AirCube is an ESP32-H2 based environmental monitoring device that measures air quality, temperature, and humidity. It provides real-time visual feedback through an RGB LED and communicates sensor data via serial interface.
Watch the AirCube in action: YouTube Demo
- Hardware: AirCube device (see Hardware section for build instructions)
- Software:
- ESP-IDF v5.0 or later
- Python 3.7+ (for data logging/visualization scripts)
- USB-C cable for programming and power
-
Clone the repository:
git clone https://github.com/yourusername/AirCube.git cd AirCube -
Build and flash the firmware:
cd firmware idf.py build idf.py -p COM3 flash monitor # Replace COM3 with your port
-
Run the data logger (in a separate terminal):
cd scripts pip install pyserial matplotlib # Edit aircube_logger.py to set your COM port python aircube_logger.py
-
Visualize the data (in another terminal):
python aircube_data_visualizer.py
That's it! Your AirCube should now be running and logging data.
-
Air Quality Monitoring
- eTVOC (equivalent Total Volatile Organic Compounds) in ppb
- eCO2 (equivalent CO2) in ppm
- AQI (Air Quality Index) calculation
- Environmental compensation using temperature and humidity data
-
Environmental Sensors
- Temperature measurement (Celsius/Fahrenheit)
- Relative humidity percentage
- ENS210 temperature/humidity sensor
- ENS161/ENS16X air quality sensor
-
Visual Feedback
- RGB LED (WS2812) with color-coded air quality indication
- Green: Good air quality (AQI 0-10)
- Yellow to Red: Degrading air quality (AQI 10-200)
- Blue (pulsing): Sensor warming up
- Smooth color transitions
- Adjustable brightness via button control
- RGB LED (WS2812) with color-coded air quality indication
-
Communication
- JSON-based serial protocol (115200 baud)
- Configurable sensor readout period
- Real-time sensor data streaming
-
Power Management
- Low-power operation support
- Configurable CPU frequency
- MCU: ESP32-H2-MINI-1
- Sensors:
- ENS210 (Temperature & Humidity)
- ENS161/ENS16X (Air Quality)
- LED: WS2812 RGB LED
- Interface: USB-C connector
- Power: USB-C powered
PCB design files are located in the kicad/ directory:
- KiCad schematic and PCB layout files
- Gerber files for manufacturing
- BOM (Bill of Materials)
- 3D STEP files
3D printed enclosure files are located in the mechanical/ directory:
- Top and bottom enclosure parts
- STEP files for CAD integration
The firmware is built using ESP-IDF and is located in the firmware/ directory.
-
Install ESP-IDF:
- Follow the official ESP-IDF Getting Started Guide
- Make sure ESP-IDF v5.0 or later is installed
- Set up the environment (run
get_idforexport.sh/export.bat)
-
Install USB drivers (if needed):
- Windows: Install CP210x USB to UART Bridge drivers
- Linux: Usually works out of the box, may need to add user to
dialoutgroup - macOS: Usually works out of the box
-
Navigate to firmware directory:
cd firmware -
Set the target (ESP32-H2):
idf.py set-target esp32h2
-
Configure the project (optional):
idf.py menuconfig
- Adjust serial port settings if needed
- Configure power management
- Modify sensor readout periods
-
Build the project:
idf.py build
-
Flash to device:
# Windows idf.py -p COM3 flash # Linux/macOS idf.py -p /dev/ttyUSB0 flash
Replace
COM3or/dev/ttyUSB0with your actual serial port. -
Monitor serial output:
idf.py -p COM3 monitor # or /dev/ttyUSB0 on Linux/macOSPress
Ctrl+]to exit the monitor. -
Flash and monitor in one command:
idf.py -p COM3 flash monitor
firmware/
βββ main/
β βββ main.c # Main application code
β βββ ens210.c/h # ENS210 temperature/humidity sensor driver
β βββ ens16x_driver.c/h # ENS16X air quality sensor driver
β βββ i2c_driver.c/h # I2C communication driver
β βββ led.c/h # LED control
β βββ led_color_lib.c/h # Color conversion utilities
β βββ ws2812_control.c/h # WS2812 LED driver
β βββ button.c/h # Button input handling
β βββ serial_protocol.c/h # Serial communication protocol
βββ CMakeLists.txt
βββ sdkconfig # ESP-IDF configuration
Python utilities for data logging and visualization are located in the scripts/ directory.
-
Install Python dependencies:
pip install pyserial matplotlib
-
Find your serial port:
- Windows: Check Device Manager β Ports (COM & LPT) or use
idf.py -p PORT monitorto test - Linux: Usually
/dev/ttyUSB0or/dev/ttyACM0. Check withls /dev/tty* - macOS: Usually
/dev/cu.usbserial-*or/dev/cu.SLAB_USBtoUART. Check withls /dev/cu.*
- Windows: Check Device Manager β Ports (COM & LPT) or use
-
aircube_logger.py - Data Logger
Logs sensor data from serial port to CSV file in real-time.
Configuration: Edit the script to set:
PORT = "COM3" # Your serial port BAUD = 115200 # Baud rate (default: 115200) CSV_FILE = "sensor_log.csv" # Output filename
Usage:
cd scripts python aircube_logger.pyThe script will:
- Create
sensor_log.csvif it doesn't exist - Append new sensor readings as they arrive
- Display logged data in the terminal
- Press
Ctrl+Cto stop logging
- Create
-
aircube_data_visualizer.py - Live Data Visualization
Real-time visualization of sensor data from the CSV file.
Configuration: Edit the script to set:
CSV_FILE = "sensor_log.csv" # Path to your CSV file MAX_POINTS = 300 # Number of recent samples to display UPDATE_INTERVAL_MS = 1000 # Refresh rate in milliseconds
Usage:
cd scripts python aircube_data_visualizer.pyThe script will:
- Display three plots: Temperature/Humidity, AQI, and Gas levels
- Auto-update as new data is logged
- Show the last 300 samples (configurable)
- Close the window to stop
-
aircube_replay_script.py - Data Replay
Replays logged sensor data with timestamp-based timing for analysis.
Configuration: Edit the script to set:
CSV_FILE = "sensor_log.csv" # Path to your CSV file SPEED = 5.0 # Playback speed (1.0 = real-time, 2.0 = 2x faster) MAX_POINTS = 300 # Number of samples to display
Usage:
cd scripts python aircube_replay_script.pyThe script will:
- Load all data from the CSV
- Replay it at the specified speed
- Show the same visualization as the live viewer
- Useful for analyzing historical data patterns
The device communicates via UART at 115200 baud using JSON messages.
The device periodically sends sensor data as JSON (default: every 1000ms, configurable):
{
"timestamp": 1234567890,
"ens210": {
"status": 0,
"temperature_c": 22.5,
"temperature_f": 72.5,
"humidity": 45.2
},
"ens16x": {
"status": "OK",
"etvoc": 50,
"eco2": 400,
"aqi": 5
}
}Commands can be sent to the device via serial (JSON format). See firmware/main/serial_protocol.c for available commands and implementation details.
Example: To change the sensor readout period, send a JSON command via serial.
The RGB LED provides real-time visual feedback based on air quality:
- π’ Green: AQI 0-10 (Good air quality)
- π‘ Yellow to π΄ Red: AQI 10-200 (Degrading air quality, smooth gradient)
- π΅ Blue (pulsing): Sensor warming up (first ~60 seconds after power-on)
- Smooth transitions: Color changes smoothly over ~1 second for pleasant visual experience
Brightness Control: Press the button on the device to cycle through brightness levels.
- Order PCB: Use the Gerber files in
kicad/gerbers/to order from your preferred PCB manufacturer - Order Components: Use
kicad/AirCube v1.0 BOM.csvto order components - Assembly: Follow the schematic in
kicad/AirCube.kicad_schfor assembly - Programming: Use USB-C connector for programming and power
- Print Files: Use the STEP files in
mechanical/directory - Assembly: Top and bottom parts snap together
- Mounting: PCB mounts inside the enclosure
AirCube/
βββ firmware/ # ESP-IDF firmware source code
β βββ main/ # Main application code
β βββ CMakeLists.txt # Build configuration
βββ kicad/ # PCB design files (KiCad)
β βββ gerbers/ # Manufacturing files
β βββ *.kicad_* # KiCad project files
βββ mechanical/ # 3D enclosure files
β βββ *.step # CAD files for 3D printing
βββ scripts/ # Python utilities
β βββ aircube_logger.py
β βββ aircube_data_visualizer.py
β βββ aircube_replay_script.py
βββ README.md # This file
-
Device not detected:
- Check USB cable (data-capable, not charge-only)
- Install USB drivers (CP210x for Windows)
- Check port permissions (Linux: add user to
dialoutgroup)
-
Build errors:
- Ensure ESP-IDF is properly installed and environment is set up
- Run
idf.py fullcleanand rebuild - Check that you've set the target:
idf.py set-target esp32h2
-
Flash errors:
- Put device in download mode (hold BOOT button, press RESET, release BOOT)
- Try lowering baud rate in
menuconfigβ Serial flasher config
-
No sensor data:
- Check I2C connections on PCB
- Verify sensor initialization in serial monitor
- Ensure sensors are properly powered
-
LED not working:
- Check WS2812 connections
- Verify power supply (LEDs need stable 5V)
- Check button functionality for brightness control
-
Serial port not found:
- Verify the port name (Windows:
COM3, Linux:/dev/ttyUSB0) - Ensure device is connected and drivers are installed
- Check if another program is using the port
- Verify the port name (Windows:
-
Import errors:
- Install dependencies:
pip install pyserial matplotlib - Use virtual environment if needed:
python -m venv venv
- Install dependencies:
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Additional sensor support
- Web interface for data visualization
- Mobile app integration
- Power optimization improvements
- Documentation improvements
- Bug fixes and testing
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.