Powering ESP32-C6 with AA batteries

Hello,
I’m working on the project where I need to power my ESP32-C6 with alkaline AA batteries. Although I know it’s not the most efficient way, this is my requirement. The aim of the project is to measure cuurent with TMAG5273 sesnor, display data on OLED screen and also send data via WiFi to ThingsBoard.

Initially, I wanted to use V3.3 pin to power mC but as I went through documentation, I figured out that it only works as an output (am I right?) and I need to use VBUS pin. So my idea is to use 4 AA batteries → buck/boost converter which gives 5 V output → Schottky diode → VBUS pin. The diode would be connected beween the converter’s VOUT and VBUS pin on the ESP32.

I also want to add two capacitors between ESP32’s VBUS and GND (100 uF and 0.1uF) to prevent current spikes when using WiFi.

Is it a right approach? Would that work?
I will be grateful for any advice.

You might also find this link helpful.

That sounds fine. Use large bulk capacitors as well… 100uF is OK, but I use larger when possible.
Calibrate the TMAG5273 (interesting approach :wink: ) when on board based on your trace position.

Since you have the buck/boost and diode, you could use the 3V3 input if power is an issue.

I don’t see that - but maybe I have an old schematic? Also don’t use the USB or Batt supply.

Hi There,

So You , Do’nt need to make it so complex , it is a pretty straight forward ask, and done often,. search the posts and you will find more.

You want to use an E-paper instead of the OLED,
You’re not doing Graphics or crazy Icons, SO Keep is Simple. e-paper draws almost no power and none when off Use the Xiao to control its Vcc and wire the Sleep mode correctly and it should work a reasonable amount of time on 3 NON_rechargable batteries.

Here is a good starting point for this configuration, I have some experience with it.

#include <Wire.h>
#include <SPI.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeSansBold9pt7b.h>
#include <TMAG5273.h> // Ensure you have the TI TMAG5273 library installed

// Define pins for XIAO ESP32-C6 SPI E-Paper Display
// Adjust these depending on your specific e-paper wiring breakout
const int EPD_CS   = D3; 
const int EPD_DC   = D2; 
const int EPD_RST  = D1; 
const int EPD_BUSY = D0; 

// Initialize E-Paper (e.g., 2.9 inch monochrome display variant)
GxEPD2_BW<GxEPD2_290_T9, GxEPD2_290_T9::HEIGHT> display(GxEPD2_290_T9(/*CS*/ EPD_CS, /*DC*/ EPD_DC, /*RST*/ EPD_RST, /*BUSY*/ EPD_BUSY));

TMAG5273 tmagSensor;

// Sleep interval configuration (e.g., wake every 60 seconds)
#define uS_TO_S_FACTOR 1000000ULL
#define TIME_TO_SLEEP  60 

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Initialize I2C for TMAG5273
  Wire.begin();
  
  // Initialize TMAG5273 sensor
  if (!tmagSensor.begin(Wire, TMAG5273_I2C_ADDRESS_DEFAULT)) {
    Serial.println("Could not find a valid TMAG5273 sensor, check wiring!");
    while (1) { delay(10); }
  }
  
  // Configure TMAG5273 for automatic temperature and 3-axis conversion
  tmagSensor.setAxis(TMAG5273_X_ENABLE | TMAG5273_Y_ENABLE | TMAG5273_Z_ENABLE);
  tmagSensor.setMeasurementMode(TMAG5273_STANDBY_MODE);

  // Initialize E-Paper Display SPI
  display.init(115200, true, 2, false); // init parameters for typical SPI setup
  display.setRotation(1);

  // Read Sensor Data
  float xVal = tmagSensor.getXData();
  float yVal = tmagSensor.getYData();
  float zVal = tmagSensor.getZData();

  // Update E-Paper Screen
  drawDisplayData(xVal, yVal, zVal);

  // Put E-Paper into sleep/power-off state to draw zero quiescent power
  display.hibernate();

  // Configure Deep Sleep Timer
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  Serial.println("Entering ESP32-C6 deep sleep...");
  Serial.flush();
  
  esp_deep_sleep_start();
}

void loop() {
  // Not used in deep sleep architecture
}

void drawDisplayData(float x, float y, float z) {
  display.setFullWindow();
  display.firstPage();
  do {
    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);
    display.setFont(&FreeSansBold9pt7b);
    
    display.setCursor(10, 25);
    display.print("SENSOR: TMAG5273");
    
    display.setCursor(10, 50);
    display.print("X: "); display.print(x, 1); display.print(" mT");
    
    display.setCursor(10, 75);
    display.print("Y: "); display.print(y, 1); display.print(" mT");
    
    display.setCursor(10, 100);
    display.print("Z: "); display.print(z, 1); display.print(" mT");

    display.setCursor(10, 125);
    display.print("STATUS: OK");
  } while (display.nextPage());
}
  1. Install the GxEPD2 and TMAG5273 libraries via the Arduino IDE Library Manager.
  2. Double-check your SPI pin mapping if you use a standard Waveshare or Seeed e-paper breakout module to match D0-D3 on the XIAO ESP32-C6.

HTH
GL :slight_smile: PJ :v:

This one, connects your XIAO ESP32-C6 to your local Wi-Fi network and publishes the TMAG5273 magnetic sensor readings to a simple built-in web server page. When it wakes up, it connects, hosts a local webpage for a few seconds so you can view it (or fetch it via an automation script), updates the e-paper screen, and goes right back to deep sleep.

#include <Wire.h>
#include <SPI.h>
#include <WiFi.h>
#include <WebServer.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeSansBold9pt7b.h>
#include <TMAG5273.h>

// Wi-Fi Credentials
const char* ssid     = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

WebServer server(80);

// Define pins for XIAO ESP32-C6 SPI E-Paper Display
const int EPD_CS   = D3; 
const int EPD_DC   = D2; 
const int EPD_RST  = D1; 
const int EPD_BUSY = D0; 

GxEPD2_BW<GxEPD2_290_T9, GxEPD2_290_T9::HEIGHT> display(GxEPD2_290_T9(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY));
TMAG5273 tmagSensor;

// Global variables to hold latest readings for the web server
float currentX = 0, currentY = 0, currentZ = 0;

#define uS_TO_S_FACTOR 1000000ULL
#define TIME_TO_SLEEP  60 

void handleRoot() {
  String html = "<html lang='en'><head><meta http-equiv='refresh' content='10'/></head><body>";
  html += "<h2>TMAG5273 Sensor Status</h2>";
  html += "<p><strong>X-Axis:</strong> " + String(currentX, 1) + " mT</p>";
  html += "<p><strong>Y-Axis:</strong> " + String(currentY, 1) + " mT</p>";
  html += "<p><strong>Z-Axis:</strong> " + String(currentZ, 1) + " mT</p>";
  html += "<p>Status: OK</p>";
  html += "</body></html>";
  server.send(200, "text/html", html);
}

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Initialize I2C and Sensor
  Wire.begin();
  if (!tmagSensor.begin(Wire, TMAG5273_I2C_ADDRESS_DEFAULT)) {
    Serial.println("Could not find a valid TMAG5273 sensor!");
  } else {
    tmagSensor.setAxis(TMAG5273_X_ENABLE | TMAG5273_Y_ENABLE | TMAG5273_Z_ENABLE);
    tmagSensor.setMeasurementMode(TMAG5273_STANDBY_MODE);
    currentX = tmagSensor.getXData();
    currentY = tmagSensor.getYData();
    currentZ = tmagSensor.getZData();
  }

  // Initialize E-Paper Display
  display.init(115200, true, 2, false);
  display.setRotation(1);
  drawDisplayData(currentX, currentY, currentZ);
  display.hibernate();

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  Serial.print("Connecting to Wi-Fi");
  unsigned long startAttemptTime = millis();
  
  // Wait up to 10 seconds for connection
  while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 10000) {
    delay(500);
    Serial.print(".");
  }

  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("\nConnected! IP Address: ");
    Serial.println(WiFi.localIP());

    server.on("/", handleRoot);
    server.begin();

    // Keep server active for 15 seconds to allow requests before sleeping
    unsigned long serverStartTime = millis();
    while (millis() - serverStartTime < 15000) {
      server.handleClient();
    }
  } else {
    Serial.println("\nWi-Fi connection failed. Skipping web server.");
  }

  // Enter Deep Sleep
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  Serial.println("Entering ESP32-C6 deep sleep...");
  Serial.flush();
  esp_deep_sleep_start();
}

void loop() {
  // Not used in deep sleep architecture
}

void drawDisplayData(float x, float y, float z) {
  display.setFullWindow();
  display.firstPage();
  do {
    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);
    display.setFont(&FreeSansBold9pt7b);
    
    display.setCursor(10, 25);
    display.print("SENSOR: TMAG5273");
    
    display.setCursor(10, 50);
    display.print("X: "); display.print(x, 1); display.print(" mT");
    
    display.setCursor(10, 75);
    display.print("Y: "); display.print(y, 1); display.print(" mT");
    
    display.setCursor(10, 100);
    display.print("Z: "); display.print(z, 1); display.print(" mT");

    display.setCursor(10, 125);
    display.print("STATUS: OK");
  } while (display.nextPage());
}

Generates , This Web page..
:grin:

  • Estimated Battery Life: Roughly 3 to 5 months (approx. 90 to 150 days) on a standard set of 3x AA alkaline batteries, assuming a 60-second wake/sleep cycle.

Why this duration?

  • Deep Sleep Power: The XIAO ESP32-C6 in deep sleep with the RTC running draws just a few microamps ($\approx 10\mu A$ to $15\mu A$).

  • Active Wi-Fi / Sensor Bursts: When waking up every minute, the ESP32-C6 connects to Wi-Fi, reads the I2C sensor, updates the SPI e-paper display, and runs the local web server for 15 seconds. This active window draws roughly 80mA to 120mA.

  • Display Quiescent Draw: E-paper displays draw zero power while maintaining the image during deep sleep, which massively extends life compared to an OLED or LCD.

  • Battery Capacity: Three standard AA alkaline batteries in series provide about 4.5V (stepped down cleanly to 3.3V via your buck converter) with roughly 2500mAh to 3000mAh of total capacity.

If you lengthen the sleep timer from 60 seconds to 5 or 15 minutes, you can easily stretch the battery life past a year.

this one: Tiny Matter-Native Board for Smart Home - XIAO ESP32C6

I took this info from this website: Getting Started with Seeed Studio XIAO ESP32C6 | Seeed Studio Wiki In the Pin Map section there is 3V3 pin descrobed as “power output”.

I use the 3V3 pin for input as well, ie supplying power to the XIAO. The buck/boost allows me to run the alkaline batteries to as low as 2V (Vin).

The 3V3 pin description as “power output” is easy to misread. I’d trust the schematic over the wiki wording before feeding power back in, especially since the regulator direction can matter depending on the board revision. Running alkalines down to 2V on Vin sounds workable, but the C6’s radio bursts may pull the rail down more than expected near end of life. Does the boost stay stable during Wi-Fi or Thread transmission, or do you see brownouts once the cells sag?

… I have confirmed that after 2025 the 3v3 which was bi-directional on units below ESP32 C3 is now output only… apparently they installed some hardware to prevent feeding… i disagree with the decision… but it is facts… I think if the unit has a battery ports on the bottom, this is the prefered power injection point. However realize the XIAO is expecting a LiPi battery on the other side of the pins… but do your own research

Mykexx, on the 3V3 pin question, I’d double-check the current schematic rather than relying on older docs, since I’ve seen conflicting notes about whether that pin is input-only on some revisions. The diode-drop concern is worth measuring: a Schottky plus buck/boost losses can eat into your 4xAA margin as the cells sag. Laura, Little Rock

I’m looking at the PCB and SCH from the Seeed Wiki and it looks like the 3V3 pin is just that - 3V3 to the ESP32. It would be nice for them to update the Wiki if changes have been made to the design!

Here’s my “evidence”.

If using a good buck/boost (I use the TPS63900), there shouldn’t be any issues when using WiFi, even when in boost mode. I did have to reduce my low voltage detector from 3V to 2.7V to cope with the “sag” during WiFi transmission. Alkaline does have current limitations so add some bulk capacitance.

FYI

The schematic evidence helps clarify the 3V3 pin question, though I would still verify against the latest revision before committing a board layout, since wiki pages often lag behind design changes. The LVD adjustment detail is useful: sag during WiFi bursts is easy to underestimate. On the bulk capacitance, what value range have you found sufficient alongside alkaline cells? I am also curious whether the TPS63900’s boost efficiency holds up as the cells approach end-of-life, since that is where the 4xAA margin really gets tested.

Perhaps @nickeyjoy can ensure the Wiki is updated?

The evidence I showed was from XIAO ESP32-C6 designs with a 2026-01-14 date.

A commercial enterprise like should ensure “breaking changes” like the 3V3 being modified to only supply power are updated immediately lest users waste their development time and money working from outdated information!

Just one of the many reasons I don’t use XIAO’s for new development.

Hi there,

Yes, that is Old News, Those of us that are more involved and less a peanut gallery knew this. Thanks for running it down to the actual message.
LOL, so many posts say it was NOT intended but folks persisted with obscure mods and diode configs and , a lot of look at what I can do, and it works
:man_facepalming:

any way , thanks.

GL :slight_smile: PJ :v:

The info is there if you look or even better Ask, no -spoon required. &
that’s why I DO use Xiao for New Development.

I still dont exactly understand what the problem was that needed to be fixed… but I just plug shit together like legos and then move them around in the air like an airplane and make the wvroom noise… apparently it doesnt effect the power users… but I am somewhat confued when they said there was no “standard” … I wa pretty sure the standard was well defined… It was a copy of the Adafruit Q-T-3.14159…

Hi there,

So , true , a lot of folks do not Know how it all evolved and therefore their personal journey began with Xiao. leads to a knowledge gap that only shows up in the deep water. LED blinking , etc. not as much… :grin:

GL :slight_smile: PJ :v:

pffft, just look at the bootloader history for a lesson…:+1:

.. it would be nice if seeed wrote a revision paper on it… as for me… I power my units with 3.7v LiPo charged thru the 5v USB.. I would love a XIAO power supply dfaughter board that includes battery management and solar sll wrapped up in a nice package (p my keyboard is full of potato chip fragments… because I am a fat bastard… and a windbag.. with on compressed air to show for it…)

Use four AA batteries with a buck-boost converter. Set its output to regulated 5V. Connect converter output through a Schottky diode. Then connect the diode to the ESP32’s VBUS. The 3.3V pin is a regulated output. Add 100µF and 100nF capacitors across VBUS and GND.