A lightweight and robust CircuitPython driver library for the DFPlayer-Mini and MP3-TF-16P v3.0 MP3 modules. This library is specifically optimized for stability with newer HW-247A and GT3200B (v3.0) chips, implementing necessary command delays and checksum verification.
- Broad Compatibility: Works with DFPlayer-Mini, MP3-TF-16P, and clones.
- Optimized for v3.0: Handles the timing sensitivities of newer hardware versions.
- Full API Support: Playback control, volume management, EQ settings, and folder navigation.
- Debugging Support: Optional verbose logging for troubleshooting communication.
- Checksum Verification: Ensures data integrity for all UART packets.
- Ensure your CircuitPython board is set up and connected.
- Copy the
lib/DFPlayer.pyfile to thelib/folder on yourCIRCUITPYdrive.
| DFPlayer Pin | CircuitPython Pin | Description |
|---|---|---|
| VCC | 3.3V or 5V | Power (Check module specs) |
| RX | TX (e.g., GP0) | UART Transmit from board |
| TX | RX (e.g., GP1) | UART Receive to board |
| GND | GND | Common Ground |
Note: A 1kΩ resistor is recommended on the RX pin of the DFPlayer when using 5V logic to reduce noise.
import board
import busio
from DFPlayer import DFPlayer
# Initialize UART
uart = busio.UART(board.GP0, board.GP1, baudrate=9600, timeout=0.1)
# Initialize DFPlayer
df = DFPlayer(uart, volume=15)
# Play the first track
df.play_track(1)
# Next track
df.next()Organize your SD card with folders named 01, 02, etc., and files named 001.mp3, 002.mp3.
# Play folder 1, track 5
df.play_folder(1, 5)status = df.query_status()
volume = df.query_volume()MIT License