Asynchronous micropython library for control of DFRobot DFPlayer Mini. Tested on ESP32 boards (Lolin32, Waveshare ESP32 driver board, DOIT ESP32DEVKIT)
Module specification and pins reference is here.
Playback control:
play(track_id) # track_id, 'next' or 'prev'
pause()
resume()
loop_track(track_id)
loop()
loop_disable()
stop()
fadeout(fadeout_ms) # non-blocking fadeout and stop
Volume control:
volume(level) # return volume level
Module control:
module_sleep()
module_wake()
module_reset()
Wire up the DFPlayer Mini MP3 breakout to the ESP32:
- VCC => 5V
- GND => GND
- TX => D16
- RX => D17
- SPK1 and SPK2 to the small speaker or DAC_R and DAC_L to the amplifier
The following example code show basic operations:
from dfplayermini import Player
from time import sleep
music = Player(pin_TX=17, pin_RX=16)
music.volume(20)
music.play(1)
sleep(10)
music.fadeout(2000)
music.play(2)
music.loop()
sleep(20)
music.module_sleep()
This project is licensed under the MIT License - see the LICENSE.md file for details