Sensirion Raspberry Pi I²C SCD4X Driver

July 16, 2026 · View on GitHub

The repository provides a driver for setting up a sensor of the SCD4X family to run on a Raspberry Pi over I²C.

Click here to learn more about the Sensirion SCD4X sensor family.

Not all sensors of this driver family support all measurements. In case a measurement is not supported by all sensors, the products that support it are listed in the API description.

Supported sensor types

Sensor nameI²C Addresses
SCD400x62
SCD410x62
SCD420x62
SCD430x62

The following instructions and examples use a SCD43.

Connect the sensor

Your sensor has 4 different connectors: GND, VDD, SDA, SCL. Use the following pins to connect your SCD4X:

SCD4XCable ColorRaspberry Pi
GNDblackPin 6
VDDredPin 1
SDAgreen or bluePin 3
SCLyellowPin 5

Detailed sensor pinout

PinCable ColorNameDescriptionComments
1blackGNDGround
2redVDDSupply Voltage2.4V to 5.5V
3green or blueSDAI2C: Serial data input / output
4yellowSCLI2C: Serial clock input

Quick start example

  • Install the Raspberry Pi OS on to your Raspberry Pi

  • Enable the I²C interface in the raspi-config

  • Download the SCD4X driver from Github and extract the .zip on your Raspberry Pi

  • Connect the SCD4X sensor as explained in the section above

  • The provided example is working with a SCD43, I²C address 0x62. In order to use the code with another product or I²C address you need to change it in the call scd4x_init(ADDRESS) in scd4x_i2c_example_usage.c. The list of supported I²C-addresses is found in the header scd4x_i2c.h.

  • Compile the driver

    1. Open a terminal

    2. Navigate to the driver directory. E.g. cd ~/raspberry-pi-i2c-scd4x

    3. Navigate to the subdirectory example-usage.

    4. Run the make command to compile the driver

      Output:

      rm -f scd4x_i2c_example_usage
      cc -Os -Wall -fstrict-aliasing -Wstrict-aliasing=1 -Wsign-conversion -fPIC -I. -o scd4x_i2c_example_usage  scd4x_i2c.h scd4x_i2c.c sensirion_i2c_hal.h sensirion_i2c.h sensirion_i2c.c \
          sensirion_i2c_hal.c sensirion_config.h sensirion_common.h sensirion_common.c scd4x_i2c_example_usage.c
      
  • Test your connected sensor

    • Run ./scd4x_i2c_example_usage in the same directory you used to compile the driver. You should see the measurement values in the console.

Troubleshooting

Building driver failed

If the execution of make in the compilation step 3 fails with something like

 make: command not found

your RaspberryPi likely does not have the build tools installed. Proceed as follows:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential

Initialization failed

If you run ./scd4x_i2c_example_usage but do not get sensor readings then go through the below troubleshooting steps.

  • Ensure that you connected the sensor correctly: All cables are fully plugged in and connected to the correct pin.
  • Ensure that I²C is enabled on the Raspberry Pi. For this redo the steps on "Enable the I²C interface in the raspi-config" in the guide above.
  • Ensure that your user account has read and write access to the I²C device. If it only works with user root (sudo ./scd4x_i2c_example_usage), it's typically due to wrong permission settings. See the next chapter how to solve this.

Missing I²C permissions

If your user is missing access to the I²C interface you should first verfiy the user belongs to the i2c group.

$ groups
users input some other groups etc

If i2c is missing in the list add the user and restart the Raspberry Pi.

$ sudo adduser your-user i2c
Adding user `your-user' to group `i2c' ...
Adding user your-user to group i2c
Done.
$ sudo reboot

If that did not help you can make globally accessible hardware interfaces with a udev rule. Only do this if everything else failed and you are reasoably confident you are the only one having access to your Pi.

Go into the /etc/udev/rules.d folder and add a new file named local.rules.

$ cd /etc/udev/rules.d/
$ sudo touch local.rules

Then add a single line ACTION=="add", KERNEL=="i2c-[0-1]*", MODE="0666" to the file with your favorite editor.

$ sudo vi local.rules

Contributing

Contributions are welcome!

This Sensirion library uses clang-format to standardize the formatting of all our .c and .h files. Make sure your contributions are formatted accordingly:

The -i flag will apply the format changes to the files listed.

clang-format -i *.c *.h

Note that differences from this formatting will result in a failed build until they are fixed.

License

See LICENSE.