Read the SO2 concentration
What this example shows
The library's electrochemical-bridgeBoard.py example starts the breakout at I2C address 0x30 and prints the gas concentration in ppm every 2.5 seconds. It is the same script the Quick Start uses.
The example creates the sensor with the ozone cell preset, SENSOR_O3. SENSOR_SO2 is the library's preset for the SGX-4SO2 cell on this board: change SENSOR_O3 to SENSOR_SO2 in the import line and in the line that creates sensor to get SO2 values. The script creates the I2C bus on GPIO 22 (SCL) and GPIO 21 (SDA); change those numbers if your board's Qwiic connector uses other pins.
The listing is the library's file at the pinned commit, apart from a few comment-only lines, which name the connector by an older name, link to another Soldered product or name a controller board in the connecting diagram, and are left out. Where its comments say to set the address with jumpers, on this board the address is set by the ADDRESS switch (0x30 as shipped), and the address jumpers JP2 to JP4 stay as shipped. Where they say LMPEN is hardwired to GND, on this board LMPEN is pulled to GND by a 10 kΩ resistor and also runs to the on-board microcontroller (see Hardware Details).
The example code
# FILE: electrochemical-bridgeBoard.py
# AUTHOR: Fran Fodor @ Soldered
# BRIEF: Single sensor PPM reading example for the ATtiny404 bridge board revision,
# which allows daisy-chaining multiple boards on one I2C bus.
# LAST UPDATED: 2026-07-23
# Connecting diagram:
#
# Qwiic------------------------>Qwiic
#
# Note: on this board revision, LMPEN is hardwired to GND, so there's no
# config_pin to set - it's ignored whenever adc_addr falls in the bridge
# range (0x30-0x37). Set the desired address using the jumpers on the back
# of the board before powering it on.
from machine import I2C, Pin
import time
from ElectrochemicalGasSensor import ElectrochemicalGasSensor, SENSOR_O3
# Initialize I2C
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# (address = 0x30 + jumper offset, giving a range of 0x30-0x37).
# Any additional boards on the same bus just need a different jumper
# setting, same as twoSensors.py does for legacy boards with 0x49/0x4A/0x4B.
sensor = ElectrochemicalGasSensor(SENSOR_O3, i2c, adc_addr=0x30)
# -------------------------------------------------------------------------
# Setup
# -------------------------------------------------------------------------
print("Electrochemical Gas Sensor - ATtiny Bridge Board Example")
if not sensor.begin():
print("ERROR: Can't init the sensor! Check connections and jumper address!")
while True:
time.sleep_ms(100)
print("Sensor initialized successfully!")
# -------------------------------------------------------------------------
# Main loop
# -------------------------------------------------------------------------
while True:
reading = sensor.getPPM()
# If PPB is more relevant for your sensor, use:
# reading = sensor.getPPB()
print("Sensor reading: {:.5f} PPM".format(reading))
time.sleep_ms(2500)
🔗Open the complete example
electrochemical-bridgeBoard.py at the pinned commit
Expected result:
Electrochemical Gas Sensor - ATtiny Bridge Board Example
Sensor initialized successfully!
After those lines, a new Sensor reading: line follows every 2.5 seconds, with the concentration in ppm to five decimal places.
Functions used
ElectrochemicalGasSensor(sensor_type, i2c=None, adc_addr=0x49, config_pin=None)returns ElectrochemicalGasSensorCreates the sensor object. The sensor type is a preset with the cell's sensitivity and the front end and ADC settings. The address decides how the module talks to the board: 0x30 to 0x37 is the bridge range.
ReturnsThe sensor object.
Parameters
| Parameter | Type | Description |
|---|---|---|
sensor_type | SensorConfig | The cell preset. SENSOR_SO2 is the preset for this board's cell. |
i2c | I2C | An initialised machine.I2C object. Without it, the module picks pins only on a few known boards and raises Board not recognized on any other. |
adc_addr | int | The address the module talks to. 0x30 to 0x37 is the board's address as set by the ADDRESS switch, and selects the module's bridge mode; any other value talks to an ADS1115 directly at that address. Default 0x49. |
config_pin | int | GPIO for the front end's enable line. Not used at addresses 0x30 to 0x37; this example leaves it out. |
begin()returns boolChecks that the board answers and sends the ADC and LMP91000 settings from the preset to it. Call it once before any reading.
ReturnsTrue when the board answered and took every setting, False otherwise.
getPPM()returns floatHas the board take one ADC reading and turns it into a gas concentration, using the 2.5 V reference, the front end gain and the cell's sensitivity from the preset. A result below zero is returned as 0.
ReturnsGas concentration in ppm.
getPPB()returns floatThe same reading as getPPM(), in parts per billion. The example shows it in a comment as an alternative.
ReturnsGas concentration in ppb (getPPM() x 1000).
Putting it together
begin() sends the cell's settings once, then every getPPM() call asks the board for a fresh conversion. Keep adc_addr equal to the ADDRESS switch setting, and give every board on the same bus its own address.
The library's other examples each have their own page: Single sensor and Two sensors among them.