Hey all-
First time poster here. I'm working on an air quality project that requires using 2 VOC (Volatile Organic Compound) sensors. I'm using the SGP30 sensor from Adafruit, along with some other sensors and an e-Ink display.
I am able to get all of the devices visible and accessible, either connected through the on-board SDA & SCL pins of the GPIO, along with a 3.3V and Ground pin, or through using SparkFun's qwiic pHat.
The problem is that the SGP30 sensor is hardwired to a specific address, and is not changeable, so to get the second sensor to work I have to create additional i2c busses.
I've managed to make that work, and with "i2cdetect -l" and "i2cdetect -y {3|4}" can see the devices on the newly added busses.
However I can't figure out how to access those new busses from within the python code. I've searched high and low and find references to this can be done, but NO examples of it.
When I am connected to i2c bus 1 (default bus, pins 3 & 5 for SDA/SCL), I would use this code:
That all works when connected to i2c bus 1 (SDA/SCL on pins 3 & 5)
Based on what I found, I added the following lines to /boot/firmware/config.txtWhen I connect the sensors to bins 17 & 27, or pins 23 & 24, the respective "i2cdetect -y 3" (or "-y 4") shows the addresses the same as "-y 1" did.
However I can't find what values to use for the board.ISC() call. I've tried each of the following to access the sensors on bus 3 (pins 17 & 27):Any clue what I'm missing? How do I specify alternate pins for SDA and SCL in the busio.I2C() call?
First time poster here. I'm working on an air quality project that requires using 2 VOC (Volatile Organic Compound) sensors. I'm using the SGP30 sensor from Adafruit, along with some other sensors and an e-Ink display.
I am able to get all of the devices visible and accessible, either connected through the on-board SDA & SCL pins of the GPIO, along with a 3.3V and Ground pin, or through using SparkFun's qwiic pHat.
The problem is that the SGP30 sensor is hardwired to a specific address, and is not changeable, so to get the second sensor to work I have to create additional i2c busses.
I've managed to make that work, and with "i2cdetect -l" and "i2cdetect -y {3|4}" can see the devices on the newly added busses.
However I can't figure out how to access those new busses from within the python code. I've searched high and low and find references to this can be done, but NO examples of it.
When I am connected to i2c bus 1 (default bus, pins 3 & 5 for SDA/SCL), I would use this code:
Code:
import boardimport adafruit_si7021import adafruit_ssd1306import adafruit_sgp30from adafruit_pm25.i2c import PM25_I2Ci2c1 = board.I2C()oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c1, addr=0x3D, reset=oled_reset)sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c1)temphumid = adafruit_si7021.SI7021(i2c1)pm25 = PM25_I2C(i2c1,reset_pin)
Based on what I found, I added the following lines to /boot/firmware/config.txt
Code:
dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=17,i2c_gpio_scl=27
However I can't find what values to use for the board.ISC() call. I've tried each of the following to access the sensors on bus 3 (pins 17 & 27):
Code:
i2c3 = busio.I2C(board.GPIO17, board.GPIO27)i2c3 = busio.I2C(board.GP17,board.GP27)i2c3 = busio.I2C(board.G17,board.G27)i2c3 = busio.I2C(board.17,board.27)
Statistics: Posted by Ricker42 — Tue Mar 04, 2025 9:43 pm — Replies 0 — Views 12