I had an Accelerometer (adxl345) and a UNO Arduino. I connected the sensor via I2C and using Wire library (Wire.h) and finally got answer.
I know Device Address for adxl345 is "0x53".
now, I want to connect two or tree Accelerometers by I2C, how can I do it? I think because of readable device ID register, I can't connect more than one adxl345.
The SDO pin can be used for a different I2C address.
So you can have two of them on the I2C bus.
Three is not possible. They react to their I2C address. Only one device can have that I2C address.
You can use I2C multiplexer (mux) chips. Some create 4 new I2C busses.
Perhaps you could use a chip select to turn them on and off, but that often doesn't work.
You can also use a 74HC... chip to create a mux with it.
Erdin:
The SDO pin can be used for a different I2C address.
So you can have two of them on the I2C bus.
Three is not possible. They react to their I2C address. Only one device can have that I2C address.
You can use I2C multiplexer (mux) chips. Some create 4 new I2C busses.
Perhaps you could use a chip select to turn them on and off, but that often doesn't work.
You can also use a 74HC... chip to create a mux with it.
Thank you dear Erdin for your help.
So, I try to use I2C MUX like this:
kowalski:
According to the ADXL345 datasheet, http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf, you can use at most two devices on an I2C bus (without mux). See page 18. Instead of a mux you could use additional pins on the Arduino for a SoftTWI bus.
Last, you can connect more modules on an SPI bus as a chip select pin is then used.
Cheers!
aha, thank you.
according to datasheet, 0x1D is 1st address and by Alt address we will have 0x53 and based on that we can use two ADXL345 s in one I2C.
And based on your suggestion, I can use chip select pin in SPI mode and use OR gates for multiple ADXL345 (I see more details in page 15 of data sheet). thank you.