I want to use two I2C devices (DS1307 RTC module and BH1750 light sensor). Because both of them use I2C, I need to connect both to the A4 and the A5 pin. Will they work fine if doing so or do I need to specify them any way in my sketch?
They will be fine. I2C is a bus system which means that you can connect multiple devices to the bus and use the device address to control which one you are communicating with
One thing to look out for is whether the devices have built in pullup resistors for the SDA and SCL lines or whether external resistors are needed
Ok, thanks alot. I'll give an update if external resistors are necessary.
In your IDE, in Examples|wire, you'll find an I2C scanner. There are others available as well. They're great tools for identifying what addresses are in use on your I2C bus. You'll need to know the addresses of your two devices in order to communicate with them.
The I2C bus devices must have differing 7-bit Slave Addressees.
There should be no problem so long as the device addresses are different - which is almost certainly the case. RTC is 0x68. I think BH1750 might be hidden in the library. I bet you don't need to look for it.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.