Read the NO concentration
What this example shows
The electrochemical-bridgeBoard.py example talks to the board at its I2C
address, 0x30. The module sees an address from 0x30 to 0x37 and uses the
board's ATtiny404 bridge: begin() checks that the bridge answers, sets up the
ADC and configures the LMP91000 front end for the chosen cell. Each getPPM()
then triggers one ADC conversion and turns it into a concentration in ppm.
The example opens I2C bus 0 with SCL on pin 22 and SDA on pin 21. Change
them if your controller's Qwiic connector uses other pins, and leave the
ADDRESS switch as it came, so the board answers at its default address, 0x30.
Change SENSOR_O3 to SENSOR_NO in both places (the import line and the
ElectrochemicalGasSensor(...) line) before you run it. SENSOR_NO is the
module's preset for this board's SGX-4NO-250 cell: 400 nA per ppm, a 120 kΩ
amplifier gain and a positive 12% bias. SENSOR_O3 is the preset for an
ozone cell, so its result is not NO in ppm.
The example code
The listing is the module's file at the pinned commit. Only comment lines are left out: the one that names the old connector, the header line that names another product's store page, and the connecting-diagram line that names an old board.
The example's comment says LMPEN is hardwired to GND. On this board a 10 kΩ
resistor pulls LMPEN to GND, and the pin is also wired to the ATtiny404 and
the header. Either way you set no config_pin: at 0x30 to 0x37 the module
ignores it.
# 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
Examples/electrochemical-bridgeBoard.py at commit 623e1e6
Expected result, with SENSOR_NO (readings in clean air; yours will differ):
Electrochemical Gas Sensor - ATtiny Bridge Board Example
Sensor initialized successfully!
Sensor reading: 0.00624 PPM
Sensor reading: 0.00588 PPM
Sensor reading: 0.00575 PPM
Sensor reading: 0.00585 PPM
Each Sensor reading: line is one reading, with the NO
concentration in ppm to five decimals and PPM at the end. If the board does
not answer, the example prints
ERROR: Can't init the sensor! Check connections and jumper address! and stays
in a loop.
Functions used
I2C(0, scl=Pin(22), sda=Pin(21))returns I2CCreates hardware I2C bus 0 on the given SCL and SDA pins. machine.I2C and machine.Pin come with MicroPython and are not part of the Soldered module (see docs.micropython.org, machine.I2C and machine.Pin).
ReturnsThe I2C bus object you pass to the sensor.
Parameters
| Type | Name | Description |
|---|---|---|
int | id | The hardware I2C bus, 0 in the example. |
Pin | scl | The clock pin, Pin(22) in the example. |
Pin | sda | The data pin, Pin(21) in the example. |
ElectrochemicalGasSensor(sensor_type, i2c=None, adc_addr=0x49, config_pin=None)returns ElectrochemicalGasSensorCreates the sensor object for one board. Nothing is sent over I2C until you call begin(). With i2c=None the module opens a bus itself on the boards it recognises, including an ESP32, where it opens I2C(0, scl=Pin(22), sda=Pin(21)), and an ESP8266, where it opens I2C(scl=Pin(5), sda=Pin(4)). On a board it does not recognise it raises an exception.
ReturnsThe sensor object.
Parameters
| Type | Name | Description |
|---|---|---|
SensorConfig | sensor_type | The cell preset. Use SENSOR_NO for this board. The module also has SENSOR_CO, SENSOR_NO2, SENSOR_SO2, SENSOR_O3, SENSOR_H2S, SENSOR_NH3 and SENSOR_CL2. |
I2C | i2c | The I2C bus the board is on. |
int | adc_addr | The I2C address. The example passes 0x30, the address the board ships with. The ADDRESS switch moves it within 0x30 to 0x37, but which setting gives which address is not confirmed yet, so only 0x30 is certain. For any address outside 0x30 to 0x37, such as the default 0x49, the module talks to the ADS1115 at that address and to the LMP91000 directly. |
int | config_pin | A GPIO for LMPEN. Unused at addresses 0x30 to 0x37, so the example leaves it out. |
sensor.begin()returns boolChecks that the board's bridge answers, sets the ADC gain from the preset and the slowest ADC data rate, then configures the LMP91000 front end (gain, load, reference, internal zero, bias and mode) from the preset. Each step waits up to 500 ms for the bridge to answer.
ReturnsTrue when every step succeeded, False otherwise.
sensor.getPPM()returns floatTakes one ADC reading and converts it: subtracts the internal zero (2.5 V times the preset's internal zero percentage), adds the zero calibration, divides by the amplifier gain to get the cell current, and divides that by the preset's nA per ppm.
ReturnsThe gas concentration in ppm. A negative result is returned as 0.0.
sensor.getPPB()returns floatThe alternative the example's comment offers: takes the same reading as getPPM() and multiplies it by 1000.
ReturnsThe gas concentration in ppb.
Putting it together
begin() runs once before the loop. If it returns False, the example prints
the error and waits forever, so you see the problem at once instead of zeros.
In the loop, each getPPM() makes one fresh measurement and the example prints
it with five decimals, then waits 2.5 seconds.