CO2 Sensors are Awesome!

I just love to measure stuff in my apartment. I have temperature and humidity sensors in every room, I monitor all doors and windows, have multiple motion sensors and bought a VINDRIKTNING air quality sensor last month. Some days ago I learned about the SCD30 CO2 sensor and immediately bought one. The sensor is quite expensive but it should be very accurate because of its IR measurement method.

I attached the SCD30 sensor to an ESP8266 microcontroller board and also added a little OLED screen.  Then I put everything in a 3D-printed case.

The CO2 Sensor

I positioned the sensor in my bookshelf near my working desk. This allows me to also track the CO2 concentration at night because I work and sleep in the same room.

I calibrated the sensor outside to 400 ppm as my reference value.


I programmed the ESP using the Arduino framework and a special library that supports communication with the sensor via i2c. The following snippets shows the "interesting parts" of the code that I use:

#include "SSD1306Wire.h" 
#include "SparkFun_SCD30_Arduino_Library.h" 
#include <MQTT.h>
#include <ESP8266WiFi.h>

WiFiClient net;
MQTTClient client;

SSD1306Wire display(0x3c, D2, D1);
SCD30 airSensor;

void setup() {
  // ...
  if (airSensor.begin(Wire) == false) {
    Serial.println("Failed to find SCD30 chip");
    debug("No Connection");

uint32_t last = 0;
uint16_t last_reading = 0;

void loop() {
  uint32_t ms = millis();
  if (ms - last > 1000) {
    last = ms;

    if (airSensor.dataAvailable()) {

      uint16_t co2 = airSensor.getCO2();
      display.drawString(0, 15, String(co2) + " PPM");
      if (co2 != last_reading) {
        client.publish("co2", String(co2));
      last_reading = co2;


  // ...
  if (!digitalRead(D3)) {
  // ...

CO2 Levels

There exist different opinions about healthy CO2 concentrations in indoor spaces but most sources recommend a value below 1000 ppm for a productive and healthy work environment (fresh outside air has around 400 ppm). Values over 2000 ppm can cause unwanted effects like headaches and should be avoided.

Personally, I start to feel uncomfortable at values over 1200 ppm.


This is a CO2 concentration diagram that I recorded on a normal summer day (thus the long periods with open windows).
It shows that the CO2 level can rise above the marker of 1000 ppm in under one hour.

CO2-plot: Normal day

The highest CO2 concentrations are reached during night when the window is closed:

CO2-plot: Night

As a comparison, that's how the CO2-plot of a night with an open window looks like:

CO2-plot: Night with open window

When the apartment is empty, the CO2 concentration decreases very slowly. I'm not sure if this is caused by air leakage through the window or by my plants.

CO2-plot: Empty apartment

Not surprisingly, the CO2 concentration also heavily depends on the number of people in the room. Here I was watching a movie with 3 friends:

CO2-plot: Movie with friends


I really have to say that the SCD30 sensor was one of the best investments of the recent time. The sensor helps me to optimize my ventilation behavior and warns me about unhealthy CO2 levels. While regular ventilation is easy in the summer months, I will have to develop a strategy for the colder time.