adafruit_drv2605
Works with
Any board with I2C. Drives ERM (eccentric rotating mass) or LRA (linear resonant actuator) vibration motors.
What it does
adafruit_drv2605 controls the DRV2605L haptic motor driver chip, which can drive the small vibration motors found in phones, game controllers, and wearables. The chip has 123 built-in waveform effects — from sharp clicks and ticks to long buzzes and double pulses — stored in ROM. You select effects by number, queue up to eight in sequence, and trigger playback. No PWM tuning required. You can also generate your own waveforms in real-time mode, but the ROM effects cover most use cases.
The chip supports both ERM motors (the coin-shaped or cylindrical vibrating motors) and LRA motors (linear actuators used in newer phones for haptic feedback). You configure which type you have once at startup.
Installing the library
Copy all of the following to CIRCUITPY/lib/:
adafruit_drv2605.mpyadafruit_bus_device/(folder)
Quick start
import time
import board
import adafruit_drv2605
i2c = board.I2C()
drv = adafruit_drv2605.DRV2605(i2c)
# Configure for your motor type (call once at startup)
drv.use_ERM() # for coin/cylindrical vibration motors
# drv.use_LRA() # for linear resonant actuators
# Play a single effect
drv.sequence[0] = adafruit_drv2605.Effect(1) # effect 1: strong click
drv.play()
time.sleep(0.5)
drv.stop()
# Queue a sequence of effects
drv.sequence[0] = adafruit_drv2605.Effect(1) # strong click
drv.sequence[1] = adafruit_drv2605.Pause(100) # 100 ms pause
drv.sequence[2] = adafruit_drv2605.Effect(14) # sharp tick
drv.sequence[3] = adafruit_drv2605.Effect(47) # buzz
drv.play()
time.sleep(1)
drv.stop()
Key things you can do
| What you want | How to do it |
|---|---|
| Play a single effect | drv.sequence[0] = adafruit_drv2605.Effect(n) then drv.play() |
| Stop playback | drv.stop() |
| Queue multiple effects | Fill drv.sequence[0] through drv.sequence[7] |
| Add a pause between effects | drv.sequence[n] = adafruit_drv2605.Pause(ms) (10–1270 ms) |
| Set motor type to ERM | drv.use_ERM() |
| Set motor type to LRA | drv.use_LRA() |
| Play effect 1 (strong click) | drv.sequence[0] = adafruit_drv2605.Effect(1) |
| Play effect 14 (sharp tick) | drv.sequence[0] = adafruit_drv2605.Effect(14) |
| Play effect 47 (buzz) | drv.sequence[0] = adafruit_drv2605.Effect(47) |
| Browse all 123 effects | Effects 1–123; consult the DRV2605L datasheet Section 11 for the full list |
Reading the official docs
Full API reference: https://docs.circuitpython.org/projects/drv2605/en/latest/
Projects using this library
- Adafruit DRV2605 Haptic Controller Breakout — wiring and code examples for the breakout board