0

This question already has an answer here:

I am trying to use four of the same accelerometer on the same bus and acquire data from each of them using an SD card. Because I am using four of the same accelerometer I need to be able to differentiate between them and I dont know how to find their specific address. I need the specific address so I can tell my arduino which accelerometer to pull data from. essentially it would pull data from 1 then 2 then 3 then 4 and loop back to 1.

marked as duplicate by gre_gor, Code Gorilla, Enric Blanco, Greenonline, KIIV Jun 22 '17 at 19:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You can't have 4 of those on one bus. The maximum is 2.

The pin SA0 defines the least significant bit of the I2C address. From the datasheet:

7 | SA0 | I2C least significant bit of the device I2C address, I2C 7-bit address = 0x1C (SA0 = 0), 0x1D (SA0 = 1).

In fact, as it states on the Adafruit website (if you'd care to read it sometime):

A is the I2C Address select pin. By default this is pulled down to ground with a 10K resistor, for an I2C address of 0x1C. You can also connect it to the 3Vo pin for an address of 0x1D

If you want more than 2 you will either have to have multiple I2C busses or use an I2C multiplexer (such as this one) to select different branches on the same bus.

  • Majenko, didn't you know ? The method in the link provided by @gre_gor has been tested and is working for a MPU-6050. It might work for a MMA8451 as well. All the sensors should be kept at 0x1D, en only one to 0x1C to control that one. Since the MMA8451 can not handle 5V signals, the signals to the SA0 pin must be lowered to 3.3V signals (to switch the I2C address). Another option is to use software I2C, perhaps even with a shared SCL pin and with seperate SDA pins for each sensor. – Jot Jun 21 '17 at 20:36
  • That's an interesting concept. As long as the chip can change is address realtime like that it could work. If it reads the pin at power on only then it won't. Give it a go, it may work. If not you'll need a second bus or multiplexer. – Majenko Jun 22 '17 at 7:52
0

Power them on one at a time. They don't take much current to run so a GPIO pin would be more than sufficient.

  • A I2C device that is powered down pulls down the SCL and SDA, making the I2C no longer useable for others. – Jot Jun 22 '17 at 11:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.