Labs / Electronic modules

GraftSense - High-Precision CO₂ Sensor Module Based on SCD41 (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.1 · License: CC BY 4.0 · Driver code (sensors/scd41_driver): MIT License

Contents
GraftSense - High-Precision CO₂ Sensor Module Based on SCD41 (Open Version)
SCD41 LED1 R3 C3 U2 C4 R1 R2 C1 C2

I. Module Introduction

High-precision CO₂ sensor module based on SCD41, which adopts the chip solution of SCD41 based on light scattering principle, can simultaneously detect three environmental parameters: carbon dioxide concentration, temperature and humidity; the module is equipped with LDO voltage regulator circuit, power filtering and indicator circuit, powered by 3.3V and communicates with the main controller via I²C interface. It has built-in automatic background calibration function, low long-term drift and high stability, supports low-power single measurement mode, and is suitable for indoor air quality monitoring, smart home, fresh air purification equipment and other scenarios.

II. Introduction to Main Chips

SCD41 is a Sensirion product of miniature high-precision CO₂ sensor. Based on the photoacoustic NDIR principle, it integrates temperature and humidity compensation, features small size, low power consumption and supports I2C, making it suitable for indoor air quality monitoring.

2.1 Chip Overview

SCD4x 10.1 6.5 0 40000 40 5 I2C 0.4 1

Sensirion SCD4x series miniature CO₂ sensors adopt patented photoacoustic NDIR technology, integrate temperature and humidity detection, measure only 10.1×10.1×6.5 mm³, have a measurement range of 0–40000 ppm with an accuracy of ±(40 ppm + 5%), support I2C interface and reflow soldering, feature an average current consumption as low as 0.4 mA, and are suitable for space-constrained indoor air quality monitoring and intelligent ventilation devices.

2.2 Pin Definition

SCD4x I2C 1 SCD41

SCD41 / LGA package, with the key pins as follows: VDD / VDDH (power supply, which shall be connected in parallel at the same voltage), GND (ground), SDA / SCL (I2C data/clock), and the remaining pins are DNC (do not connect, leave floating). The chip uses the notch on the protective film as the positioning mark for pin 1.

2.3 Functional Block Diagram

SCD41 I2C

The SCD41 operates on the photoacoustic NDIR principle: the system controller drives the infrared emitter to emit infrared light of a specific wavelength, CO₂ gas absorbs the infrared energy to generate a photoacoustic signal which is collected by an acoustic transducer; meanwhile, the built-in temperature and humidity sensor acquires data synchronously, the signal is sent to the signal processing unit via the digital interface for calculation and compensation, and finally the measurement result is output through the I2C interface.

2.4 Performance Parameters

SCD41 400 2000 40 5 4000 5000

The SCD41 sensor features a CO₂ measurement range of 0–40000 ppm, with an accuracy of ±(40 ppm + 5% of reading) within the 400–5000 ppm range, a repeatability of ±10 ppm, and a response time of 60 seconds; its temperature and humidity measurement ranges are -10~60℃ and 0~100% RH respectively, with typical accuracy of ±0.8℃ / ±6% RH. It also provides specifications for long-term drift, repeatability and other parameters, reflecting its multi-parameter integration and high-precision characteristics.

SCD41 2.4 5.5V 30mV 175mA 0.4mA 10 60 0 95

SCD41 has a supply voltage range of 2.4–5.5V, with a typical voltage ripple of less than 30mV; its peak current is approximately 175mA at 3.3V, and the current in low-power mode is as low as 0.4mA; it operates at a temperature range of -10–60℃ and a humidity range of 0–95% RH (non-condensing), with a typical sensor lifespan of over 10 years. Key parameters including I/O levels and ESD rating are also provided.

2.5 Reference Circuit

SCD41 10k

SCD41 's SCL and SDA lines are pulled up to VDD via an external pull-up resistor (e. g., 10kΩ) to enable open-drain bidirectional communication;VDD and VDDH must be connected together nearby to supply power to the sensor. The microcontroller transmits and receives data with the sensor by driving the bus to a low level, thereby enabling the transmission of measurement data such as CO₂.

2.6 Chip Configuration

None.

SCD4x 3 16 0x62 8 3.1 1000ms 3.2 3.3 5

SCD41 has an I²C interface that uses 0x62 as the device address; after power-on, it must wait 1000ms to enter the idle state before being able to receive commands. Communication takes 16-bit command/data (MSB first) plus 8-bit CRC check as the basic unit, supports four types of I²C sequences: write, read, send command, and send command and fetch result; for read operations, data can only be read after waiting for the command execution time.

SCD4x SCD41 5 0x21b1 0ms

SCD4x instruction set is functionally categorized into basic measurement, signal compensation, calibration, low-power operation, advanced functions, and SCD41 proprietary instructions, listing the hexadecimal codes, I²C sequence types, execution durations, and in-cycle executability of each command, covering core operations including measurement start/stop, temperature and humidity compensation, automatic calibration, low-power control, self-test and reset.

SCD4x 5 0x21b1 0xec05 1ms

SCD4x ’s basic commands define a periodic measurement process: first send start_periodic_measurement (0x21b1) to start the 5-second update cycle, then use read_measurement (0xec05) to read CO₂, temperature and humidity data (each with CRC checksum, parsed according to a fixed formula); only a few commands such as read, stop, and set air pressure are supported during measurement operation.

SCD4x 0x3f86 0x241d

SCD4x features for stopping periodic measurement and signal compensation: send stop_periodic_measurement (0x3f86) and wait for 500ms to stop periodic measurement and enter idle mode for configuration modification; signal compensation must be operated in idle mode, for example, set the temperature and humidity compensation offset (which does not affect CO₂ accuracy) via set_temperature_offset (0x241d), after modification, a save command needs to be sent, then restart the measurement to take effect.

SCD41 3 1ms

SCD4x compensation-related commands: get_temperature_offset (0x2318) is used to read the current temperature offset value;set_sensor_altitude (0x2427) and get_sensor_altitude (0x2322) are used to set / read the altitude (default: 0 meters). All these configurations must be operated in idle mode, and the settings need to be saved to EEPROM via the persist_setting command after configuration.

0xe000 1ms

SCD4x features ambient pressure compensation and on-site calibration functions: set_ambient_pressure (0xe000) can set the current ambient pressure during periodic measurement, with a higher priority than the altitude setting, and is recommended for scenarios with significant air pressure changes; on-site calibration includes Forced Recalibration (FRC) and Automatic Self-Calibration (ASC). The former needs to be performed step by step in an environment with a known CO₂ concentration to restore the initial accuracy, while the latter relies on exposure to a 400ppm environment every week to achieve long-term stability.

SCD4x

SCD4x on-site calibration command: perform_forced_recalibration (0x362f) requires input of the target CO₂ concentration, and returns the calibration correction value after execution (0xffff indicates failure);set_automatic_self_calibration_enabled (0x2416) is used to enable or disable the Automatic Self-Calibration (ASC, enabled by default), while get_automatic_self_calibration_enabled (0x2313) reads its current status. After configuration, the setting must be saved to persist_setting to EEPROM.

SCD4x 30 0 11 0x21ac 0x4b03 1ms 0x8000

SCD4x low-power periodic measurement mode: Send the start_low_power_periodic_measurement (0x21ac) command to initiate low-power measurement with an update interval of approximately 30 seconds, which reduces power consumption and self-heating but results in a longer response time; use the get_data_ready_status (0xe4b8) command to check the data ready status, so as to avoid receiving a NACK response when reading unready data.

2000 48 3 16

SCD4x 's persist_settings (0x3615) command can write configurations such as temperature offset, altitude, and ASC status to EEPROM for power-off retention. Note that the EEPROM has a minimum endurance of 2000 erase-write cycles; the get_serial_number (0x3682) command reads the 48-bit unique serial number for chip identification and verification, with the data returned in 3 16-bit words each with CRC check.

10 0 1.2

SCD4x Self-test and reset commands: perform_self_test (0x3639): Triggers the sensor's functional self-test, which takes 10 seconds; a return value of 0 indicates no faults. perform_factory_reset (0x3632): Restores factory settings and clears calibration history, taking 1.2 seconds to complete. reinit (0x3646): Performs a soft reboot by reloading configuration from EEPROM; stop measurements before sending this command.

SCD41 CO2 5000ms 0ppm 50ms

SCD41 features a unique low-power single-shot measurement mode: measure_single_shot (0x219d) enables on-demand measurement of CO₂, temperature and humidity (taking 5 seconds), while measure_single_shot_rht_only (0x2196) measures only temperature and humidity (taking 50ms). Automatic self-calibration is enabled by default for single-shot measurements; averaging results from multiple consecutive measurements can reduce noise. With extremely low power consumption, this mode is ideal for low-duty-cycle applications.

SCD41 0x36e0 1ms 0x36f6 20ms

SCD41 Power Management Commands: power_down (0x36e0) puts the sensor from idle mode into sleep to reduce power consumption, while wake_up (0x36f6) wakes it back to idle mode (no response after wakeup; the status can be verified by reading the serial number, and the first single measurement data is recommended to be discarded), making it suitable for power cycle applications in single measurement scenarios.

SCD4x SCD41 CRC-8 8 0x31 0xFF

SCD4x I²C communication CRC check rule: uses an 8-bit CRC algorithm with the polynomial 0x31 and the initial value 0xFF, which only calculates the checksum for the two bytes of the data word (excluding the command word). The complete implementation code in C language is provided to ensure the integrity of data transmission.

2.8 PCB Routing Precautions

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the circuit source project, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_Schematic1_High-Precision CO2 Sensor Module Based on SCD41_v1.0.0_2026-05-09.pdf 2.1 MB

SCD41 U1 U2 I2C V1.0.0

This module provides an I2C communication interface: the default address is 0x62, it is compatible with 3.3V level, supports standard I2C communication rate, and can realize stable reading of three environmental parameters including carbon dioxide concentration, temperature and humidity; the module is equipped with LDO voltage regulator and power filter circuit, integrates automatic background calibration function, features low long-term drift and high stability, supports low-power single measurement and periodic measurement modes, and is suitable for scenarios such as indoor air quality monitoring, smart home, fresh air purification equipment, etc. , providing reliable environmental perception data and interaction capabilities for the system.

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing. The high-precision CO₂ sensor module based on SCD41 uses the I2C interface to communicate with the main controller.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's I2C0 interface:

development board pins

Module Pins

Description

Pin 4

SDA

I2C data transmission line, corresponding to I2C0 's SDA

Pin 5

SCL

I2C clock signal line, corresponding to the I2C0 SCL

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

106 0.0.20200321

Enter scd41_driver to search, and the following will be displayed:

scd41_driver v1.0.2 SCD4X CO2

Click to copy the local installation command:

scd41_driver SCD41 v1.0.1 SCD4X

Import the module driver library code via the mip tool. Below are the usage commands for the mpremote tool:

mpremote mip install https://upypi.net/pkgs/scd41_driver/1.0.0

Import the high-precision CO₂ sensor module based on SCD41 - MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/09/08 16:52
# @Author  : hogeiha
# @File    : main.py
# @Description : Code to test the SCD4X CO2/temperature/humidity sensor driver class
# @License : MIT

# ======================================== Import Modules =========================================

from machine import Pin, SoftI2C
from scd4x import SCD4X
import time

# ======================================== Global Variables ============================================

TARGET_SENSOR_ADDRS = [0x62]
I2C_SDA_PIN = 4
I2C_SCL_PIN = 5
I2C_FREQ = 100_000

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization ==========================================

time.sleep(3)
print("FreakStudio: Using SCD4X CO2/temperature/humidity sensor ...")

# Initialize the SoftI2C bus
i2c_bus = SoftI2C(sda=Pin(I2C_SDA_PIN), scl=Pin(I2C_SCL_PIN), freq=I2C_FREQ)

# Scan for devices on the I2C bus
devices_list = i2c_bus.scan()
print("START I2C SCANNER")
if len(devices_list) == 0:
    raise RuntimeError("I2C scan found no devices")
print("I2C devices found: %d" % len(devices_list))

# Iterate over the scan results and initialize the target sensor
sensor = None
for device in devices_list:
    if device in TARGET_SENSOR_ADDRS:
        print("I2C address: %s" % hex(device))
        sensor = SCD4X(i2c_bus=i2c_bus, address=device)
        print("Sensor initialization successful")
        break

if sensor is None:
    raise RuntimeError("No target sensor found on I2C bus")

# Print the serial number
print("SCD4X Serial Number: %s" % str(sensor.serial_number))

# Configure the sensor parameters
sensor.altitude = 100
sensor.temperature_offset = 2.0
sensor.self_calibration_enabled = True
sensor.persist_settings()

# Start periodic measurement mode
sensor.start_periodic_measurement()
print("Start measuring...")

# ========================================  Main Program  ===========================================

try:
    while True:
        if sensor.data_ready:
            co2 = sensor.CO2
            temp = sensor.temperature
            humi = sensor.relative_humidity
            print("CO2: %d ppm  Temp: %.2f C  RH: %.2f %%" % (co2, temp, humi))
        time.sleep(5)

except KeyboardInterrupt:
    print("Program interrupted by user")
except OSError as e:
    print("Hardware communication error: %s" % str(e))
except Exception as e:
    print("Unknown error: %s" % str(e))
finally:
    print("Cleaning up resources...")
    sensor.deinit()
    del sensor
    print("Program exited")

Burn the code, open the terminal, and the output is as follows:

I2C SCD4X

The SCD4X CO₂/temperature and humidity sensor functions properly in terms of I2C communication and initialization, and can stably output CO₂ concentration, temperature and humidity data. The CO₂ value gradually rises during the measurement process, while the temperature and humidity fluctuate slightly synchronously, indicating normal operation response.

IV. Drivers

scd41_driver-1.0.0.zip 13 KB

None.

VI. Revision History

Document Version

Date of Revision

Modifier

Modify Content

v1.0

2026-05-09

Zero High-Luck

Initialize the document

v1.1

2026-06-06

Xin Ruili

Create an open version of the document based on the internal document version v1.0.

VII. Relevant Materials

7.1 Chip Datasheet

SCD41-D-R1.pdf 953 KB

7.2 Unique Icons for PCB Silk Screen

SCD41 7.2