ESPHome Air Quality Sensor System (SEN6x)
Table of Contents
A simple CO2 sensor is often not enough for precise monitoring of indoor air quality. In this project I show the construction of a fully dynamic air quality monitor based on ESPHome. The special feature: The system can be completely configured at runtime via a web interface without re-flashing and solves the specific hardware challenges of professional sensors.
Die Hardware-Basis
The system relies on high-quality and compact components:
-
Microcontroller: An ESP32-C3-DevKitM-1 provides sufficient power for the display and ensures a stable WLAN connection.
-
Sensory: The Sensirion SEN66 (compatible with SEN6x/SEN5x) is an all-in-one sensor for measuring CO2, particulate matter (PM1.0, PM2.5, PM4.0, PM10), volatile organic compounds (VOC), nitrogen oxides (NOx), as well as temperature and humidity.
-
Display: A round 1.28 inch LCD with GC9A01 Controller, controlled via SPI.
I also designed a suitable housing for the project that ensures optimal airflow for the sensor and accommodates all components compactly.
Software features and technical highlights
The firmware is based on ESPHome and uses the LVGL library for the graphical interface. The focus during development was on maximum flexibility and physical accuracy.
1. Fully dynamic UI & headless operation
The device is designed as a true standalone system. It doesn't necessarily require a cloud or even an active Home Assistant instance. Thanks to the integrated ESPHome web server, the device can be operated headless via any browser in the local network. All assignments (which measured value is displayed on which display slot), colors, theme settings (dark/light mode) and refresh rates can be changed live in the web UI. The display adjusts in real time.
2. Specific Sensirion gas engine logic
Gas sensors for CO2, VOC and NOx require a continuous warm-up period to calculate correct baselines. Simply restarting the query timer would hard reset the sensor and distort the measured values. The firmware therefore uses decoupled query logic: The sensor runs internally in continuous operation at a 24-hour interval, while a separate, customizable script retrieves the data gently and asynchronously at the desired interval (e.g. every 30 seconds) via the I2C bus.
3. Dynamic moisture compensation (Magnus formula)
Compact housings generate waste heat, which requires a temperature offset in the software. However, the relative humidity is physically directly dependent on the temperature. If only the temperature is calibrated, the accuracy of the displayed humidity decreases. The firmware therefore calculates via the Magnus-Tetens-Formula the current saturation vapor pressure and corrects the relative humidity to match the set temperature offset. This means that the displayed measured values remain physically consistent.
4. Individual alarm limits
In order to be able to assess the air quality at a glance, 21 individual limit values (three levels each for seven sensors) were implemented. If a value exceeds the defined limit, the corresponding sheet or text on the display automatically turns into the desired warning color (e.g. yellow, orange or red). These threshold values and colors can also be easily set via the user interface.
Resources & Download
The project is completely open source. I make the complete ESPHome code (YAML) and the 3D model for the housing available on GitHub and Thingiverse:
-
Firmware / source code: Click here for the GitHub repository
-
3D printing housing (STL/STEP): Click here for the Thingiverse project
-
Driver: The excellent SEN6x driver from the repository is used as a custom component tuct/esphome-projects used.
AGML battery charger









Hi, in picture #3 there is what looks like a gray foam insert where the sensor is placed in the housing. Does that come with the sensor? Looks like it was cut with a machine. If not, where did you get that?
Hi, this is correct it is cut from EVA foam with a laser. The sensor does not come with it. I uploaded the shape on thingiverse.com (hopefully). These came from sensirion from the sensors fact page.
Best regards
You got an awesome project here and I’m trying to do it myself. I found your thingiverse page (the link in the article points to github instead), but cannot find the cutout for the foam. It’s the missing piece for me, if you could upload that,I’d really appreciate it. How thick was the foam you used to fit it well to the case? I assume you’re located in Germany. I’m in Switzerland. Any recommendations on EVA cutting? I’ve never done that before.
Modifications I’m planning to do to your design: I’ll upgrade to ESP32-C6 (about 3mm longer) and will try to add an ambient light sensor to control the screen. I understand you have hard-coded that (or are controlling it through HA)?
Also happy if you send me the details via email.
Display brightness and Day/Night mode are available in HA for manipulation. Nothing is hardcoded. I use the sun modifier for decision to alter brightness. It’s all in the ESPHome code.
EVA is 2 or 3 mm from a multiple color sheet pack, nothing special. I cut this on a cheap 5W UV-laser at “medium” power/speed.
I found the foam STEP file on the sensiron page, see link below.
I tried to manhandle it but got bun all over it.
What happened?
Hello iam interested in building the same project can you please ask for more details?
Cause i dont know how to program arduino.
Thx
Can you send me the diagram of the cables? how to connect?