Projects / AAA battery life gauge

AAA battery life gauge

Beginner1.3 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO15.6 mASSD1306

    Install the libraries

    SSD1306 and GFX.

  2. NANO

    Build the divider

    Two 10 kohm resistors, middle point to A0.

  3. NANO

    Connect the cells

    Plus end to the divider, minus end to GND.

  4. NANO

    Add the load

    220 ohm across the cells.

  5. NANO

    Wire the display

    A4 and A5 with power.

  6. NANO

    Upload the sketch

    A voltage and a bar appear.

  7. NANO

    Log for an hour

    Copy the serial output into a spreadsheet.

  8. NANO

    Plot the curve

    Note how the voltage falls slowly then faster.

In short

How do you build an AAA battery life gauge?

Two AAA cells are loaded with a small resistor while a board reads their voltage and shows a rough charge bar, to learn how battery voltage drops. You need Arduino Nano, AAA alkaline battery × 2, Resistor 10 kΩ × 2, Resistor 220 Ω, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 8 steps and about 75 minutes.

Level
Beginner
Time
About 75 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Two AAA cells in series, plus endDivider topHold with a 2-cell holder or tape and clips
Two AAA cells in series, minus endNano GNDCommon ground
Divider: 10 kohm from the plus endNano A0Top resistor
Divider: 10 kohm from A0Nano GNDBottom resistor
220 ohm load resistorPlus end to minus endDraws about 14 mA from fresh cells
OLED VCCNano 5VThe Nano is powered by USB
OLED GNDNano GNDCommon ground
OLED SDA and SCLNano A4 and A5I2C bus

Code

A battery does not give a steady voltage as it empties. A fresh alkaline cell starts a little above 1.5 volts and slowly falls to about 1.0 volt when it is nearly flat, and the voltage also sags more when a bigger load is connected. This build measures the voltage of two AAA cells in series with the Nano, which stays powered from USB. The two equal 10 kilohm resistors divide the battery voltage by two so it fits inside the range of the 1.1 volt internal reference, which gives about a hundredth of a volt per step. A 220 ohm resistor across the cells is a small steady load of about 14 milliamps, so the voltage drops as in real use, and the sketch logs the time and the voltage over the serial port every five seconds so you can plot a discharge curve in a spreadsheet. Do not use rechargeable or lithium cells with this circuit without changing the limits, and never connect the cells to the Nano 5V pin. The bar is only a rough guide: alkaline cells hold their voltage for a long time and then fall quickly at the end.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const float REF_V = 1.1;            // internal reference
const float DIVIDER = 2.0;          // two equal resistors
const float FULL_V = 3.2;           // two fresh cells with a light load
const float EMPTY_V = 2.0;          // about 1.0 V per cell, treat as empty
unsigned long startMs;

float readVolts() {
  long sum = 0;
  for (int i = 0; i < 32; i++) { sum += analogRead(A0); delay(2); }
  return (sum / 32.0) * REF_V / 1023.0 * DIVIDER;
}

void setup() {
  Serial.begin(9600);
  analogReference(INTERNAL);
  delay(50);
  analogRead(A0);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println("OLED not found"); while (1) { } }
  oled.setTextColor(SSD1306_WHITE);
  startMs = millis();
}

void loop() {
  float v = readVolts();
  float frac = (v - EMPTY_V) / (FULL_V - EMPTY_V);
  if (frac < 0) frac = 0;
  if (frac > 1) frac = 1;

  oled.clearDisplay();
  oled.setTextSize(2);
  oled.setCursor(0, 0);
  oled.print(v, 2); oled.print(" V");
  oled.drawRect(0, 28, 100, 14, SSD1306_WHITE);
  oled.fillRect(2, 30, (int)(96 * frac), 10, SSD1306_WHITE);
  oled.setTextSize(1);
  oled.setCursor(0, 50);
  oled.print("Minutes: "); oled.print((millis() - startMs) / 60000UL);
  oled.display();

  Serial.print((millis() - startMs) / 1000); Serial.print(","); Serial.println(v, 3);
  delay(5000);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

0,1.101
5,1.101

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Fresh cellsAbout 3.0 to 3.2 V, full bar
After an hourSlightly lower voltage
Cells disconnectedReading near zero
Load removedVoltage rises a little
Half-used cellsAbout 2.6 to 2.8 V

If it does not work

Reads zero

Check the divider middle point and the A0 wire.

Reads half the real voltage

The divider factor is wrong, check both resistors are 10 kohm.

Reading jumps

Poor contact at the battery clips.

Bar always full

Raise FULL_V and EMPTY_V to match your cells.

Nano resets

The cells are connected to the 5V pin by mistake, remove them at once.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the AAA battery life gauge?

Arduino Nano, AAA alkaline battery × 2, Resistor 10 kΩ × 2, Resistor 220 Ω, SSD1306 OLED Display and Breadboard 830 Tie Points.

How long does the AAA battery life gauge take to build?

About 75 minutes for a beginner maker, in 8 steps.

How do I know the AAA battery life gauge works?

Fresh cells: About 3.0 to 3.2 V, full bar. After an hour: Slightly lower voltage. Cells disconnected: Reading near zero.

Reads zero: what should I check?

Check the divider middle point and the A0 wire.

Reads half the real voltage: what should I check?

The divider factor is wrong, check both resistors are 10 kohm.

Reading jumps: what should I check?

Poor contact at the battery clips.

Bar always full: what should I check?

Raise FULL_V and EMPTY_V to match your cells.