The Battery Drawer Problem

Every maker has one. That drawer. You know the drawer. It sits in the kitchen, or the garage, or the shadowy recesses of your workbench, and inside it lies a primordial soup of loose AA batteries — some fresh, some dead, some so old they have crusty white rings around the negative terminal that look like geological formations. You pick one up. Is it good? Is it bad? You hold it to your tongue like a heathen, get a tiny tingle, and decide it must be fine. Then you put it in your kid's toy, and the toy dies a slow, sad, bleeping death three hours later.

I decided to solve this problem. Badly. On purpose.

And so B.A.T.T.E.R.Y. was born — Basically A Toy That Embodies Rechargeable Yet-again-batteries. The name is deliberately clunky, intentionally over-punctuated, and almost impossible to say out loud without sounding like you've had a stroke. It is, in short, the perfect name for a project whose entire reason for existing is a single, dumb, beautiful pun.

How It Works

The measurement is conceptually simple. A fresh AA alkaline battery sits at around 1.5–1.6 V. A dead one reads around 1.0 V or lower. The ESP32's ADC reads 0–3.3 V at 12-bit resolution, so a 1.5 V signal lands comfortably in range — no voltage divider needed. The AA's positive terminal goes directly to GPIO 34, the negative terminal to GND.
The hard part is the ADC itself. The ESP32's ADC is notoriously noisy and non-linear, especially at the top of its range. A fresh 1.5 V battery can read as 1.65 V or 1.7 V on a bare ADC read — making it look overcharged, which is obviously wrong. B.A.T.T.E.R.Y. solves this with four stacked techniques:
  1. eFuse calibration — Reads the factory-burned Vref on your specific ESP32 chip via esp_adc_cal. Each chip is individually calibrated at the factory; using that data is non-negotiable for accurate readings.
  2. 32× oversampling with min/max rejection — Takes 32 ADC readings, throws out the highest and lowest, averages the remaining 30. Kills transient spikes from the sample-and-hold capacitor charging off low-ESR fresh cells.
  3. 10-sample moving average — On top of the batched reads, smooths the output so the display doesn't jitter.
  4. 0.1 µF ceramic capacitor on GPIO 34 — The hardware fix. Sits physically close to the ESP32 and absorbs sampling spikes before they reach the ADC. Without it, fresh batteries still read wrong even with all the software fixes above(learnt it the wrong way ;) ).

The 0.1 µF cap is the most overlooked piece. It's also the cheapest. Solder it anyway.

The Display Pipeline

Voltage is mapped to a percentage (1.0 V = 0%, 1.6 V = 100%, linear interpolation between) and a status enum:

Voltage range              Status
< 0.2 V                  No Battery
0.2 V – 1.05 V           Replace
1.05 V – 1.35 V          Low Worried
1.35 V – 1.6 V+          Good Happy

 

The Critical Wiring Rule

The single most important sentence in this entire project: the internal 9 V system battery, the external AA being tested, and the ESP32 itself must all share a common ground. Voltage is always a difference between two points. If the AA's negative terminal isn't tied to the ESP32's ground, the reading will be garbage — either wildly fluctuating, stuck at zero, or floating up to a random voltage that means absolutely nothing. Every ground in this project meets at the ESP32's GND pin.

The Enclosure — Cardboard Is Correct

You can absolutely 3D-print a slick enclosure for this project. People have. People will. But I'm here to argue that cardboard is the correct material, both aesthetically and philosophically.

The project is a joke — a battery shaped battery tester. If you build it in a sleek black anodized aluminum case, the joke dies. It becomes a Tool. A Product. A Serious Object. But if you build it in a hand-cut cardboard shell wrapped in mismatched colored paper, with a wonky window cut out for the OLED and the AA holder hot-glued to the front like a growth, the joke lands. It looks like a child's drawing of a robot that came to life and started judging you. That is the energy I are going for.