The Problem:
So, we’ve quickly reached a point where deploying hundreds of battery operated interactive items in a single morning has become physically infeasible. The main technical challenge is actually due to the batteries needing to be plugged in less than a few hours ahead of time (depending on the device).
The obvious, and most easy solution was to just implement an ESP32 sleep mode where the EPS32 would check every couple minutes to see if it should wake up. However – and we should have known this – the typical 5V USB batteries you buy on amazon typically completely shut off at that low of current in an attempt to stop the battery from continuing to drain with nothing attached.
This makes sense…however, it completely makes the ESP32 sleep mode unusable.
The Solution:
Unfortunately, no simple solution exists (within a reasonable budget). We mass deploy these interactive items, so even a 5 dollar increase in costs can add up to thousands in expenses very very quickly.
So we had to take matters into our own hands (and solve a few additional problems at the same time)!
A few things to note:
- A typical 5v USB operated battery is actually a 3.7v battery transformed to 5v (probably 90%ish efficient).
- The ESP32 accepts 5v but actually uses an LDO to convert it to 3.3v. The 1.7v is completed wasted as heat.
- Peripheral devices attached to the battery still consume power even if the ESP32 is asleep.
- Without access to the 5v USB battery internals, we have no way to measure the remaining battery life.
With all these considerations in mind, it seemed we could not only fix the battery shut off issue, but massively increase battery efficiency and convenience at the same time. Ya bb!
So that’s exactly what we did.
Firstly, we used DW01 chip to do basic battery management. However, like all things, there’s a gotcha: the chip needs to have a current applied to begin operation after being attached to a battery. The chip is designed to always be attached to a battery (which we were not planning on doing).
Next we used an LDO to create a 3.3v line directly for the ESP32. Because the battery will start at around ~4.1v and drop down to ~3v, we use the LDO to initially regulate the voltage down for the ESP32. This DOES waste energy as heat, but considerably less than 5v to 3.3v
Then we added an ESP32 controllable MOSFET that we use to supply battery level voltage to any downstream devices (ex: lights, audio, etc). We added the controllable MOSFET so that when the ESP32 goes to sleep, we can disable all downstream devices and prevent any current losses (prolonging battery life).
And finally we just added a simple voltage divider to measure the battery voltage (without frying the ESP32 pins – which only take 3.3v). This we can use to estimate the remaining battery life and send it to the server.
Boom! And now we can put the ESP32s to sleep for weeks, issue a command from the server, and have them wake up within 5 minutes!