This example uses a desktop CPython driver, not a CircuitPython driver.
It's easy to use the SEN5x Adapter Breakout with Python and the Sensirion Python driver for SEN5x sensors. This driver allows you to easily write Python code to read environmental data from a SEN5x sensor.
You can use this driver with any computer that has GPIO and Python. Note that this is NOT a CircuitPython compatible driver, it is for CPython (desktop Python).
This board does NOT come with a JST GH-compatible cable NOR a SEN5x sensor! You can pick up the cable here and a SEN5x from DigiKey.

Python Computer Wiring
Since there are dozens of Linux computers/boards you can use, we will show wiring for Raspberry Pi.
Here's the Raspberry Pi wired with I2C using the STEMMA connector:
-
Pi 3V to breakout STEMMA VIN (red wire)
-
Pi GND to breakout STEMMA GND (black wire)
-
Pi SCL to breakout STEMMA SCL (yellow wire)
- Pi SDA to breakout STEMMA SDA (blue wire)
- SEN5x sensor to breakout JST GH port
Here's the Raspberry Pi wired with I2C using a solderless breadboard:
-
Pi 3V to breakout VIN (red wire)
-
Pi GND to breakout GND (black wire)
-
Pi SCL to breakout SCL (yellow wire)
- Pi SDA to breakout SDA (blue wire)
- SEN5x sensor to breakout JST GH port
Python Installation of Sensirion SEN5x Library
You'll need to ensure that I2C is enabled on your platform and verify you are running Python 3.
Once that's done, from your command line run the following command:
pip3 install sensirion-i2c-driver sensirion-i2c-sen5x
This will install the Sensirion I2C driver and I2C SEN5x driver. If your default Python is version 3 you may need to run 'pip' instead.
Python Usage
Once you have the library pip3
installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:
python3 code.py
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries # # SPDX-License-Identifier: MIT import time from sensirion_i2c_driver import I2cConnection, LinuxI2cTransceiver from sensirion_i2c_sen5x import Sen5xI2cDevice i2c = LinuxI2cTransceiver('/dev/i2c-1') device = Sen5xI2cDevice(I2cConnection(i2c)) # Print some device information print(f"Version: {device.get_version()}") print(f"Product Name: {device.get_product_name()}") print(f"Serial Number: {device.get_serial_number()}") # Perform a device reset (reboot firmware) device.device_reset() # Start measurement device.start_measurement() time.sleep(1) def read_data(): try: # Wait until next result is available print("Waiting for new data...") while device.read_data_ready() is False: time.sleep(0.1) # Read measured values -> clears the "data ready" flag values = device.read_measured_values() print(values) # Access a specific value separately (see Sen5xMeasuredValues) # mass_concentration = values.mass_concentration_2p5.physical # ambient_temperature = values.ambient_temperature.degrees_celsius # Read device status status = device.read_device_status() print("Device Status: {}\n".format(status)) except Exception as e: # pylint: disable = broad-except print(f"Error: {e}") while True: read_data() time.sleep(5)
Sensirion has a LinuxI2cTransceiver
module in its sensirion_i2c_driver library. This lets you interface with the I2C bus on the Raspberry Pi in a way that is compatible with the Sensirion SEN5x library.
After the sensor is instantiated over I2C, data is read from the sensor and printed to the serial console every five seconds in the loop.
Page last edited January 21, 2025
Text editor powered by tinymce.