Two sensors
What this example shows
The library's electrochemical-twoSensors.py example reads two boards on one I2C bus and prints both concentrations in ppb (parts per billion) every 2.5 seconds. It creates sensor1 at adc_addr=0x4A with config_pin=25, and sensor2 at adc_addr=0x49 with config_pin=32.
Both objects use the ozone cell preset, SENSOR_O3. SENSOR_SO2 is the library's preset for this board's SO2 cell: change SENSOR_O3 to SENSOR_SO2 in the import line and in both lines that create a sensor to get SO2 values. The script creates the I2C bus on GPIO 22 (SCL) and GPIO 21 (SDA). This board's address switch and jumpers are described on Hardware Details.
On this board the LMP91000 and ADS1115 sit on the board's own bus 2, and your controller reaches them through the board's address on the Qwiic bus, 0x30 to 0x37 with the ADDRESS switch (0x30 as shipped). The example's adc_addr=0x4A and adc_addr=0x49 talk to an ADS1115 directly. For two of these boards, give each its own ADDRESS switch address and pass that address as adc_addr for its sensor. Where the connecting diagram says each LMPEN goes to a GPIO pin, on this board LMPEN is already pulled to GND by a 10 kΩ resistor and also runs to the on-board microcontroller, and at the board's addresses the module does not use config_pin.
The comment "Set different ADC I2C addresses on each breakout using the address jumpers." does not give this board's procedure. Leave the address jumpers JP2 to JP4 as shipped: moving JP3 or JP4 may stop the board giving readings, and closing two of them shorts 3V3 to SDA2, 3V3 to SCL2, or SDA2 to SCL2, depending on which pair. See Hardware Details.
The listing is the library's file at the pinned commit, apart from three comment-only lines, which link to another Soldered product or name a controller board in the connecting diagram, and are left out. In that diagram, the first Qwiic and LMPEN pair is sensor 1 (LMPEN to GPIO 25) and the second is sensor 2 (LMPEN to GPIO 32).
The example code
# FILE: electrochemical-twoSensors.py
# AUTHOR: Fran Fodor @ Soldered
# BRIEF: Two O3 sensor PPB reading example using two breakouts on one I2C bus.
# LAST UPDATED: 2026-05-21
# Connecting diagram:
#
# Qwiic------------------------>Qwiic
# LMPEN------------------------>25 (GPIO pin, required for I2C configuration)
#
# Qwiic------------------------>Qwiic (same bus)
# LMPEN------------------------>32 (GPIO pin, required for I2C configuration)
#
# Set different ADC I2C addresses on each breakout using the address jumpers.
# Both LMP91000 chips share address 0x48 — the LMPEN pin selects which one
# is active during configuration, so a GPIO pin is required for each sensor.
from machine import I2C, Pin
import time
from ElectrochemicalGasSensor import ElectrochemicalGasSensor, SENSOR_O3
# Initialize shared I2C bus
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# Sensor 1: ADC address 0x4A, LMPEN on pin 25
sensor1 = ElectrochemicalGasSensor(SENSOR_O3, i2c, adc_addr=0x4A, config_pin=25)
# Sensor 2: ADC address 0x49, LMPEN on pin 32
sensor2 = ElectrochemicalGasSensor(SENSOR_O3, i2c, adc_addr=0x49, config_pin=32)
# -------------------------------------------------------------------------
# Setup
# -------------------------------------------------------------------------
print("Electrochemical Gas Sensor - Two Sensors Example")
if not sensor1.begin():
print("ERROR: Can't init sensor 1! Check connections!")
while True:
time.sleep_ms(100)
print("Sensor 1 initialized successfully!")
if not sensor2.begin():
print("ERROR: Can't init sensor 2! Check connections!")
while True:
time.sleep_ms(100)
print("Sensor 2 initialized successfully!")
# -------------------------------------------------------------------------
# Main loop
# -------------------------------------------------------------------------
while True:
reading1 = sensor1.getPPB()
reading2 = sensor2.getPPB()
print("Sensor 1 reading: {:.5f} PPB".format(reading1))
print("Sensor 2 reading: {:.5f} PPB".format(reading2))
time.sleep_ms(2500)
🔗Open the complete example
electrochemical-twoSensors.py at the pinned commit
Expected result:
Electrochemical Gas Sensor - Two Sensors Example
Sensor 1 initialized successfully!
Sensor 2 initialized successfully!
After those lines, a Sensor 1 reading: and a Sensor 2 reading: line follow every 2.5 seconds, each with its concentration in ppb to five decimal places. If one board does not start, the script prints ERROR: Can't init sensor 1! Check connections! (or sensor 2) and stops there.
Functions used
ElectrochemicalGasSensor(sensor_type, i2c=None, adc_addr=0x49, config_pin=None)returns ElectrochemicalGasSensorCreates one sensor object from a cell preset, an I2C object, an address and an optional enable pin. The example creates two, one per board, on the same I2C object.
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, shared by both sensors. |
adc_addr | int | The address the module talks to. 0x30 to 0x37 selects the module's bridge mode, which talks to the board's on-board microcontroller; any other value talks to an ADS1115 directly at that address. Default 0x49. |
config_pin | int | GPIO for the LMP91000's enable line. Not used at addresses 0x30 to 0x37. Default None. |
begin()returns boolStarts the transport the address selects and sends the ADC and LMP91000 settings from the preset. The example calls it once for each sensor.
ReturnsTrue when the setup succeeded, False otherwise.
getPPB()returns floatTakes one ADC reading and returns the gas concentration in parts per billion: getPPM() x 1000. A result below zero is returned as 0.
ReturnsGas concentration in ppb.
Putting it together
Each ElectrochemicalGasSensor object keeps its own address and preset, so one script can read several boards on the same bus, as long as no two share an address.