I welcome you to my last part of my series as part of Upcycle IoT Design Challenge. Today I will complete up-cycling my broken wireless earbuds which I introduced in previous blogs.
The last part remaining in my project is controlling device using Microhip SAM E51 microcontroller. In my second blog I shown reversed schematic of earbuds. On schematics we have seen that one button is connected differently for being able wake up sleeping SoC when “powered off”. In meantime I soldered wires to buttons. Under some circumstances buttons can be emulated directly by open-drain GPIo from MCU but this is not the case, because
- MCU runs on 3.3V while earbuds SoC on 1.6V
- Middle button pulls the voltage up to battery voltage (3.7 – 4.2V)
For this reason I need to implement some kind of level-switching.
Emulating buttons using transistors
Switching the two “normal” buttons is easy because we can emulate them just using simple NMOS (on left is MCU GPIO, on right is wire soldered to earbuds buttons):
The center button is more complicated because we must pull it up instead of down. We need to use PMOS, but there is one more problem. PMOS gate is usually driven by pull-up, but problem is that we pull this voltage to 4V and at the same time attach the gate to MCU which is 3.3V only. For this reason we need cascade of NMOS and PMOS solving the issue. I do not have PMOS in home, so I used PNP instead.
Firmware
That is all. At this point I tested that driving gates emulates button presses and move forward to implement it in firmware. Earbuds distinguish short and long presses. They even understand very very long press on center button which enters pairing mode.
I extended my UART driver for capability to receiving data also (originally it was TX only) and implemented triggering actions just by typing key in UART terminal. Keys do following:
X: turn on or off earbuds (toggle power)
E: pause or resume playback (toggle playback)
C: enter paring mode
+: Volume up
-: Volume down
N: Next song
P: Previous song
S: print humidity and temperature as per previous blog
Here example of usage:
Final circuit
Final circuit showing connected earbuds, fake battery emulator, and button driving transistor looks as follows:
Conclusion
Circuit works well and I am happy about it. Working circuit shows that I correctly reversed button section of schematics of the earbuds and successfully implemented remote control originally broken earbuds using Microchip SAM E51 microcontroller which I used for a first time. The last part remaining is desoldering one broken (and one working) earbud cable and soldering output to jack or jack cable for playing sound using standalone speaker instead of one broken (and working) earbud. But this last step should not be that hard. Now I can play music wirelessly from iPhone and tune iPhone volume from serial port terminal. It is cool, is not it? :D
Thanks for reading my blog series as far. I hope you enjoy it as much as I enjoy making this project. Of course, I would be very happy if you leave some feedback in the comments below. You can download project sources in the section below.
Resources