Multiple Sensors on Raspberry Pi GPIO

codingCat picture codingCat · Jul 16, 2013 · Viewed 10.1k times · Source

I am working up a sensor package for my PI. I have already added the TMP102 temperature sensor from Sparkfun. On the GPIO it is powered from pin 1, grounded on pin 6, with pin 3 and 5 handling the serial data. I have written a python script to read the data and everything works fine.

My problem is that I now want to add a second sensor to the GPIO, the BMP085 pressure sensor also on a breakout board from Sparkfun. What wiring examples I have found suggest that it needs to hook into the same GPIO pins as the TMP102. They should both register as serial devices, but I am unsure how to wire everything together.

I'm a programmer at heart, so hooking up electronics makes a nervous. :-)

Any suggestions will be greatly appreciated.

Thanks.

Answer

Craig picture Craig · Jul 16, 2013

If your sensors use I2C and it looks like the TMP102 and the BMP085 do, you are in luck.

I2C is designed to have multiple devices sharing the same 2 wire interface. Each device must have a distinct address though so you need to make sure your devices don't conflict. You will have to read the datasheets or other documentation for your sensors to find out how to set the address.

Once you configure the address for each sensor you should be able to connect both devices to the same SDA and SDL pins.