Redson Dev · Idea
Low-Cost CO2 Monitor & Alert for Small Business Spaces
Published July 25, 2026
This project helps small businesses like a barber shop in Brooklyn, New York, or a veterinarian's office in Omaha, Nebraska, ensure good air quality by monitoring carbon dioxide levels. High CO2 can indicate poor ventilation, affecting staff and customer comfort. The device uses an affordable sensor to display current CO2 levels and trigger a visual or audible alert if they exceed a safe threshold, promoting a healthier indoor environment.
What you'll need
- 1x ESP32 development board (e.g., ESP32 WROOM-32)
- 1x MH-Z19B NDIR CO2 sensor
- 1x OLED display (128x64 pixels, I2C)
- 1x Breadboard
- Jumper wires (male-to-male and male-to-female)
- 1x Micro USB cable (for ESP32 power and programming)
- 1x Buzzer (optional, 5V)
Step-by-step
- 01
Hardware Assembly
Connect the MH-Z19B sensor to the ESP32: Vin to 5V, GND to GND, TX to ESP32 RX2 (GPIO16), RX to ESP32 TX2 (GPIO17). Connect the OLED display: VCC to 3.3V, GND to GND, SDA to ESP32 SDA (GPIO21), SCL to ESP32 SCL (GPIO22). If using, connect the buzzer positive lead to a digital pin (e.g., GPIO12) and negative to GND via a current-limiting resistor.
- 02
Arduino IDE Setup and Libraries
Install the ESP32 board definitions in Arduino IDE. Go to Preferences > Additional Board Manager URLs and add 'https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json'. Then, in Tools > Board > Boards Manager, search for and install 'esp32'. Install necessary libraries: 'MH_Z19B', 'Adafruit GFX Library', and 'Adafruit SSD1306'. Use the Library Manager under Sketch > Include Library > Manage Libraries.
- 03
Firmware Development
Write Arduino C++ code that initializes the MH-Z19B sensor and OLED display. Read CO2 concentration from the MH-Z19B every 5 seconds. Display the current CO2 level on the OLED. Implement a simple conditional check: if CO2 exceeds a predefined threshold (e.g., 1000 ppm), display a 'HIGH CO2' alert on the screen and, if connected, activate the buzzer.
- 04
Calibration and Threshold Setting
The MH-Z19B sensor often requires calibration in fresh air (400ppm). Include code to perform the 'ABC Logic' (Automatic Baseline Correction) or manually initiate a calibration cycle in a well-ventilated area for accurate readings. Set the alert threshold based on local guidelines or recommendations for indoor air quality, perhaps starting with 800-1000 ppm for initial testing.
- 05
Deployment and Testing
Upload the code to the ESP32. Power the device and place it in your target small business space. Monitor the readings on the OLED and observe the alert system when CO2 levels rise, perhaps by having several people occupy the space without opening windows. Adjust the alert threshold as needed for your specific environment.
Tips
- Consider adding Wi-Fi connectivity to log CO2 data to a simple local web server or cloud service for historical analysis.
- For a more polished look, design and 3D print an enclosure for the components.
- Add a push-button to cycle through different display modes or manually trigger a fresh air calibration.
