Reference
SCD40 / SCD41 CO2 Sensor Complete Guide
The SCD40 and SCD41 measure actual CO2 concentration using photoacoustic NDIR sensing, something a temperature/humidity sensor like the BME280 or SHT series cannot do at all. This guide covers both chips' real specs, wiring one to an ESP32, and the common beginner mix-up between CO2 sensing and air-quality/humidity sensing.
- ESP32
- 2 min read
The SCD40 and SCD41 are true CO2 sensors from Sensirion, measuring carbon dioxide concentration in parts-per-million using photoacoustic NDIR (non-dispersive infrared) sensing, alongside onboard temperature and humidity measurement. This is a genuinely different measurement principle from the already-published BME280 or SHT series, a common beginner mix-up worth stating directly: neither the BME280 nor any SHT sensor measures CO2, they measure temperature, humidity and (for the BME280) barometric pressure, none of which is a substitute for real CO2 sensing.
SCD40 vs. SCD41: real differences
| SCD40 | SCD41 | |
|---|---|---|
| CO2 accuracy | ±50ppm | ±40ppm |
| Low-power single-shot mode | No | Yes |
| Best for | Continuously-powered monitors (e.g. a wall-plugged CO2 traffic-light indicator) | Battery-powered or duty-cycled monitors, thanks to its single-shot low-power mode |
Both share the same I2C address (0x62) and command set, so code written for one runs on the other. Pick the SCD41 specifically if you need battery-friendly, infrequent readings, otherwise the SCD40 is the cheaper option for an always-powered monitor.
Pinout
| Pin | Function |
|---|---|
| VDD | Power, 2.4V–5.5V |
| GND | Ground |
| SDA | I2C data |
| SCL | I2C clock |
Both chips need a brief warm-up after power-on and periodic recalibration against known-good outdoor air (~400–420ppm) for long-term accuracy, both handled automatically by their default automatic self-calibration (ASC) unless disabled.
Wiring to an ESP32
| SCD4x Pin | ESP32 Pin |
|---|---|
| VDD | 3.3V |
| GND | GND |
| SDA | GPIO21 |
| SCL | GPIO22 |
Arduino code (SparkFun SCD4x library)
#include <Wire.h>
#include <SparkFun_SCD4x_Arduino_Library.h>
SCD4x co2Sensor;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!co2Sensor.begin()) {
Serial.println("Couldn't find SCD4x sensor");
while (1) delay(10);
}
}
void loop() {
if (co2Sensor.readMeasurement()) {
Serial.print("CO2 (ppm): ");
Serial.print(co2Sensor.getCO2());
Serial.print(" Temp (C): ");
Serial.print(co2Sensor.getTemperature());
Serial.print(" Humidity (%RH): ");
Serial.println(co2Sensor.getHumidity());
}
delay(5000); // the sensor itself only produces a new reading every 5s
}Install “SparkFun SCD4x Arduino Library” via the Arduino Library Manager, or Sensirion’s own “Sensirion I2C SCD4X” library. Note there is no first-party Adafruit Arduino library for this chip, only a CircuitPython driver, if you were expecting one by analogy with Adafruit’s other sensor libraries.
Practical Applications
- Indoor air quality monitoring: CO2 buildup is a genuine, well-studied proxy for how stale/poorly-ventilated a room is.
- Demand-controlled ventilation: only run an extractor fan or HRV when CO2 actually rises.
- Meeting-room/classroom monitors: a common, practical use case for this exact chip.
- Greenhouse CO2 supplementation control: closing the loop on CO2 enrichment for plant growth.
Conclusion
If a project genuinely needs CO2 data, the SCD40/SCD41 are the real thing, not a proxy inferred from humidity or temperature. Either pairs cleanly with an ESP32 over I2C alongside a BME280 for a complete air-quality picture.
More guides
Keep building.
From ESP32 HomeKit accessories to Arduino and ATtiny reference guides, there’s more where this came from.
All guides

