Skip to content

LRA Wireling Python Tutorial

This Wireling lets you control a Linear Resonant Actuator (LRA) or Eccentric Rotating Mass (ERM) via the I²C bus and the DRV2605 IC, to create Haptic vibration type motion.

Technical Details

TI DRV2605 LRA Haptic Driver Specs

  • Flexible Haptic/Vibra Driver
    • LRA (Linear Resonance Actuator)
    • ERM (Eccentric Rotating Mass)
  • I2C Controlled Digital Playback Engine
    • Real-Time Playback Mode via I2C
  • Smart Loop Architecture(1)
    • Automatic Overdrive/Braking (ERM/LRA)
    • Automatic Resonance Tracking (LRA)
    • Automatic Actuator Diagnostic (ERM/LRA)
    • Automatic Level Calibration (ERM/LRA)
  • Licensed Immersion™ TouchSense® 2200
    features:
    • Integrated Immersion Effect Library
    • Audio to Vibe
  • Optional PWM Input with 0% to 100% Duty Cycle
    Control Range
  • Optional Analog Input Control
  • Optional Hardware Trigger Pin
  • Efficient Output Drive
  • Fast Start Up Time
  • Constant Acceleration Over Supply Voltage
  • 1.8 V Compatible, VDD Tolerant Digital Pins
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V
  • Current: 2.5mA
Pins Used
  • A5/SCL - I²C Serial Clock line
  • A4/SDA - I²C Serial Data line
  • A(x)/INT - Interrupt Pin
    • Note: (x) corresponds to the Port number used
Dimensions
  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height 7.07mm (0.278 inches)
  • Weight: 1 gram (.04 ounces)

Notes

  • The DRV2605 chip is used for controlling LRA and ERM motors.
    • A Linear Resonance Actuator (LRA) is a buzzing motor that produces noise. Due to their construction and operating method, LRAs outlast traditional vibration motors several times over and are tuned to operate at frequencies that are optimal for skin contact. This is the type of motor soldered to the LRA Wireling
    • An Eccentric Rotating Mass (ERM) motor is a vibrating motor that produces vibration, sometimes referred to as a pager motor. Current popular uses for an ERM motor include giving feedback on user interfaces via cellphones, watches, remote controls, and touch-enabled devices.

Materials

Hardware

Required Software

  • Python 3 (Python 2 is not supported!)
  • All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)
  • DRV2605 Python package (mentioned later)
  • DRV2605 Example Program

Hardware Assembly

Plug your Wireling into the port you plan on using! The default in the included program is port 0.

If you want to use a different port, you just need to change the port value in the program mentioned later.


Programming

Install the necessary Python package:

pip3 install adafruit-circuitpython-drv2605

Use pip if Python 3 is your default. Python 2 is not supported.

Open up the included example in a terminal to see what's inside:

drv2605_example.py
# Simple demo of the DRV2605 haptic feedback motor driver.
# Will play all 123 effects in order for about a half second each.
# Author: Tony DiCola
# Adapted for TinyCircuits by: Laverena Wienclaw

import time
import tinycircuits_wireling
import board
import busio
import adafruit_drv2605

# Enable power to pi hat & wirelings
wireling = tinycircuits_wireling.Wireling()
wireling.selectPort(0) # select port 0 labeled on pi hat

# Initialize I2C bus and DRV2605 module.
i2c = busio.I2C(board.SCL, board.SDA)
drv = adafruit_drv2605.DRV2605(i2c)

drv.use_LRM() 

# Main loop runs forever trying each effect (1-123).
# See table 11.2 in the datasheet for a list of all the effect names and IDs.
#   http://www.ti.com/lit/ds/symlink/drv2605.pdf
effect_id = 1
while True:
    print('Playing effect #{0}'.format(effect_id))
    drv.sequence[0] = adafruit_drv2605.Effect(effect_id)  # Set the effect on slot 0.
    # You can assign effects to up to 7 different slots to combine
    # them in interesting ways. Index the sequence property with a
    # slot number 0 to 6.
    # Optionally, you can assign a pause to a slot. E.g.
    # drv.sequence[1] = adafruit_drv2605.Pause(0.5)  # Pause for half a second
    drv.play()       # play the effect
    time.sleep(0.5)  # for 0.5 seconds
    drv.stop()       # and then stop (if it's still running)
    # Increment effect ID and wrap back around to 1.
    effect_id += 1
    if effect_id > 123:
        effect_id = 1

Notice that this example has a call to the function use_LRM(). This makes the DRV2605 chip compatible with the use of LRA motors, like the once that comes with the LRA Wireling. If you choose to use an ERM motor instead, you would use the function use_ERM() to correctly initialize the chip for proper usage. Without using the correct mode, your motor will not work as expected.


Run Program

Navigate in the terminal to the directory with the python example and type:

python3 drv2605-example.py

Once the program is running, the LRA Wireling should start going through a list of different vibration types. Take notes on what effects are your favorite!


Contact Us

If you have any questions or feedback, feel free to email us at info@tinycircuits.com or make a post on the forum.

Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!

Thanks for making with us!


Downloads