2

I'm very new into rpi & sensors. I'd like to connect an BME280 I2C Temperature and Pressure Sensor and a Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor to my rpi. In the tutorials I see that both require:

Pi 3V3 to sensor VIN
Pi GND to sensor GND
Pi SCL to sensor SCL
Pi SDA to sensor SDA

Now the rpi has 2x 3V3 and 2x GND to use for both sensors, although only 1x SCL and 1x SDA. I'm pretty sure its somehow possible to connect multiple I2C devices, but I couldn't figure out how yet.

Can I just connect both sensor to the single SCL & SDA pins with a cable?

Or do I need a I2C expansion? If so, how is something like this called and can my sensors connected to the expansion simply be detected using the sudo i2cdetect -y 1 command?

Thanks!

1
  • Do you know if the modules have built in pullup resistors? If not, you need to add your own (between 1.2k and 10k each on the SCL and SDA line). If one does, you're okay. If both do, make sure the value of the resistors in parallel stays above 1.2k or you may break something by drawing too much current during low times.
    – cat40
    Commented Jul 7, 2021 at 23:36

1 Answer 1

6

I2C is a bus system and allows you to connect multiple sensors to the same pins. The master system (the Pi) lets the sensors know who should respond by placing that sensor's address on the bus.

In your case you can connect all the sensors I2C SDA pins to the Pi's SDA pin and all the sensors I2C SCL pins to the Pi's SCL pin.

Note you can also connect all the sensor Vin (+ve) pins to one Pi 3V3 pin and all the sensor ground (-ve) pins to one Pi ground pin.

2
  • Sorry for the dumb question ... but how am I going to connect multiple sensors to the same pin?
    – DottoreM
    Commented Sep 3, 2021 at 15:58
  • You can solder all the wires together. I tend to use breadboards and connect SDA and SCL to their own row which lets me connect 4 devices to each (most breadboards have 5 pins per row). You can daisy chain each devices SDA/SCL to the next.
    – joan
    Commented Sep 3, 2021 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.