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.

Stuffy Meter Battery Edition running completely unplugged on its 18650 cell with the disconnected USB-C cable beside it

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):

Stuffy Meter Battery Edition two-mode bypass power path diagram: USB-C plugged in (direct bypass via D2 with Q5 OFF while BQ25170 charges the 18650) vs. USB-C unplugged (instant UPS handover via Q5 ON with D2 blocking reverse flow)

  • Plugged in = true bypass: VBUS holds P-MOSFET Q5 (AO3401A) completely OFF. The monitor runs straight off USB through Schottky diode D2 (B5819W) into VSYS, while U5 (BQ25170) charges the 18650 on its own isolated branch. Zero system current passes through the cell.
  • Clean auto-cutoff: Because U5 sees only true cell current, charging tapers to 40 mA at 4.10 V, shuts off completely, and turns the red D3 (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 VBUS drops to 0 V (cleanly, thanks to a tiny D4 diode we added after SPICE caught the ESP32-C3’s USB D+ pull-up leaking 1.8 V back onto VBUS). Q5 snaps 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 VSYS fed directly from D2, the board runs out of the box even with an empty battery holder or SW3 switched to OFF.

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:

  1. Smooth 400 mA CC/CV charge: Ramps cleanly up to 4.103 V (100%)—within 3 mV of the 4.10 V target.
  2. Dead-flat bypass plateau: Holds a ruler-flat 4.103 V while USB-C stays plugged in—zero trickle drift.
  3. Seamless unplug & multi-day discharge: Unplugging hands over to the 18650 with zero reboot. With 30-second screen auto-sleep enabled, a single Panasonic NCR18650GA ran ~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), tracking 1.44%/h (34.6%/d) over the continuous 21.9 h OLS window—projecting ~2.9 days (~69–70 hours) from a full charge:

Stuffy Meter 7-day Battery endurance chart showing the overnight CC/CV charge to a flat 4.103 V bypass plateau followed by ~34 hours of unplugged discharge to 45% (3.760 V) at 1.44%/h (~2.9 days projected)

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)

Top-down annotated photo of the Battery Edition actively charging over USB-C, highlighting TH1 (with 3x zoom beside the 18650 holder), U5 (BQ25170 charger), and the lit red D3 (CHG) LED

  • 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): A 10 kΩ NTC on TS pauses charging outside 0–45 °C. Flipping SW3 (BAT ON / OFF) to OFF pulls TS below 50 mV to disable the charger while Q4 disconnects the cell—zero battery current ever passes through the tiny slide switch. (Take a close look at where TH1 sits 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:

Full annotated Battery Edition safety map showing U9 (FS8205A) and U8 (DW01A) hardware protection on the left (with zoom inset), TH1 (NTC) in the center, and U5 (BQ25170) + D3 (CHG) on the right

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 / PCB before TH1 feels 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:

Battery Edition displaying uninitialized TV-static GRAM snow caused by CS-less SPI bit misalignment before the v2.4.5 fix

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:

Second Battery Edition display board with the 1.14-inch TFT detached and the torn FPC fingers still soldered to pads 1–13

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 mm window to mount the 0.7 mm solder-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 J2 even carried three extra pins (9–11) for a VSYS rail + discrete backlight driver, when the main board’s 2 A TPS63802 buck-boost already regulates +3V3 cleanly (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):

Stuffy Meter Home English multi-room dashboard showing headless Bedroom (Battery Edition v2.5.3 on USB with no cell), Living Room (USB Edition v2.5.1), and Child Room (Battery Edition v2.5.3 at 75% on battery) plus Room-to-Room Comparison charts

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): Move TH1 directly 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 MSP1141 module: First trial the 8-pin MSP1141 ST7789V module (solid PCB backing, FPC tucked behind the board, built-in 3.3 V backlight driver) directly on rev 4.1’s J2 pins 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—shrinking J2 from 1×11 to 1×8 (powered from +3V3, dropping the redundant VSYS rail) and revisiting right-side-up pin order plus hardware CS/RST if a GPIO frees up.