Hi, me and a friend are working on a project using an Arduino NANO. We are using a few components which includes two which both need SCL / SDA connection.
We concluded that they could not both be simultaneously connected to the Arduino's A5 and A4 pins, so I was wondering if I could use the other analog pins (i.e. A3 & A2) as a second set of SCL / SDA? Or is there a simpler and better solution to this issue?
SCL/SDA are the pins of the I2C connection. I2C is a bus system where each component is selected by a unique address. As long as these addresses are set differently, several components can be connected to SCL/SDA and accessed individually.
Thank you! That helps a lot, how would you actually set adresses for components that are simultaneously connected to the same SDA / SCL pins?
Generally speaking, you don't set them. Each component will have a fixed address (or sometimes a small number of possible addresses that you can set by connecting certain pins on the device).
If you use another Arduino as an i²c slave device, you can choose any address you like, other than the addresses of any other devices on the bus.
This is true if the two devices are the same, or by chance happen to have the same address.
If these devices have one or more "ADDR" pins, you will be able to change the address of one of the devices so they no longer clash.
If the devices have no ADDR pins, then you may be able to use other Arduino pins to make a second i²c bus using a software library, or by using an i²c multiplexer chip.
What devices are you planning to connect to i²c?
We are planning on using an accelerometer and a gyroscope, the gyroscope does have a DRDY pin but I havent found a use for that yet.
The accelerometer and gyroscope will almost certainly have different, fixed addresses. You will probably not need to use the DRDY pin. (The DRDY pin does not change the address of the device.)
If you have not purchased these devices yet, you can buy combined accelerometer+gyroscope devices, some have magnetometer also.
Just curious what made you draw that conclusion?
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 See About the IDE 1.x category.
Very good question.
Are we ever going to fix this problem?
Hi, we made that conclusion because we haven't had to do it like this before and it seemed a little counter intuitive to connect them to the same pins at the same time.
Still, I dont fully understand exactly how I would use an address to speak to a certain module with I2C (or SPI?).
I2C and SPI are very different in this respect. Usually you use the wire library to talk to I2C devices ( or a device specific library that internally uses the wire lib ). The methods or constructors of these libraries allow you to specify the device address.
In the case of I²C, it is called a "BUS" and that is the whole purpose of the interface, to connect many devices together.
You know (from the datasheet) the address of the device, and the function call that "talks" to it includes the specification of the address. Mostly (almost always) you will use a library for this.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.