simple co2 sensor for indoor usage with led and buzzer signalling. based on esp32 and mh-z19 co2 sensor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Biermann 010f5f1646 Moved logos into sep. folder. 2 years ago
doc moved grafana dashboard to doc directory 2 years ago
lasercut_case Moved logos into sep. folder. 2 years ago
.gitignore another addition 2 years ago Removed error: USB-Cable has data lanes. 2 years ago
co2sensor.yaml display only n/100 digits for fewer distraction, changed thresholds, changed font to 'Gidole regular' 2 years ago
font.ttf changed to Gidole Regular 2 years ago
secrets.yaml.example updated documentation 2 years ago



higher concentrations of CO2 inside will make you sleepy and have an impact on your wellbeing. during the current pandemic higher CO2 concentrations inside are also a pretty good indic ation for higher levels of aerosol and as such a higher risk for infection. the 'CO2 Ampel' (CO2 traffic light) will give you a visual representation of the current situation and remin d you to open windows to keep you happy and healthy

parts list

description part link
ESP32 ESP-32 30Pin Aliexpress Link
Infrared CO2 Sensor mhz-19 Aliexpress Link
Active piezzo buzzer (optional) KY-012 Aliexpress Link
OLED Display SSD1306
LED-Ring (9 Pixel) WS2812 Aliexpress Link
3m USB-Kabel USB-Kabel Aliexpress Link


  • solder everything according to the connection schema
  • get yourself a copy of esphome ( pip3 install esphome
  • compile the firmware with co2ampel=USER_ROOM esphome co2sensor.yaml run
    • replace user with a nick that identifies you or your organisation
    • replace room with the place the sensor is located at
    • e.g. unhb_hackspace or unhb_001 for obfuscation
    • these will be used for online graphing! if sensor has wifi access
  • hold boot on your esp32 until fw upload starts.


  • place the sensor in your room, keep it away from direct exposure of breath (give it at least 1-2m distance to humans or other co2 sources to get the average co2 level of the room)
  • when there is a freifunk wifi around there is nothing to do for you, same when you defined your own wifi via secrets.yaml.
  • else just wait a bit and the sensor will spawn an wifi without a password. connect with your phone and choose to login or open in a browser to enter your wifi credentials
  • when everything is done, the default config will send the sensor readings back to the project where you can view online graphs (see grafana)


there is a quick setup on here your sensor should apper in the list on the left as soon it is connected via wifi.


ESP32 PIN peripherals note
VIN mhz-19 (VCC)
GND mhz-19 (GND)
GND KY-012 (GND) passive buzzer will do as well
D12 KY-012 (Signal/+)
3V3 SSD1306 (VCC)
3V3 WS2812 (VCC)
GND WS2812 (GND)
D4 WS2812 (DI)
RX2 / D16 mhz-19 (TX)
TX2 / D17 mhz-19 (RX)
I2C SDA / D21 SSD1306 (SDA)
I2C SCL / D22 SSD1306 (SCL)


if your ws2812 don't work on 3.3V power (most will do) you can try to use 5V instead. there are plenty different ws2812 builds so ymmv... if the leds don't work with 5V try to add a pullup resistor to your data line and a diode towards D4 to raise your high level while protecting your GPIO ( looks like this:

either way it might be a good idea to have a capacitor between VCC and GND. my prototype worked without any of these, but from time to time some LEDs just randomly turn on...

readings for inside rooms

CO2 measure light buzzer meaning
400 ppm none no more or less the baseline of the sensor hardware and means 'outside air quality'
400-800ppm none no safe zone and can be considered good air quality
800-1000ppm yellow no warning zone (consider to open windows) and is between medium and bad air quality
> 1000ppm red + blink no hygienic bad air quality, chance for infections rise