| OpenMic Audio recorder |
The charging side itself is not too hard A TP4054 can charge a 3.7V LiPo from 5V USB. A simple regulator such as ME6211C33M5G can regulate from the battery to 3.3V.
The ESP32-S3 has a number of low power modes, meaning you can make a device, e.g. a Watchy, which can run off a small LiPo for weeks with the ESP32 in a low power mode for longer periods.
But there are a couple of challenges. One is powering down other stuff on the board - a good example being the WS2812 style LEDs - these use a small amount of power even when not lit. A simple fix for these is a point of load device like TPS22916 - it acts as a power switch and can easily cut the power to parts of the board.
| Simple charger circuit |
But what if you want to have an off mode, where, instead of running in a low power mode for a few weeks you want something that uses no power when off, and holds battery charge for months or years (subject to internal leakage). My OpenMic Audio recorder is a good example of this.
The answer is to used the TPS22916 to control the power to the whole board, including the processor.
I tried a couple of times and now have this circuit design...
| Power on circuit |
To explain this... The switch SW3 is a nice little push button. When pressed it connects the battery (pin 3) to the ON input on the TPS22916. This powers on the board (VSWITCHED).
The very first thing the software does is set PWR GPIO to output HIGH level. This, via the diode (because GPIO is 3.3V and battery is 3.7V) holds the ON pin high.
Releasing the switch disconnects the battery from ON pin, but the PWR holds it high and keeps power on.
Separately the software sets the BTN GPIO to an input, weak pulled low. This is connected to ON which is connected to PWR (3.3V less a diode). This allows the software to read this as high when button not pressed.
Pressing the button when on simply changes ON from 3.3V to 3.7V and has no effect, but it disconnected BTN, which goes low due to weak pull down. Thus allowing the software to detect button presses when running normally.
Finally, when turning off, the software sets the PWR output low. The ESP32 actually has a mode to hold a GPIO at a level over reset, which allows the pin to be held low as the processor loses power and goes in to reset (brownout detect).
Once off, the whole board is not powered and only power usage is the tiny amount the TPS22916 may use, and any used by idle battery charging TP4054.
So far tests show that even after months, my audio record still shows a full battery level when turned on.
Finally I have simple potential divide in to an ADC input from VSWITCHED to allow battery level estimation.
Next steps: There are chips designed to use fuck all power but provide a configurable periodic wake up output. These could be used to power on the ESP32 periodically, much like the low power mode on the ESP32 itself, but lower power - so devices could wake once a day, for example, and run of a battery for years if needed.