need to use 4 accellerometers with I2C

Hi all!
I need to record data from 4 accellerometers (board: whatever Arduino board is good).

I have some little experience with analog accellerometer (where I measure x y z through 3 analog pins),
and with accellerometer using I2C (where I read data from SDA and SCL pins, namely analog pin A5, A4 on Arduino UNO);

Now the question is: what approach do you suggest? I think analog accellerometers are not reasonable (too much pins involved).
Is it possible to use different I2C devices?
Can you suggest some tutorials about it?
thanks a lot!
Valerio

An I2C device has an address. Two identical devices will have the same address so they will not work on one I2C bus. Most of the chips you can buy have extra pins that will allow small changes in the addresses. This is how you make 4 copies of the same device work together.

Which accelerometer do you want to use?

I have to decide which model to use, do you have any advice?
I was looking in

Adafruit:

sparkfun:

https://www.sparkfun.com/search/results?term=accelerometer

robotitaly:

Just to know: once I change the addresses of my four devices, how do I connect them to Arduino?
In my poor experience I connected a single I2C device to A4 and A5 pins.
Where are supposed to be connected the further devices?
Thanks!

Please, do you have any model to suggest?

I found this:
MMA8452Q

but as I can understand here

https://learn.sparkfun.com/tutorials/mma8452q-accelerometer-breakout-hookup-guide/example-code

and here

https://learn.sparkfun.com/tutorials/mma8452q-accelerometer-breakout-hookup-guide/hardware-overview#address_jumper

in this model I can switch only between 2 addresses, while I need 4 addresses!
Thanks, Valerio

Even If an I2C-device only has 1 address, you can still controll many of 'm. Using an analog multiplexer, you can choose which specific slave to talk to.

http://forum.arduino.cc/index.php?topic=21794.0

in this model I can switch only between 2 addresses, while I need 4 addresses!

If you can switch addresses with an I/O pin, you need only two. Just make sure that three of the devices have the "wrong" address, and talk to the one with the "right" address.

Yea.
It is clear to me the theory. My problem is that, as far as now, I only found I2C accelerometers where I can select two address only!
For example, the model MMA8452Q:

in this tutorial

https://learn.sparkfun.com/tutorials/mma8452q-accelerometer-breakout-hookup-guide/hardware-overview#address_jumper

is explained that, through a solder on SA0, I can chose between address 0x1C or 0x1D, the only two "right address"

As far as now, I did'nt find I2C accelerometers where I can select four (or more) different address.
About the proposed solution using multiplexer: yea, I can surely use it but in this case...what is the advantage of I2C? If I use a multiplexer I can use an analog accelerometer, non need of I2C.
thanks!

UPDATE:
I'm thinking a possible solutions is to use accellerometers with SPI
interface, for example ADXL362.
I see in this tutorial
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi
that it should be simple to daisy chain more than one slaves.

through a solder on SA0, I can chose between address 0x1C or 0x1D, the only two "right address"

Don't use solder on SA0, use an I/O pin from the Arduino.

mmm I'm not sure I understood. Please tell me if this is your idea.
You propose:

  • to initialise in the code all the 4 accelerometers with the same "right" address, for example 0x1D
  • then, connect 4 different I/O pins from arduino, to SA0 in each accelerometer, so that I can change (from code) the address of 3 accelerometers to "wrong" address (0x1C).
  • query in a loop cycle only the "right address".

Is it correct?

Exactly, but it is a very old idea. Treat the SA0 line as another "chip select".

Hi,
What is the application that needs 4 separate accelerometers?

Tom..... :slight_smile:

Hi, I'm working on an experiment with infants. We need to record movements from 4 limbs.
Valerio :o

valerio_sperati:
About the proposed solution using multiplexer: yea, I can surely use it but in this case...what is the advantage of I2C? If I use a multiplexer I can use an analog accelerometer, non need of I2C.
thanks!

You can indeed use other accelerometers as well, main reason for mentioning a multiplxer is the number of arduino-pins used. Using analog meters you'll need 4 x 3 pins, using SPI you'll need 3 + 4 CS-pins.
I2C + Multiplexer could, in your case, already be done with 3 pins.

valerio_sperati:
Hi, I'm working on an experiment with infants. We need to record movements from 4 limbs.
Valerio :o

Maybe a more accurate and less mind boggling and time consuming method?

Simpson_Jr:
You can indeed use other accelerometers as well, main reason for mentioning a multiplxer is the number of arduino-pins used. Using analog meters you'll need 4 x 3 pins, using SPI you'll need 3 + 4 CS-pins.
I2C + Multiplexer could, in your case, already be done with 3 pins.

Yea, I got the point :slight_smile:
Anyway about I2C+Multiplexer, I realised that it is not very clear to me how to connect the parts: can you post some more detailed description? I'm quite newby with I2C and I used a multiplexer (4051) years ago for reading from light sensors. How do I have to combine them?
Thanks a lot !

If you use this circuit and connect the scl/sda lines to your arduino I2C pins, you've got 4 I2C-buses you can choose from on the left side, to park your accelerometers.

You can choose which bus using lines i2c_set_a/b.

If you can set your meters to 2 different addresses, you can connect 2 on the same bus and only need 2 i2c-buses to read 4 of 'm.

One of the control-pins could therefor be connected to ground/5v permanently, while you use the other control-pin to choose which of 2 buses you need.

(EN is included here to control whether chip should function and could be connected to gnd as well.)

One thing to keep in mind while programming using a solution like this, is that I2C is relying on commands/responses. It's important to finish each command properly, before switching to another bus.

Thanks a lot! This is exactly the schema I needed!
Valerio

Have you tested one accelerometer on a wire equal to the length of your longest infant? I2C is quite sensitive to the capacitance of the wires in the cable.

I had problems extending an I2C link to 10cm. I had to rearrange the ribbon cable to put a ground wire between SCL & SCA.

I have run high speed SPI over 3m of ribbon cable with no special precautions.

You can get I2C extender chips which will boost the signal up to 6m.

MorganS:
Have you tested one accelerometer on a wire equal to the length of your longest infant? I2C is quite sensitive to the capacitance of the wires in the cable.

I had problems extending an I2C link to 10cm. I had to rearrange the ribbon cable to put a ground wire between SCL & SCA.

I have run high speed SPI over 3m of ribbon cable with no special precautions.

You can get I2C extender chips which will boost the signal up to 6m.

Thanks for this information! I didn't think about such type of problem.
So do you suggest to use an accelerometer with SPI?
I found this model: ADXL362

could it be ok?

Tanks Valerio

The ADXL362 seems appropriate for the application, given what you've told us so far.