Skip to content
Micropython implementation of DFPlayer control using UART 1 (secondary Serial connection)
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Added pycharm folder suppression Sep 13, 2017
550px-Miniplayer_pin_map.png Image Jul 10, 2017
LICENSE Initial commit Jul 7, 2017 Update Oct 22, 2019 Config delay lengthened. Added polling finish() method which returns … Sep 13, 2017 Workaround for volume being set back to 0.5 after test-play Nov 4, 2017


Micropython implementation of DFPlayer control using UART 1 (secondary Serial connection) on ESP8266

If you are not limited to ESP8266 (with its TX-only UART) you should consider using instead.

To use, wire up the DFPlayer Mini MP3 breakout module following this loom...

alt text

  • DFPlayer Mini
    • VCC => 5V Vin
    • All GND pins => GND
    • Busy Pin (immediately opposite VCC) => GPIO2 (NodeMCU D3)
    • RX Pin (immediately below VCC) => GPIO0 (NodeMCU D4)
    • SPK1+SPK2 to a 3W speaker (limiting the volume to 0.5 can help prevent brownout for larger wattage speakers)
    • ...or...
    • DAC_R+DAC_L to a 3.5mm Line Out Jack

The following example code uses the ScanPlayer.

It will first scan all available folders for files called 000_XXX.mp3 001_XXX.mp3 and so on.

It considers only folders named 00-09.

It will play a single track from each folder in turn, only repeating a folder when all folders are exhausted, and only repeating a track when all tracks have been exhausted.

from time import sleep
import scanplayer
player = scanplayer.ScanPlayer()
availableFolders = list(player.tracks.keys())
if len(availableFolders) > 0:
    keyPos = 0
    while True:
        folder = availableFolders[keyPos]
        while player.playing():
        keyPos = (keyPos + 1) %  len(availableFolders)
    print("No available tracks")
You can’t perform that action at this time.