Bluetooth Media Button
October 20, 2020 1 Comment
This is a pretty straight forward project, though it still took a while to get everything fitting together nicely 🙂
The idea was to re-use this nice big volume knob from an old, analog amplifier, put it into a custom little box and make it able to control the volume of my computer.
Using an ESP32 is definitely overkill for the functionality, but I had one laying around and it has Bluetooth integrated, as well as a nice “deep sleep” feature which allows me to save battery and have the button run on a single small batter for quite some time.
The MH-CD42 Charge&Discharge circuit’s role is to two-fold:
- charge the battery
- step up the 3.7V of the battery to the necessary 5V for the ESP32 board
However, getting it to work was a bit fiddly, due to the fact that it’s really designed for a typical USB power bank, which means that when connected to a battery it only starts providing a low (~2.5V) voltage at the output, and then only if there’s a load (more than ~30mA I think) it goes to the full 5V. This was an issue for me, as the ESP32 wouldn’t start at this low voltage.
One can force it to “wake up” by pressing the small onboard button, or taking the “Key” pad to LOW/GND.
To solve this issue I connected the same momentary switch that I use for play/pause to this “Key” pad, which means that on startup one has to press it once.
The MH-CD42 has other features like going automatically to sleep if no current is drawn for a given amount of time, being able to put it to sleep by pressing the small onboard switch twice, etc. … These are actually nice to have features for my project too.
In order to ensure that the batter lasts for as long as possible, I’ve also implemented a “deep sleep” feature: the button/ESP32 will go to sleep after 30seconds of lack of usage.
In order to gracefully wake it up, as opposed to doing a hard reset through a power cycle, I had to provide an external interrupt on one of its pins, which I did using the same play/pause button (which is connected to PIN 33).
So this switch is connected to both the above ESP 32 pin and the “Key pad” on the Charge&Discharge circuit and serves 3 purposes:
- send the play/pause command through Bluetooth
- force start/stop of the MH-CD42
- wake the ESP32 up
Again, though seemingly simple, the box did take quite a bit of thinking and a few iterations to get just right… More than half of the space is taken by the metal weights, just so that it “feels good” in the hand 🙂
As usual, you can find all the ESP32 code as well as the 3D models of the box on my Github account.
Pingback: Game on IKEA Obergransad LED display | Robotics / Electronics / Physical Computing