Ambien: An ESP32 CO2 Sensor With E-Paper That Runs a Year on Two 18650s
TL;DR: Ambien is an open source ESP32 CO2, temperature and humidity sensor with a 4.2 inch e-paper display that runs up to a year on two 18650 cells. It publishes one JSON message over MQTT with Home Assistant auto discovery, works fully offline, and stays silent for RF quiet shacks. Hardware tour, battery math and shack workflows inside.
What Ambien Is
Ambien is an open source ESP32 based CO2, temperature and humidity sensor with a 4.2 inch e-paper display that wakes, measures, refreshes the screen and returns to deep sleep, stretching two 18650 cells to about a year of operation.
It is the work of mcer12, published under GPL-3.0 and declared done, with firmware, EasyEDA PCB sources and gerbers, 3D printable enclosure files and even unit tests in one repo. A Sensirion SCD4x measures CO2 while an SHT30 covers temperature and humidity. Every wakeup publishes one JSON message over MQTT with native Home Assistant discovery, and a mobile friendly captive portal handles setup with a theme switch. Skip Wi-Fi entirely and it still works as a silent offline display. The pixel style interface uses the author PixelFonts project for a retro paper look that suits e-paper perfectly.

Why a Shelf Sensor Belongs in a Ham Shack
Shacks are small rooms full of warm bodies, hot radios and closed doors. A two person contest station overnight easily pushes CO2 past 1,000 ppm, the point where drowsiness and dull thinking set in, exactly when you need sharp ears for weak signals. Most operators blame fatigue. Some of it is chemistry, and a 50 dollar sensor answers the question objectively.
E-paper brings a second shack advantage that rarely gets mentioned. Unlike TFTs with PWM backlights and buzzing boost converters, an e-paper display draws nothing at rest and emits nothing while you read it. No switching noise near HF receivers, no glow wrecking night vision during meteor scatter sessions, no fan, no hum. It's the most RF polite display technology available, and this project exploits that fully.
The third reason is architectural. Ambien is a masterclass in duty cycling an ESP32, the same chip family running fox hunt beacons, DX cluster clients and LoRa trackers across this site. Its sleep discipline, Wi-Fi on for seconds, sensors in low power modes, everything else dark, is directly reusable in field nodes that must survive weekends on small cells.
Hardware Tour: Overkill MCU, Frugal Everything Else
ESP32 Because Spares Existed
The author admits the ESP32 is massive overkill and used one because spares sat in the drawer. Honest engineering beats optimal engineering when the alternative is a three week parts order. The chip spends nearly its whole life in deep sleep anyway, so the overkill costs nothing in battery terms and buys USB native upload, ample RAM for the display buffer and Wi-Fi when needed.
E-Paper Display, 4.2 Inch, 400 by 300
The screen is a 4.2 inch 400 by 300 black and white e-paper panel, HINK-E042A13-A0 or equivalents with the centered flex cable. That resolution fits big readable digits across a room, and the bistable nature means the last reading stays visible for months with zero power. Power fails during a storm and the shack whiteboard still shows the last CO2 value. Try that with an LCD.
Sensirion SCD4x Plus SHT30
CO2 comes from the Sensirion SCD4x photoacoustic sensor family, temperature and humidity from the SHT30. Both are the same parts serious commercial monitors use, not the drift prone eCO2 estimation chips that guess CO2 from VOCs. The firmware offers forced recalibration to 430 ppm from the web interface, which you trigger with the unit breathing fresh outdoor air. The CO2 sensor is optional in software. Disable it and the layout switches to a big temperature plus humidity face while battery life multiplies.
Power: Two 18650s, TP4057, Optional Protection
Two 18650 slots plus a TP4057 charger and USB-C cover the power story, with an optional FS312F-G protection chip at a higher cutoff to protect cell health. Prefer a flat pack? Omit the slots and protection and wire a LiPo instead. The headline numbers fall straight out of the duty cycle. About a year with CO2 sensing, multiple years on temperature and humidity alone.

Battery Math Worth Stealing
Two quality 18650s hold roughly 7,000 mAh combined. Spread over 8,760 hours in a year, the average budget is about 800 microamps. The ESP32 in deep sleep sips single digit microamps, the e-paper needs power only during its few second refresh, and Wi-Fi transmits for seconds per wakeup. The SCD4x in low power mode dominates the budget, which is exactly why disabling CO2 multiplies life into multiple years.
Any builder of battery field nodes should memorize this shape. Capacity divided by hours gives the average current, and every subsystem must fit under it. Ambien publishes the answer in working hardware rather than spreadsheet theory.
Software Tour: One JSON Message and a Portal
MQTT in a Single Publish
Each wakeup sends one non retained message to <topic>/state, default topic ambien/ambien_xxxx, shaped like this:
{"temperature":23.5,"humidity":45,"co2":812,"battery":4.05}
One message, four fields, no chatty protocol. Battery voltage rides along every time, so Home Assistant can graph cell decline across seasons and warn before winter kills a weak cell.
Home Assistant Discovery With One Checkbox
Tick Register in Home Assistant and the next wakeup publishes a retained discovery config to homeassistant/device/ambien_xxxx/config. Entities appear automatically with the device grouped correctly. The checkbox then unticks itself, a small UX touch that prevents duplicate registrations. Readers building the rest of the smart shack should start with the companion Home Assistant hardware and installation guide.
Captive Portal and Offline Mode
First boot with no Wi-Fi starts an Ambien_XXXX access point serving a mobile friendly setup page at 192.168.0.1, with light and dark themes. Enter Wi-Fi, wake interval and MQTT details, save and reboot. Later changes come from the AP MODE or LOCAL SERVER buttons on the device. The OFFLINE MODE button on the first run screen skips networking entirely for a pure display that never transmits, ideal for exam halls, bedrooms and anyone who simply dislikes another Wi-Fi client.

Build and Setup Path
The project uses PlatformIO with libraries fetched automatically, so firmware is one command:
pio run -t upload
MQTT payload unit tests run on the PC with pio test -e native, or on hardware with pio test -e esp32dev connected. PCB sources live in EasyEDA format with gerbers included, and the enclosure ships as three 3MF files for top, bottom and holder. Setup follows the access point flow above, then one forced 430 ppm calibration outdoors before trusting absolute CO2 numbers.
Ambien Versus Commercial CO2 Monitors
| Item | Ambien | Typical e-ink commercial monitor | Always on Wi-Fi monitor |
|---|---|---|---|
| Sensors | SCD4x true CO2 plus SHT30 temp and humidity | True CO2 plus temp and humidity | True CO2 plus temp, humidity, sometimes VOC and PM |
| Display | 4.2 inch e-paper, room readable | Small e-ink, room readable | Small color LCD, needs power |
| Battery | 2×18650, about a year with CO2 | Coin or AA cells, one to two years | USB powered, no battery operation |
| Smart home | MQTT plus Home Assistant discovery | Vendor app and cloud, sometimes Matter | Vendor app plus Matter or HA |
| Offline use | Full display only mode | Full display only mode | Dead without power and Wi-Fi |
| Data path | Your MQTT broker, nothing leaves home | Vendor cloud account usually required | Vendor cloud account usually required |
| Openness | GPL-3.0, PCB, enclosure, tests | Closed | Mostly closed |
| Cost shape | Parts plus an evening | Mid range retail | Budget to mid range retail |
| Best for | Hams and makers who own their data | Bedrooms and classrooms wanting zero setup | Desks already full of USB chargers |
Shack Workflows That Earn the Shelf Space
Park one at eye level behind the operating position. Glance up between overs. CO2 climbing toward four digits means open the door or crack a window before the next hour, not after the headache. Log weekend contest CO2 alongside scores for a season and the ventilation lesson writes itself.
Pair readings with automation. Home Assistant can boost a USB fan, flash the shack lamp or send a phone alert when CO2 crosses your threshold. Battery voltage in every message means the sensor joins the same low battery watch as your handhelds.
Take it portable. Field Day tents, exam sessions and club meetings all concentrate people in still air. Offline mode keeps it silent and emission free, and the year long battery means it lives in the go box without a charging rota.
Honest Limits
Sixty five stars means a young community, so expect to answer your own questions from the source. The e-paper refreshes in seconds, useless for real time graphs. The 4.2 inch panel and dual 18650s make a chunky shelf object, not a pocket meter. Forced calibration demands genuine fresh air, and calibrating beside a running generator invents accuracy problems. The project is declared done rather than actively developed, which is a feature for stability and a risk if Espressif breaks an API under it.
Sources and Further Reading
- Ambien project repo, firmware, PCB and enclosure: https://github.com/mcer12/Ambien-ESP32
- PCB sources, schematic and gerbers: https://github.com/mcer12/Ambien-ESP32/tree/main/pcb
- 3D printable enclosure models: https://github.com/mcer12/Ambien-ESP32/tree/main/enclosure
- PixelFonts retro font project: https://github.com/mcer12/PixelFonts
- Home Assistant MQTT integration docs: https://www.home-assistant.io/integrations/mqtt/
- Home Assistant hardware and installation guide: https://hamradio.my/home-assistant-best-hardware-installation-guide/
73 de 9M2PJU



Post Comment