Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ShrimpingIt/micropython-dfplayer
Micropython implementation of DFPlayer control using UART 1 (secondary Serial connection)
https://github.com/ShrimpingIt/micropython-dfplayer
Last synced: about 1 month ago
JSON representation
Micropython implementation of DFPlayer control using UART 1 (secondary Serial connection)
- Host: GitHub
- URL: https://github.com/ShrimpingIt/micropython-dfplayer
- Owner: ShrimpingIt
- License: agpl-3.0
- Created: 2017-07-07T09:40:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-17T16:27:56.000Z (over 4 years ago)
- Last Synced: 2024-08-02T20:45:08.566Z (4 months ago)
- Language: Python
- Size: 112 KB
- Stars: 41
- Watchers: 5
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mpython - micropython-dfplayer - Driver for DFPlayer Mini using UART. (精选驱动库 / 输出类)
- awesome-micropython - micropython-dfplayer - Driver for DFPlayer Mini using UART. (Libraries / Audio)
README
# micropython-dfplayer
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 https://github.com/jczic/KT403A-MP3/blob/master/kt403A.py instead.
To use, wire up the DFPlayer Mini MP3 breakout module following this loom...
![alt text](550px-Miniplayer_pin_map.png)
* 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 JackThe 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.```python
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]
player.playFolder(folder)
while player.playing():
sleep(0.1)
keyPos = (keyPos + 1) % len(availableFolders)
else:
print("No available tracks")
```