ATtiny85 TinyDFPlayer SMD

1 year ago

Profile:ATtiny-controlled and LiPo Battery-powered MP3-Player using the DFPlayerMini Module

Open source license: CC-BY-SA 3.0

  • 5.3k
  • 8
  • 23

Description

Overview

TinyDFPlayer is an ATtiny controlled and LiPo battery powered MP3-Player using the DFPlayerMini module featuring:

  • Micro-SD-card slot
  • Battery charging and protection circuit
  • Battery level detection
  • OLED display
  • On/off switch
  • Volume control
  • Three push buttons to control the player
  • Remembers the last track played after switching off (EEPROM)

You can directly connect a 3.7 V Li-Po battery and a 3 W / 4 Ohm speaker to the board.

pic1.jpg

Hardware

DFPlayer Mini Module

The DFPLayer Mini module is a serial MP3 module that offers the perfect built-in MP3 hardware decoding. It supports TF cards with FAT16 and FAT32 file systems. Music playback as well as other functions can be controlled by simple serial commands without cumbersome software implementation. The main features of the module are easy to use, stable and reliable functions.

Battery Charger

For battery charging the TP4056 is used. The TP4056 is a complete constant-current/constant-voltage linear charger for single cell lithium-ion batteries. The charge voltage is fixed at 4.2V and the charge current (max 1000mA) can be programmed externally with a single resistor (R6). The TP4056 automatically terminates the charge cycle when the charge current drops to 1/10th the programmed value after the final float voltage is reached. Other features include current monitor, under voltage lockout and automatic recharge. Charging is done via the built-in Micro USB connector.

Battery Protection

For the battery protection (overcharge, overdischarge, overcurrent and short circuit protection) the DW01A is used in combination with an FS8205 dual MOSFET. The DW01A is constantly measuring the voltage across the battery and the current flowing in (when charging) or coming out (when discharging). If something goes wrong it takes the battery out of the circuit by closing the MOSFET which acts like a switch between the negative side of the battery (B-) and ground. The overcurrent protection works by comparing the voltage drop across the MOSFET with the internal 150mV reference of the DW01A. As the RDS(on) of one FS8205 is around 2x25mOhm, the DW01A will close the MOSFET at 150mV/50mOhm = 3A.

User Interface

The user interface utilizes three buttons, a wheel potentiometer and a 128x64 pixels OLED display. An ATtiny85 microcontroller brings it all together.

Building Instructions

Calibrating ATtiny85's Internal Oscillator

Error-free serial communication with the DFPlayer module requires precise timing. Usually the internal oscillator of the ATtiny85 used for this is sufficiently accurate (at least I haven't had any problems so far). However, the serial communication may not work due to an imprecise oscillator. It is therefore recommended to calibrate it manually. There are numerous instructions on how to do this on the Internet. Alternatively, the TinyCalibrator can be used for this.

Building the TinyDFPlayer

Solder all of the components onto the circuit board. Connect a 3.7 V Li-Po battery and a 3 W / 4 Ohm speaker to the corresponding pin headers.

pic3.jpg

If you want to use the 3D-printed case, first install a 70 x 40 mm speaker in the lower part of the housing and screw it in with 2.3 x 5 mm self-tapping screws. Place an approx. 1 cm thick piece of foam behind the speaker, which fits tightly against the outer walls of the housing. This improves the sound quality significantly and separates the battery from the speaker. Then place the battery. Click the upper part of the housing on the lower part and screw on the TinyDFPlayer Board with 2.3 x 5 mm self-tapping screws. Glue four rubber feet to the underside of the player.

pic4.jpgpic5.jpgpic6.jpg

Compiling and Uploading the Software

If using the Arduino IDE

  • Make sure you have installed the following core and libraries:
  • Go to Tools -> Board -> ATtinyCore and select ATtiny25/45/85 (No bootloader).
  • Go to Tools and choose the following board options:
    • Chip: ATtiny85
    • Clock: 8 MHz (internal)
    • Leave the rest at the default settings
  • Connect your programmer to your PC and to the ICSP header of the device.
  • Go to Tools -> Programmer and select your ISP programmer (e.g. USBasp).
  • Go to Tools -> Burn Bootloader to burn the fuses.
  • Open TinyDFPlayer sketch and click Upload.

If using the precompiled hex-file

  • Make sure you have installed avrdude.
  • Connect your programmer to your PC and to the ICSP header of the device.
  • Open a terminal.
  • Navigate to the folder with the hex-file.
  • Execute the following command (if necessary replace "usbasp" with the programmer you use):
    avrdude -c usbasp -p t85 -U lfuse:w:0xe2:m -U hfuse:w:0xd7:m -U efuse:w:0xff:m -U flash:w:tinyDFPlayer_v1.2.hex

Operating Instructions

Preparing the SD-Card

Micro SD cards (TF cards) with a maximum of 32 GB are supported. The card should be formatted in the FAT32 file system. The firmware is written for the folder-play function of the DFPlayer. This means you have to create folders named 01, 02, 03, ... in the SD card root and inside the folders you have to name the audio files 001.mp3, 002.mp3, ... The maximum number of folders is 99 and the maximum number of files per folder is 255. Don't leave gaps in the folders or file numbers. After the three-digit number of the MP3 files, the title name can be added for better identification, e.g. "003_MySong.mp3". Note that the title names cannot be read out and transmitted by the MiniDFPlayer module, so unfortunately it is not possible to display the title names.

There must not be any unnecessary files on the SD card, such as those stored there by MacOS (e.g. Spotlight). Better take Linux or Windows to write to the SD card. Under MacOS you can try to clean up with the following command:

$ dot_clean /Volumes/SD-Card

Insert the SD card into the corresponding slot of the DFPlayer Mini module.

Operating the TinyDFPlayer

The device is switched on with the power switch. The two outer buttons are used to switch files and folders. The middle button is used to switch between pause and play. The wheel potentiometer is for choosing the volume. All necessary information is displayed on the OLED. To charge the battery, connect a 5V power supply via the micro USB port.

pic2.jpg

License

license.png

This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)

Documents

TinyDFPlayer

Open in editor

TinyDFPlayer_v1.0

Open in editor

BOM

ID Name Designator Footprint Quantity
1 Header SPK HDR-1X2/2.54 1
2 Connector BAT HDR-1X2/2.54 1
3 DFPlayer U2 DFPLAYER_MINI 1
4 100n C1,C9,C3 0805 3
5 10u C8 0805 1
6 I2C I2C HDR-4X1/2.54 1
7 470uF C10 CAP-SMD_D10.0-L10.3-W10.3-H10.2 1
8 OLED OLED OLED 1
9 ATTINY85-20SU U1 SOIC-8_208MIL 1
10 USB PWR Connector USB USB PWR CONNECTOR 1
11 Slide Switch POWER SLIDE SWITCH DPDT 1P2T JB 1
12 FS8205 Q1 SOT-23-6 1
13 ICSP-6 ICSP ICSP-6 1
14 3x6x2.5 PREV,NEXT,OK KEY-3.0*6.0 3
15 1k R12,R7 0805 2
16 10k R11,R10,R1,R9 0805 4
17 4k7 R4,R3 0805 2
18 1k2 R6 0805 1
19 1k5 R5,R2 0805 2
20 100 R8 0805 1
21 DW01A U5 SOT-23-6 1
22 47u C2 1206 1
23 Red L2 LED-0805 1
24 Blue L1 LED-0805 1
25 TP4056 U4 SOP-8_EP_150MIL 1
26 B103 3 pin U6 B103 3 PIN 1

Unfold

Project Members

Project Attachments

Login or Register to comment
Comments have been closed by project owner
Comments have been closed by mission publisher
All comments 8

Stefan Wagner

@jasonmrc: And I created folders 01, 02, 03, ... in the sd-card root and inside the folders 001.mp3, 002.mp3, ...

2019-12-01 16:41:45
Reply

Stefan Wagner

@jasonmrc: I've uploaded the hex-file and also send it via email. My bigger chip has the number YX5200-24SS.

2019-12-01 16:17:54
Reply

jasonmrc

@wagiminator Hi , can you send me the compiled hex to jmcservv at gmail dot com. i have created a folder on the sd card mp3 and put some mps3 in it . when i play it  it only plays the first file 0001.mp3. selecting file 2 plays again the first file.  i await your hex file to test with !  thanks and happy weekend !

2019-12-01 10:38:18
Reply

Stefan Wagner

@jasonmrc: Mmmmh, I use Arduino v1.8.8, maybe that's an issue. I will compile the sketch and upload the hex-file as soon as I'm on my "workstation". Maybe we can see a little bit clearer then. I will also look at the dfplayer for the number which is printed on it.

2019-12-01 08:37:33
Reply

jasonmrc

@wagiminator  I used a 2GB tf card , as for fuses i used avrdudezz with line -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m


then wired the df player to an arduino uno - same tf card - but used the library dfplayer_fast , and it worked fine .


so i ported the tinyplayer to the fast library and its working - but -


ejecting the card it will no show the error
files and folders  are read and give a maximum of 25
buttons work fine too.
volume works - battery shows full at batt 4.3v circa.


So there is an issue with the library of the dfrobot ? is the cheap df player using the same protocol and codes to initialise the board?


I leave you with these questions . meanwhile I will try a 1gb card

2019-11-30 21:31:45
Reply

Stefan Wagner

@jasonmrc: And check if you have set the fuses of the ATtiny to 8MHz internal ("Burn bootloader" in the Arduino IDE) to have a working serial communictaion with the dfplayer.

2019-11-30 14:40:04
Reply

Stefan Wagner

@jasonmrc: Mmmmh, I also used a cheap dfplayer. I think it could be the sd-card. Have you tried to use one with 4GB or less? The bigger ones often have compatibility issues.

2019-11-30 14:25:06
Reply

jasonmrc

Hi


I build this project , but when i power up it says starting ... then says error sd card . i tried formatting it in exfat , fat16,fat32 and also put files like 0001.mp3 in root , in folder mp3, in folder  advert as per datasheet. 1


One thing i should highlight is inspecting the dfplayer mini module the small chip us without a number and the bigger chip has number AA19HFA440-94 . Maybe these are cheap copies on the internet !


will dig deeper about these mp3 modules ..

2019-11-30 12:16:35
Reply

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn