Adding a battery to a 24/7 desktop air-quality monitor sounds simple—until you think about how it actually gets used. Most days Stuffy Meter sits plugged into USB-C; only occasionally do you unplug it to carry into another room or ride out a power cut.
That usage pattern makes naive battery wiring a trap. Hang an ESP32 and CO₂ sensor directly across a basic charger + battery node, and the ~100 mA system load tricks the charger into never terminating—quietly float-charging the lithium cell at full voltage 24/7.
Now that the JLCPCB-assembled Battery Edition boards (rev 4.1) are running cord-free on my desk (tucked into a snap-fit 3D-printed case), this post focuses on the parts that mattered most: how we built true bypass charging and two-layer 18650 safety, and three physical-world surprises that slipped past every automated check once real boards—and an EE friend—got involved.

Bypass charging: why USB power never touches the battery
Instead of sharing one node between the charger, battery, and MCU, Stuffy Meter separates USB and battery power with a MOSFET power path (D2 + Q5 → VSYS):

- Plugged in = true bypass:
VBUSholds P-MOSFETQ5(AO3401A) completely OFF. The monitor runs straight off USB through Schottky diodeD2(B5819W) intoVSYS, whileU5(BQ25170) charges the 18650 on its own isolated branch. Zero system current passes through the cell. - Clean auto-cutoff: Because
U5sees only true cell current, charging tapers to 40 mA at 4.10 V, shuts off completely, and turns the redD3(CHG) LED off. The cell rests disconnected until self-discharge ever dips below 4.00 V—so leaving it plugged in for months won’t cook it. - Seamless UPS handover: Unplug USB-C and
VBUSdrops to 0 V (cleanly, thanks to a tinyD4diode we added after SPICE caught the ESP32-C3’s USB D+ pull-up leaking 1.8 V back ontoVBUS).Q5snaps ON in microseconds with zero reboot; firmware switches the SCD41 to 30-second low-power sampling and sleeps the TFT after 30 seconds (bat_screen_off, now enabled by default—tap MODE to wake for 30 s). - Works with no cell at all: With
VSYSfed directly fromD2, the board runs out of the box even with an empty battery holder orSW3switched toOFF.
Real-hardware proof: 4.103 V bypass plateau & ~2.9-day runtime
To measure real battery behavior without taping a multimeter to my desk, firmware v2.5.0 logs cell voltage and power state right alongside CO₂ history in on-board flash—flushing cleanly before the 3.30 V deep-sleep cutoff.
One multi-day 7d trace from the built-in Battery endurance card confirms the entire power-path lifecycle on real silicon:
- Smooth 400 mA CC/CV charge: Ramps cleanly up to 4.103 V (100%)—within 3 mV of the
4.10 Vtarget. - Dead-flat bypass plateau: Holds a ruler-flat 4.103 V while USB-C stays plugged in—zero trickle drift.
- Seamless unplug & multi-day discharge: Unplugging hands over to the 18650 with zero reboot. With 30-second screen auto-sleep enabled, a single Panasonic
NCR18650GAran ~34 hours unplugged across two days (4.090 V / 99% → 3.760 V / 45%, with only a brief USB plug-in mid-test for a firmware update), tracking1.44%/h(34.6%/d) over the continuous21.9 hOLS window—projecting ~2.9 days (~69–70 hours) from a full charge:

Two independent layers of 18650 safety on the PCB
I chose a user-replaceable, flat-top unprotected 18650 (2500–3500 mAh, ~65 mm) over a glued-in LiPo pouch so anyone can source a cell locally, replace it years later, and avoid shipping lithium batteries. Because bare cells have no built-in protection board—and 18650 holders aren’t keyed—the PCB carries two independent safety layers.
Layer 1: Everyday smart charging (U5 BQ25170 + TH1 NTC + D3 CHG)

- Gentle 400 mA CC/CV capped at 4.10 V: Stopping at 4.10 V instead of 4.20 V trades ~10% capacity for dramatically longer calendar life on a mostly-plugged-in desk monitor. Even
VSET(36 kΩ) is intentionally a single resistor so an open or short fault disables charging instead of over-volting the cell. - 10-hour safety timer: Cuts off charging automatically if an aging cell never tapers down to the 40 mA cutoff.
- Temperature window (
TH1) & zero-current switch (SW3): A10 kΩNTC onTSpauses charging outside0–45 °C. FlippingSW3(BAT ON / OFF) toOFFpullsTSbelow 50 mV to disable the charger whileQ4disconnects the cell—zero battery current ever passes through the tiny slide switch. (Take a close look at whereTH1sits in that 3× zoom—it comes back to bite us below.)
Layer 2: Independent hardware backstop (U8 DW01A + U9 FS8205A + F2 + Q2/Q3)
Even if U5 ever failed dead-shorted, a completely independent protection stage on the left side of the board watches the 18650 directly:

Think of U8 (DW01A) + U9 (FS8205A) as a 3 µA referee + two back-to-back electronic gates between the cell’s negative terminal and GND—one Charge Gate (OC) and one Discharge Gate (OD). Normally both stay open; on an extreme fault, DW01A shuts only the dangerous direction:
| Extreme fault | Threshold | DW01A → FS8205A |
Result |
|---|---|---|---|
| Overcharge | > ~4.30 V |
Closes Charge Gate (OC) |
Blocks charging, still allows safe discharge |
| Over-discharge | < ~2.50 V |
Closes Discharge Gate (OD) |
Protects cell, still allows USB recharge (firmware already deep-sleeps at 3.30 V) |
| Overcurrent / short | > ~3 A (7 ms) or short (400 µs) |
Slams Discharge Gate (OD) shut |
Cuts B- in milliseconds—backed by F2 (2 A / 100 A-fault PTC fuse) |
Add Q2 + Q3 (reverse-polarity P-FETs), and inserting a cell backwards simply leaves it disconnected with no smoke.
Why put protection on the PCB instead of buying “protected 18650” cells?
Off-the-shelf “protected 18650” cells literally weld a tiny disc carrying the exact same DW01A + 8205A pair onto the bottom of a bare cell—making it too long for standard 65 mm holders while still missing charge regulation, bypass power path, temperature sensing, and reverse-polarity protection:
| Feature | “Protected 18650” cell | Stuffy Meter Battery PCB |
|---|---|---|
Extreme cutoff (DW01A + FS8205A) |
Yes (+3–5 mm length) | Built-in (U8 + U9 + F2 PTC) |
4.10 V CC/CV charging (BQ25170) |
No | Built-in (U5 + D3 + 10 h timer) |
Bypass power path (D2 + Q5) |
No | Built-in (clean cutoff, zero trickle wear) |
NTC temperature cutoff (0–45 °C) |
Usually no | Built-in (TH1, moving under cell in rev 4.2) |
| Reverse-polarity protection | No | Built-in (Q2 + Q3) |
What the AI got wrong: three bugs real hardware (and an EE friend) caught
Just like in Hardware as Code, rev 4.1 was built and verified as code: a 94 × 56 mm main board plus an upright 54 × 25 mm display daughterboard on one 99 × 97 mm JLCPCB panel (47 BOM lines, 84 parts), zero ERC/DRC violations, passing SPICE simulations, and a GO from an independent AI reviewer.
Then physical boards landed on my desk—and three real-world blind spots showed up immediately.
1. The EE friend’s 2-minute catch: an NTC behind a plastic wall
In 2D KiCad coordinates, TH1 sat millimeters from the battery. When I asked a friend with an EE background to review the board, he caught the flaw in two minutes: TH1 is mounted on the PCB outside the plastic wall of the 18650 holder (BT1).
- High thermal lag: Cell heat has to cross
cell wrapper → air → plastic holder wall → air / PCBbeforeTH1feels it, while the PCB ground pour sinks heat away from its pads. - What it really tracks on rev 4.1: Ambient air temperature inside the battery bay—still valid for blocking freezing (
< 0 °C) or hot-room (> 45 °C) charging, just too slow to catch an abnormally self-heating cell body.
Rev 4.1 still has wide safety margins (~0.12 C slow 400 mA charge, 4.10 V cap, 10 h timer, DW01A, and the cell’s internal CID/PTC), so it’s safe to use—but fixing the thermal path is at the top of the rev 4.2 list below.
2. Stealing display pins caused TV-static GRAM snow (v2.4.5)
Freeing GPIO4 (VBAT_SENSE) and GPIO10 (VBUS_DET) on the pin-tight ESP32-C3 meant hard-wiring the upright TFT’s CS low and tying RST to EN. On real silicon, software reboots reset SPI2, glitched GPIO6 (LCD_SCK), shifted the ST7789’s SPI bit counter, and lit up TV-static snow:

Even worse, our shifted init bytes accidentally matched ST7789 read opcodes (RDDID, RDDST, RAMRD_CONT), tricking recovery into turning on uninitialized GRAM. Firmware v2.4.5 squashed it permanently: probe alignment via D/C=1 + RDDPM (0x0A) readback before init, clear GRAM to black before DISPON, retry fail-closed at 10 MHz SPI, and park GPIO6 high before every esp_restart().
3. One display flex cable tore off—and exposed an over-engineered daughterboard
On Board #2, the 1.14” TFT felt loose out of the box and popped off at a light touch while depaneling:

I blamed cold solder joints—until JLCPCB support shared pre-shipment photos showing all 13 joints held and the flex ribbon itself sheared along the solder fillet because the panel wasn’t taped down. JLCPCB refunded USD 15 within minutes, and that tear made a deeper flaw obvious: the custom display daughterboard itself wasn’t worth keeping.
- Fragile & pricey mounting: Milling a
26.1 × 15.9 mmwindow to mount the0.7 mmsolder-type FPC (N114-2413THBIG01-H13) face-down left the glass resting on 0.22–0.67 mm strips, weakened the board during depaneling, added JLCPCB hand-soldering and “Different Design: 2” panelization fees, and made broken screens non-repairable. - Redundant backlight rail: Header
J2even carried three extra pins (9–11) for aVSYSrail + discrete backlight driver, when the main board’s 2 ATPS63802buck-boost already regulates+3V3cleanly (giving uniform brightness on USB and battery).
The immediate silver lining for Board #2: because the firmware treats the display as optional—and the bypass power path runs cleanly with an empty battery holder—it flashed over USB-C and joined Stuffy Meter Home completely headless as Bedroom (Battery Edition · v2.5.3 · USB no cell), logging beside Living Room (USB Edition · v2.5.1) and Child Room (Battery Edition · v2.5.3 · 75% on battery):

Next steps: Battery rev 4.2
AI agents, SPICE, and DRC got a software engineer 90% of the way to a safe, bypass-powered battery PCB—catching electrical-graph bugs like USB VBUS back-feed before a single board was fabbed. Real hardware and a two-minute human EE review closed the last 10%, giving us a clear checklist for the next revision:
- Direct cell-to-NTC thermal coupling (
TH1): MoveTH1directly under the center of the 18650 (via a bottom-windowed holder or split clips), carve a copper thermal-relief keep-out around its pads, and bridge the gap with a dry, soft silicone thermal pad (~5×5 mm, non-conductive) so inserting a cell makes direct thermal contact. - Drop the custom display board for an off-the-shelf
MSP1141module: First trial the 8-pinMSP1141ST7789V module (solid PCB backing, FPC tucked behind the board, built-in3.3 Vbacklight driver) directly onrev 4.1’sJ2pins 1–8 rotated 180° with Display flip enabled in the Web UI. Once verified, rev 4.2 deletes the custom display daughterboard and panelization completely—shrinkingJ2from1×11to1×8(powered from+3V3, dropping the redundantVSYSrail) and revisiting right-side-up pin order plus hardwareCS/RSTif a GPIO frees up.