Ships from Alingsås, Sweden · Free shipping from 149 SEK · Swedish support by email and phone
Measure CO2 at home: build a CO2 meter for Home Assistant with the SCD40

Measure CO2 at home: build a CO2 meter for Home Assistant with the SCD40

22/11, 2026 –

Tired in the afternoon, stuffy air in the bedroom or a headache after a long meeting in the home office? Often the carbon dioxide level has crept up. With a real CO2 sensor and Home Assistant you see exactly when the air gets bad, and can get a reminder or start the ventilation automatically. This guide shows how to build your own CO2 meter in fifteen minutes.

⚡ In short

  • The M5Stack CO2 Unit with a Sensirion SCD40 measures real carbon dioxide (not an estimate) plus temperature and humidity.
  • It connects with the included Grove cable to an AtomS3 Lite or ATOM Lite. No soldering.
  • ESPHome reads the sensor and sends the values to Home Assistant. The LED on the board shows green, yellow or red.
  • Everything stays local, with no app or cloud service.

CO2 Unit connected with a Grove cable to an AtomS3 Lite that sends data to Home Assistant

The CO2 Unit connects with a Grove cable to the Atom board, which sends the values to Home Assistant over Wi-Fi.

Why measure carbon dioxide?

We breathe out carbon dioxide, so in a closed room the level keeps rising. CO2 itself is not dangerous at the levels found at home, but it is a very good measure of how well the room is ventilated. High levels go together with tiredness, poorer concentration and worse sleep.

Carbon dioxide scale from 400 to 2000 ppm

Approximate levels for indoor air.

Outdoors the CO2 level is around 420 ppm. The Public Health Agency of Sweden uses 1000 ppm as a guideline for adequate ventilation. In a bedroom with the door closed and two people, reaching 1500 to 2000 ppm during the night is not unusual.

Real CO2 sensor or estimate?

Many cheap air quality sensors show an eCO2 value calculated from other gases. The SCD40 measures carbon dioxide directly with photoacoustic sensing. The accuracy is ±(50 ppm + 5% of the reading) between 400 and 2000 ppm, which is more than enough to control ventilation and get reliable alerts.

What you need

CO2 Unit (U103)

CO2 Unit (U103)

Sensirion SCD40, CO2, temperature, humidity

549 kr

View product
AtomS3 Lite (C124)

AtomS3 Lite (C124)

Our first choice for new projects

219 kr

View product
ATOM Lite (C008)

ATOM Lite (C008)

Works just as well, change the pins

209 kr

View product

The Grove cable comes with the CO2 Unit. You also need a USB-C cable and an ordinary USB charger.

Step 1: Connect

Plug the Grove cable between the CO2 Unit and the Grove port on the Atom board. The connector only fits one way. That is all the hardware work.

AtomS3 LiteATOM Lite
Grove SDAGPIO2GPIO26
Grove SCLGPIO1GPIO32
RGB LEDGPIO35 (WS2812)GPIO27 (SK6812)
ESPHome boardm5stack-atoms3m5stack-atom

Step 2: Install ESPHome

  1. Install the ESPHome add-on in Home Assistant (Settings → Add-ons) if you do not have it yet.
  2. Connect the Atom board to your computer with USB-C and create a new device in ESPHome. Choose ESP32-S3 for the AtomS3 Lite or ESP32 for the ATOM Lite.
  3. Replace the configuration with the example below (keep your own api key and Wi-Fi) and click Install.
  4. After the first install over USB, all future changes can be made over Wi-Fi.
esphome:
  name: co2-bedroom

esp32:
  board: m5stack-atoms3      # ATOM Lite: m5stack-atom
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

api:
  encryption:
    key: !secret api_key

ota:
  - platform: esphome

i2c:
  sda: GPIO2                 # ATOM Lite: GPIO26
  scl: GPIO1                 # ATOM Lite: GPIO32

light:
  - platform: esp32_rmt_led_strip
    id: status_led
    name: "Status LED"
    pin: GPIO35              # ATOM Lite: GPIO27
    num_leds: 1
    rgb_order: GRB
    chipset: WS2812          # ATOM Lite: SK6812

sensor:
  - platform: scd4x
    update_interval: 30s
    co2:
      name: "CO2"
      on_value:
        then:
          - light.turn_on:
              id: status_led
              brightness: 30%
              red: !lambda 'return x > 800 ? 1.0 : 0.0;'
              green: !lambda 'return x > 1000 ? 0.0 : 1.0;'
              blue: 0%
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"

💡 The LED as a traffic light

With the example above the LED shows green below 800 ppm, yellow between 800 and 1000 ppm and red above 1000 ppm. Perfect in a child's room or on the desk, even for people who never open Home Assistant.

Step 3: Add it to Home Assistant

Once the board has started, it appears under Settings → Devices & services as a discovered ESPHome device. Click Add. You now have sensors for CO2, temperature and humidity, and can put them on your dashboard or view the history as a graph.

Step 4: Automations that make a difference

The really smart part is letting Home Assistant act on the value. This example sends a notification to your phone when CO2 has been above 1000 ppm for ten minutes:

alias: Remind me to air out
triggers:
  - trigger: numeric_state
    entity_id: sensor.co2_bedroom_co2
    above: 1000
    for: "00:10:00"
actions:
  - action: notify.mobile_app_your_phone
    data:
      message: >-
        CO2 in the bedroom is {{ states('sensor.co2_bedroom_co2') }} ppm.
        Time to air out!

More ideas:

  • Boost the ventilation unit when the level rises, and return to normal when it drops.
  • Turn on a fan in the home office through a smart plug or a relay.
  • Show a red light in the hallway when someone should open a bedroom window.
  • Log the highest value of the night and see how it changes when you sleep with the door open.

Placement and calibration

  • Place the sensor at about breathing height, 1 to 1.5 metres up, and not right by a window, a vent or where someone breathes straight on it.
  • The Atom board gets slightly warm. Keep the sensor a little away from the board using the cable, or adjust the temperature with temperature_offset in ESPHome.
  • The SCD40 calibrates itself automatically. It assumes the lowest level during a week is fresh air (about 400 ppm), so the room needs a proper airing at least once a week for the value to stay accurate.

⚠️ The first days

Give the sensor a few days with normal airing before you fully trust the exact numbers. The trend, when the level rises and falls, is right from the start.

Frequently asked questions

Do I need to know programming?

No. You paste the configuration above and click Install. All values arrive in Home Assistant automatically.

Can the same board also be a Bluetooth proxy?

Yes. Add the lines from our Bluetooth proxy guide to the same configuration.

How often does it measure?

The example reads every 30 seconds. The SCD40 can measure every five seconds, but 30 to 60 seconds is plenty at home.

Does it work without Home Assistant?

The LED works as a standalone traffic light. For graphs, history and automations you need Home Assistant.

Build your own CO2 meter

The CO2 Unit and the Atom boards ship from our stock in Sweden.

Buy CO2 Unit