Connect more then one I2C devices Arduino Nano

There are 2 dedicated pins for SDA and SCL GPIO (One for SDA and one for SCL) in Arduino nano. how to connect more than one I2C Devices to Arduino nano? Like, I have to connect one I2C OLED display and one BME280 I2C sensor.

Just connect them to the same pins. I2C is a bus, that's how buses work.

Then How to define the pins at the time of coding?

and can you please refer to any book to learn Arduino from beginning to advance?

If you mean that there are 2 pins of each type then you are wrong

@UKHeliBob No, I am not saying that.

That varies slightly depending on exactly which library you are using.

Check the library documentation.

I2c devices have an address as well as the pins they connect to. If you have multiple i2c devices, they connect to the same pins but have different addresses used in the beginTransmission() call (for example.)

Hi @DJSUBHA007
Connect both devices you have to your arduino's I2C pins and then run the I2Cscanner,
https://playground.arduino.cc/Main/I2cScanner/
and you will see on the serial monitor 2 I2C addresses.

1 Like

@DJSUBHA007, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the IDE 1.x category.

You don't define pins if you use the hardware I2C interface as they are the same; you define / use addresses.

1 Like

The worked examples included in the libraries for the relevant devices should give you all you need. You shouldn't need to run a scanner.

With most Arduino, you cannot define the pins, and there is no need to define the pins. On Nano, they are A4 and A5, and they can only be these pins.

Sorry, I do not know what book to recommend. When I came to Arduino, I was already quite familiar with electronics and coding from many years before at university. I only had to learn what was unique to Arduino, which I was able to do from examples and with help from this forum.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.