How to connect multiple I2C sensors/devices with Arduino
I want to connect two, three or more I2C sensors/devices to Arduino (as slave), How can I do it??
Answer
You need to do the following:
- Make sure that each sensor/device should have a unique I2C address to these sensors/devices. In the case of the addresses are duplicate, you need to change I2C address of the sensor/device to make it unique. To change I2C address of a sensor/device, you need to read its datasheet or manual. Manufacturers usually offer one of the follwing ways to change I2C address:
- Changing I2C address via command
- Changing I2C address via a jumper (soldering may required)
- For wiring, you can connect all I2C sensors/devices to the same Arduino I2C pins (SCL, SDA, VCC, GND).
- In the code, you just need to specify the unique I2C address for each sensor/device
To check I2C address of a sensor/device, see How to know I2C address of sensor/device
Buy Arduino
1 × Arduino UNO Buy on Amazon | |
1 × USB 2.0 cable type A/B Buy on Amazon |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.