I have done a lot of small circuit boards, but one of the challenges with any board is battery working.
I used the Watchy as a good example of this, understanding how to put the ESP32 in to deep sleep and so on. This worked very well. What I had not done until now was actually make a battery based board myself.
The first attempt, which was a massive long shot, was to test if I could run an ESP32 (ESP32-S3-MINI-1) off a button cell. The answer is no. This was not a big surprise.
So the next attempt was this :-
This has a small LiPo battery, an LDO regulator, and a charger circuit. This is basically copied the choice of components for these from the Watchy design.
There are a few things you need for battery working though - for a start, I have a FET to control power to the LED chain. The LEDs, when idle, do use very little power, but for battery working I want it to be zero power. So I have a GPIO that actually switches the power for the LED chain on and off (this is the small WS2812B compatible 3.3V RGB LEDs I have been using lately).
Another small trick is to also use a FET to switch the battery voltage to an ADC. The ADC on the ESP32 needs a lower voltage, so has a potential divider. The problem is a potential divider uses a small amount of current all the time - so again, this is switched on using a FET. I don't know if that is really necessary, but every uA helps. This should, hopefully, allow me to confirm battery levels whenever I need.
One small issue, which I have yet to quite get to the bottom of, is waking from deep sleep. The ESP32 IDF seems to suggest it is possible to make any RTC GPIO cause a wake on a state change. This is ideal for any buttons (I have two on that board design). However, that did not seem to work. I'll experiment more. There is, however, a separate way to do this, which is you can have a set of RTC GPIOs and wake on "any high" or "all low". For more than one button (I added two for the hell of it), this only really works if you have the idle state of the button low, not high. I had, as is common, had these buttons switched to GND with a pull up. I had to change the design not be reversed to allow wake on either button being pressed (at least until I get the "change of state" logic working).
I had fun finding a suitable upright USB-C connector, and I have juggled the various connector positions a bit since this original design.
Now to find what the battery life is when idle, and how many times you can use it before it goes flat. But it does work - yay!
The wake on RTC IOs definitely work, keep on fiddling! Another option is use a FET or PMC to completely shut down the ESP when idle, obviously depends on the application as to whether this is appropriate, but its ideal for stuff that might sit in a drawer for weeks at a time when you don't want to come back to a flat batt. Patrick
ReplyDeleteI use the pin enable of the ESP32 from a microcontroller in one of my projects, this will turn off the ESP32 and it should draw insignificant power. Maybe without another microcontroller it could self latch on, so have it pulled down to ground with a resistor then a button puts it high and starts the ESP32 and then use a GPIO pin to latch itself high for as long as needed? I guess this depends on how quick that GPIO pin can be put high, a small capacitor could perhaps keep the pin high for a few hundred milliseconds to allow time for it to latch itself on. You can then have it turn itself off by dropping the GPIO to ground. Of course this is only of use if you don't want it to turn itself on using the RTC.
ReplyDelete