There is a bit of a problem with Tap right now... Or, well, everything in general.
The chip shortage seems to have grown just a little further outward, and captured the battery charge IC that I was initially planning to use. There are alternative models, of course, but... I thought, why not try and replace it with components I am more comfortable with using. The BGA is very tricky to solder, after all.
This, however, turned out to be tricky. This single charger IC has so much functionality all in this little module:
- 1.8V LDO
- 2x Load switch
- Button reset circuit with power on/off
- ADC for battery measurement
At first I wanted to use discrete components to fill this gap, but that quickly turned into a bit of a mess, because for the button reset function alone you need three new ICs.
But... What about a separate controller? Something low powered, like an STM32L0 at low clock speed. This would be able to control the load switch, it has an ADC, and might even provide extra GPIO pins if necessary.
And then it hit me - it can do a lot more than this. It can, for example, take over the SPI slave role required to extract the camera feed of the ADPS gesture sensor, something the ESP might struggle with. It could act as battery gauge, estimating battery current over a resistor.
Best of all, it could read the ESP32's UART log output.
When the ESP crashes, it dumps a crash message to UART, which cannot be rerouted to, ex., MQTT or Bluetooth, because it's crashed. But the STM? It could happily receive the crash message, buffer it, and then write it onto the OLED screen that is built in, or send the crash message back to the ESP once it rebooted so it can be sent to a log server.
Even though STMs are in short supply and a bit more expensive, I did find that digikey still has the STM32L051 series - at 4€ in single quantity, but better than nothing.
This will, of course, take further work to program and get right, but it could elevate the badge even further.
More importantly, this STM external coprocessor could be reused in a large number of other projects to fill in some of the gaps that the ESP leaves in terms of analog, power consumption and IO pin count.
I will have to play with the idea and report back!