How your ESP32 reads a 12V battery: the voltage divider
Two resistors scale a 12V battery down to a voltage an ESP32's 3.3V input can read safely, with a zener as a backstop.

Free build sheet
The parts, every wire with its length and bend points, a bend guide, both sides of the board and checkboxes to track your progress. Print it or keep it open at the bench.
Open the build sheetWhat you need
6 parts on a perfboard 16 × 28 holes, plus hookup wire.
| Qty | Part | Where to buy |
|---|---|---|
| 1 | Ceramic Cap100nF C1 | Buy Ceramic Cap on Amazon |
| 1 | Diode (axial) D1 | |
| 1 | Power Input (2-pin) J1 | |
| 1 | Signal+Power Header (3-pin) J2 | |
| 1 | Resistor (axial)39k R1 | Buy Resistor (axial) on Amazon |
| 1 | Resistor (axial)10k R2 | Buy Resistor (axial) on Amazon |
Check every pin against the datasheet of the exact part in your hands before wiring.
As an Amazon Associate I earn from qualifying purchases.
Cut list
9 wires, 217 mm (8.5 in) in total, in the order the build sheet cuts them. Wire numbers match the build sheet. Each length includes 5 mm per end to go through the hole.
| Wire | Colour and net | Length | ||
|---|---|---|---|---|
| 6 | BlackGND E21 → G23 | E21 → G23 | 17mm | Straight |
| 5 | BlueTAP M21 → H23 | M21 → H23 | 28mm | 18mm (90°) |
| 4 | GreenTAP K13 → L20 | K13 → L20 | 30mm | 23mm (90°) |
| 1 | Red12V E7 → E5 | E7 → E5 | 15mm | Straight |
| 7 | RedGND F20 → J15 | F20 → J15 | 33mm | 18mm (90°) |
| 3 | WhiteTAP F12 → J12 | F12 → J12 | 20mm | Straight |
| 9 | WhiteGND I14 → F5 | I14 → F5 | 40mm | 28mm (90°) |
| 2 | YellowTAP E13 → E15 | E13 → E15 | 15mm | Straight |
| 8 | YellowGND K14 → L16 | K14 → L16 | 18mm | 10mm (90°) |
About this build
A 12V battery is nearly four times what a 3.3V ADC input can survive, so two resistors scale it down: 39k on top, 10k underneath. The tap between them sits at 2.45V, and even with a lead acid pack charging at 14.4V it only reaches 2.94V.
The math is Vout = Vin x 10k / (39k + 10k). A 100nF ceramic on the tap filters the reading, and a 1N4728A 3.3V zener clamps it, so a spike can't push the tap past what the input can take. The tap and ground leave on a 3 pin header.
The zener only works one way round. The build sheet shows which end goes to the tap, and the band on the part tells you which end is which.
More builds
See all builds
VideoThe whole weather station is three parts
A XIAO ESP32C3 reads a temperature and humidity sensor and shows the reading as a colour on an RGB LED.
9 parts · 14 wires
Sensors
VideoThe Clapper, recreated: lights that turn on when you clap
Clap once and an LED turns on, clap again and it turns off. A microphone, two transistors and one flip-flop chip.
14 parts · 24 wires
SensorsLights
VideoThis LED tells you how dead your battery is
A light for a 12V lead acid battery: green when it's healthy, yellow when it's getting low, red when it's nearly flat.
13 parts · 17 wires
PowerTools and test