ESP32-S3 Battery
Using a battery with the Adafruit ESP32-S3 is easy as pie.
11/09/2023
What's the point in having such a compact, portable board when you have to be tethered to a USB port to power it? Luckily for us, it's dead easy to get a battery working with this ESP32 board from Adafruits. I'll outline it here:
1. Buy battery.
2. Plug in battery.
3. Destroy circuit board. (optional)
You only have to execute step 3 if you get your wires crossed, which I came very close to doing, so heed this warning.
I purchased this battery from Amazon - 1100mAh was more than enough capacity while keeping the battery itself quite small. It arrived a couple of days later. I was excited to plug it in and free myself from the tether of USB power.
But wait, something is a miss. The polarity was the wrong way around.
If I had plugged it in like that, it probably would have zapped the board. Luckily, this is an easy fix.
Changing the battery polarity
On the white connector at the end of the cables, simple lift the tabs over each wire and pull the wire out, then plug them back in the other way around. Now the positive side of the battery will plug into the positive part of the board and vice versa. Easy as that. I could now plug the battery in and start using it. The battery can be charged over USB C and then will be automatically drained when not plugged into a power source - it really could not be easier.
Monitoring the Battery
"But how much charge do I have left?" Good question. Thanks to the battery monitoring chip on the board (MAX17048) it's trivial to query the amount of power left. The MAX17048 library can be installed via the Arduino IDE. I wrote a small program to query the status and display the results on the TFT display. Find my code below:
#include "Adafruit_MAX1704X.h"
#include <Adafruit_ST7789.h>
#include <Adafruit_GFX.h>
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_MAX17048 batt;
void setup() {
// turn on backlite
pinMode(TFT_BACKLITE, OUTPUT);
digitalWrite(TFT_BACKLITE, HIGH);
// turn on the TFT / I2C power supply
pinMode(TFT_I2C_POWER, OUTPUT);
digitalWrite(TFT_I2C_POWER, HIGH);
// initialize TFT
tft.init(135, 240); // Init ST7789 240x135
tft.setRotation(3);
tft.setTextSize(2);
tft.fillScreen(ST77XX_BLACK);
batt.begin();
}
void loop() {
tft.fillScreen(0);
tft.print("Battery: ");
tft.print(batt.cellPercent());
tft.println("%");
tft.print("Voltage: ");
tft.print(batt.cellVoltage());
tft.println("V");
tft.print("Charge Rate: ");
tft.print(batt.chargeRate());
tft.println("%/h");
tft.setCursor(0,0);
delay(2000);
}
And that's it. I can now charge and use my board without being attached to my laptop.