
Keli Qiqi and two cute little ones (・ω< )★


1 Introduction
Use the Essence ESP32-S development version to receive the Bluetooth output I2S signal and decode it to UDA1334. The audio signal switches the ESP32-S Bluetooth, FM, and AUX audio sources through the CD4052 switch to the PAM8406 power amplifier, 5Wx2 2.0 channel, comes with OLED display, lithium battery Charging circuit, etc.
2.Features
1.Support Bluetooth.
2. Support AUX input.
3. Support FM frequency modulation.
4. With OLED screen to check status.
5. Comes with lithium battery, comes with lithium battery charging circuit and balanced charging circuit.
6. Use the Anxinko development version to save the download circuit.
7. Power detection and charging detection support.
8.5Wx2 2.0 channel.
9. One-click mute.
10. Visualization of volume adjustment.
11. Power supply isolation, when there is DC12V power supply, the lithium battery will not be used for power supply, extending the battery life.
3.I2S decoding
It is relatively simple. Use UDA1334 decoding IC to decode and output analog signals. You only need ESP32 to provide BCK, SW, and DATA. MCLK is not needed. Other pins can be pulled down as shown in the schematic diagram.
4.FM radio
Use TEA5767, use IIC control, output analog signal, IIC is controlled by ESP32-S, pay attention to leave the antenna.
The direct sound from the FM radio module is small, so an amplification circuit is needed. Just use S9014 to work in the amplification area.
If you feel the volume is loud, you can increase the volume of R54.

5.SOURCES SWITCH
Since there is a signal output by the decoding IC, an FM output signal, and an AUX IN signal, a SOURCES SWITCH is required. This is a 2-channel 4-channel switch from TI that can be used for analog or digital.
Controlled by AB, connected to the IO of ESP32, INH pull-down is enabled.
Here is a table for switching
OUTPUT |
B |
A |
CH0 (Bluetooth) |
0 |
0 |
CH1(FM) |
0 |
1 |
CH2(AUX) |
1 |
0 |
CH3 (empty) |
1 |
1 |
6.Charging circuit
There are two built-in lithium batteries, but most of them are single-cell charging solutions. I didn’t want to find a charger, so I used a boost charging solution, which can also be charged with ordinary 5V.
However, the charging circuit is too simple, which affects the life of the lithium battery after long-term use. It doesn't do a good job of charging while charging, so it will never be fully charged, and it will be discharged after charging.
A more mature solution is to add PMOS, disconnect the battery from the load through the 5V IN input, and then charge the battery with 5V while supplying power to the load. I was too lazy to do it here.
Modification suggestions: 1. Add a power switch 2. Add a balanced charging module 3. Use a charging IC with path management.
The one above is the old plan, and the one below is the new one.
Compared with the old solution, the new solution uses step-down charging. The advantage is that it charges quickly and can use a switching tube to make the 12V power supply directly work the load and charge the lithium battery without interfering with each other. However, the disadvantage is that you need to buy a 12V adapter.
It still uses a two-cell lithium battery charging solution, and this time a lithium battery balancing circuit is added to ensure the service life of the battery.
When there is 12V power supply, 12V will control the Q3 MOS tube to disconnect the lithium battery power supply, and then the main power supply will change from the lithium battery 7.4V to 12V, and 12V will charge the lithium battery without interfering with each other.

This circuit is actually a power supply solution that I have made before. Interested students can check out my previous projects.
https://oshwhub.com/Aknice/cn3762-shuang-chuan-lian-li-dian-chi-chong-dian
7.AMP
The COM terminal of SOURCES SWITCH is connected to the four-link adjustable resistor of the AMP, which can adjust the volume, and is connected to the ADC pin of the ESP32 for easy viewing of the volume.
Grounding the MODE pin indicates that it is a Class A/B power amplifier. This power amplifier does not require an inductor.
8.Code
Develop using Arduino
Requires btAudio-master, u8g2, Arduino TEA5767 libraries
See minimalAudio.uno
Mainly because OLED displays more codes.
9. Electrical performance test
Test equipment: ABTEC A2
Take advantage of the free time to quickly test the electrical performance of this thing.
According to the data sheet, Class AB, 4 ohm load 5V, THD+N is 1% is about 2.5W. Other data such as signal-to-noise ratio, distortion, frequency response distortion curve, etc. are not written.
It can be seen that the 2.2W THD+N is 0.5%, which is basically consistent with what is written in the data sheet. The current gain is -13db.
When the power reaches 4W, THD+N is as high as 34%, the sine wave basically appears as a square wave, and the current gain is 0db.
When the gain is -13db, the signal-to-noise ratio of 1khz is 78.746db
The frequency/gain curve is -13db at 20hz~20khz, without DRC, so it is almost a straight line.
Frequency/power curve
10. Summary
The charging circuit is too simple, which affects the life of the lithium battery after long-term use.
Modification suggestions: 1. Add a power switch 2. Add a balanced charging module 3. Use a charging IC with path management.
It's a relatively simple speaker, but the amplifier isn't powerful enough. If you really want 5W, THD+N is too bad, and you can only listen to it at 2W.
The FM antenna is not good enough, the parameters are not adjusted, the rustling sound is loud, and the automatic channel search function is not implemented. It can be improved later.
ADC sampling will drift. It is recommended to add filter capacitors and pull-up circuits to improve jitter elimination in software.
I didn’t have time to paint the casing, so I just made an acrylic fixed back panel.



See attached backplate_front view_2007.dwg
Speaker recommendation: 4 ohm 5W 66mm
Screw recommendations: Motherboard M3*16 Speaker: M3*35
Heat dissipation suggestions: MOS tubes and inductors of the power amplifier, lithium battery charging circuit, and two energy-consuming resistors of the lithium battery balancing circuit
The following is a video demonstration
The FM effect will actually be better than in the video
The rustling sound in the FM radio effect is caused by the mismatch between the FM antenna and circuit parameters. Since there is no equipment to test, the parameters are not adjusted, so there is a rustling sound, and the effect is average.