2
\$\begingroup\$

I'm using this cheap ADXL chip with Arduino Uno. When I read the sensor with I2C - it works fine. However I have some servo motors as well which generate a lot of noise and when I turn the motors on, the sensor readings become pretty much useless.

I read that SPI is much more immune to noise, so I decided to go this way. However I just cannot get it to work with SPI. I'm using this code, which seems to work for other people: https://www.sparkfun.com/tutorials/240

I triple checked the wirings, they seems ok to me, tried with and without level shifter, tried hooking up various pull-up resistors... and still I get just zeroes. Yet I2C works just fine (without any pull-ups).

I'm wondering since the Sparkfun code uses a different breakout board for the ADXL chip - could it be that mine needs some specific pull-ups, that are not mentioned in that tutorial? How can I know what pull-ups need to be placed?

And any other suggestions will be much appreciated!

\$\endgroup\$
  • \$\begingroup\$ I'm using the same module as you did but getting strange output. 56, -47, -93 is what I get when stationary and flat. What figures do you get? \$\endgroup\$ – Kar May 3 '15 at 16:22
3
\$\begingroup\$

You should read the datasheet for the part to double check your connections. You should not be having any pullups for SPI communication.

Regarding being unable to communicate via I2C when motors are on - how long are your I2C wires? Trying to lower the resistance of I2C pullups might help.

In general you can try to remedy this situation by adding bigger caps near microcontroller/accelerometer power supply or even adding a small (~10 ohm or less) series resistor and a cap on Vcc that goes to noise sensitive part.

Read up on star grounding and powering techniques, it is possible you could solve your problem by just reconnecting wires in "star" manner.

\$\endgroup\$
0
\$\begingroup\$

UPDATE: eventually it turned out the "noise" in the readings was due to the mechanical vibrations that the motors cause. It's not because of i2c or spi or other wirings.

The accelerometers goes completely crazy when put to mechanical vibrations and this seems to be how all of them work. That's why you need to combine accelerometer with a gyroscope - the gyro doesn't get messed due to vibrations, however it accumulates an error over time. So both devices have one problem and by combining them together - each device fixes the other device's problem and you get an accurate reading :)

\$\endgroup\$
  • 1
    \$\begingroup\$ Yep, you are touching upon one of the basic applications of sensor fusion. If you want to learn more check this video out: youtube.com/watch?v=C7JQ7Rpwn2k Its for Android, but pretty much applicable to sensor fusion in general. \$\endgroup\$ – Michael Choi Nov 26 '14 at 21:17
0
\$\begingroup\$

Be aware that there a two different kind of ADXL345 (like described in http://wei48221.blogspot.de/2015/06/how-to-use-adxl345-triple-axis.html)... one from sparkfun and the other one you get from ebay(etc.) They both look more or less the same but only that one from sparkfun works with i2c and spi... that one from ebay only works with i2c

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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