Use 2x BME280 sensors failed #11978
-
Hi, I need two BME280 sensors which I will connect to my pico. My code is the following:
I get this error:
The i2c scanner can detect the sensors when I connect them after another: Same address for both (118 or 0x76). Is something wrong with the code or is it a i2c bus problem? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
If they are both at 0x76, then the initialization below will not find the second one, because it uses address 0x77. bme2 = BME280.BME280(i2c=i2c_1, address=0x77) On the sensor, if the SDO pin is grounded, it will use address 0x76. If the SDO pin is connected to +V, it will use address 0x77. Don't let it float: then the address is undefined. If you set the address of one sensor to 0x76 and the other to 0x77, you can then connect them to the same I2C bus, and you won't need two I2C buses. |
Beta Was this translation helpful? Give feedback.
-
Could you post a purchase or product link to your sensor board? The code you posted above is already using two different buses, |
Beta Was this translation helpful? Give feedback.
-
Sure, I have ordered them here: https://www.berrybase.de/gy-bme280-breakout-board-3in1-sensor-fuer-temperatur-luftfeuchtigkeit-und-luftdruck Ok, well, then I don't understand why it is not compiling correctly. This should work without correct addresses, right? If not, it could be an address issue since the sensors use the same one. I have connected VCC, GND, SDA and SCL. |
Beta Was this translation helpful? Give feedback.
-
Here is an old thread about the same error message: https://forum.micropython.org/viewtopic.php?t=4746 |
Beta Was this translation helpful? Give feedback.
GPx and GPIOx are just different names for the same thing. And the numbers of the GPIO constructor refer to GPIO/GP numbers. The usual confusion with RPi Pico boards is between GPIO/GP numbers and board pin numbers.
The former start at 0 up to 31, the latter start at 1 up to 40. So GPIO/GP 8 is at board pin #11, GPIO/GP9 is at board pin #12.