Problem with MMA8452Q Accelorometer

Hi,

I am using MMA8452Q accelerometer along with arduino uno and i am using the MMA8453Q code to operate MMA8452Q.I found that readings are not so accurate and the after 4 to 5 readings the accelorometer is repeating the same value.I dont know what's wrong kindly help me in tracing out the problem.

Thanku very much

Could you run the i2c_scanner, to check if the chip is actually visible on the i2c bus : Arduino Playground - I2cScanner

The link to your sensor is this: NXP® Semiconductors Official Site | NXP Semiconductors

What code are you using ? Please provide a link or the sketch.

Which breakout board are you using ?

Do you use the 3.3V from the Arduino Uno for the sensor ?
Can you upload a photo, so we can see how it is connected ?

Hi,

I am using MMA8452Q breakout board with Arduino Uno.I downloaded the code from below link
http://n0m1.com/2012/02/12/shake-rattle-roll-the-mma8453q-arduino/ --------in that you can see the "download" word highlighted once after you downlaod the library then in that i am using MMA8453_n0m1 datamode.

The connections between the accelorometer and the arduino are made as below
MMA8452 Breakout ------------ Arduino
3.3V --------------------- 3.3V
SDA ----------------------- A4
SCL ----------------------- A5
INT2 ---------------------- D3
INT1 ---------------------- D2
GND ---------------------- GND

My doubt is that *MMA8452Q:Xtrinsic 3-Axis, 12-bit and *MMA8453Q:Xtrinsic 3-Axis, 10-bit Digital accelorometer. So what parameters do i need to vary in the MMA8453Q code to reflect the difference.

Thank u very much

Which breakout board ? Are there pull-up resistors on the breakout board for the i2c-bus ?

The way you connected it, is okay.

The n0m1 code uses it's own i2c library.
That will make things complicated.
You better should have started with a simpler accelerator.

I don't know it the difference between the MMA8453Q and MMA8453 will effect the behavious. You can check the datasheets yourself.

Have a look at Sparkfun : Triple Axis Accelerometer Breakout - MMA8452Q - SEN-10955 - SparkFun Electronics
That code is for the MMA8453Q. Could you try that ?

Read also this: http://arduino.cc/forum/index.php?topic=97468.0

Hi,

I am using the the break board "Triple Axis Accelerometer Breakout - MMA8452Q".Please click on the below link to find more information on the breakout board

Triple Axis Accelerometer Breakout - MMA8452Q - SEN-10955 - SparkFun Electronics?

Thank you

That breakout board has pull-up resistors for the i2c-bus, that's good.

You could run the i2c_scanner : Arduino Playground - I2cScanner
If the i2c_scanner detects the sensor, the connections are good.

After that, try the example code on the Sparkfun page.

Hi,

I am using the following code to work with MMA8452Q accelorometer breakout(Arduino UNO) . The readings are fluctuating even when the accelerometer is not moving. Can you please verify the code and let me know what's the problem.

Thank you very much

accelorometer_gvalue_wire.ino (5.46 KB)

It's hard to look at the code and see exactly what it is doing.

Your sensor is probably a MEMS sensor, and fluctuation is normal.

My problem with Sparkfun code is, that an error is no passed on to higher levels. For example the Wire.endTransmission() function returns a value if something is wrong. But with the code you use, you don't know if something is wrong.

Hi,

When the i2c_scanner code is used then i am getting the output as

I2C Scanner
Scanning...
I2C device found at address 0x1D !
done

When i use the attached code in the previous post then i am getting output as follows ( when the accelerometer is held at a fixed position also there are variations in the readings)

MMA8452 Basic Example
MMA8452Q is online...
0.14 0.60 -6.23
2.76 1.12 9.38
2.80 1.14 9.40
2.78 1.13 9.37
2.78 1.20 9.36
2.82 1.18 9.42
2.80 1.16 9.42
2.76 1.15 9.40
2.78 1.16 9.40
2.81 1.17 9.43
2.80 1.17 9.42
2.84 1.15 9.39
2.79 1.22 9.40
2.80 1.23 9.43
2.78 1.20 9.39
2.83 1.17 9.34
2.77 1.14 9.42

All the values are interms of g. Normally when the accelerometer is not moving then the acceleration should be 0 but here it is showing some value. Can you please tell me why is it so?

Thank you

I don't know that sensor, but...

The first reading is not valid. I have had that with other sensors.

The variations are not that bad. For the raw values of a MEMS sensor, they look just fine.
You should have some low-pass filter or averaging.
If I place an accelleration sensor on my wooden table (with also the computer on it) I get more variations, although I can't feel any vibration of the computer, but the sensor does. See the conditions and variations of my measurements with this sensor : Arduino Playground - MPU-6050

If the sensor is not factory calibrated, you have to take care of the offset.

If an acceleration sensor is placed flat, the z-axis (pointing up) would normally be 1g, because it measures the earth gravity. In your case it is almost 10g. Is there a factor 10 somewhere ?

Suppose there is a factor 10 in the code, then all you have to do is correct that and get rid of the offset in software and use the average of a few samples.

I am also having real problems with this accelerometer. I am using it on a micro and the code will run for between 5 and 20 seconds and then stop, the TX light goes out and the serial window stops displaying new values. The code is attached.

I have connected the breakout as per instructions, and attached SDA/SCL as given here:

I have also tried the i2c scanner code which shows the device okay. Any ideas? Perhaps someone can suggest an alternative device which they know works well with a micro and is reliable. I need to use the micro for space considerations, so a larger board won't do.

MMA8452Q_tester.ino (5.6 KB)

I did all the previous plug and code, but the Serial Monitor Only shows

I2C Scanner
Scanning...
No I2C devices found

I2C Scanner
Scanning...
No I2C devices found...

Any clue?

Thx

jahnavi:
Hi,

When the i2c_scanner code is used then i am getting the output as

I2C Scanner
Scanning...
I2C device found at address 0x1D !
done

When i use the attached code in the previous post then i am getting output as follows ( when the accelerometer is held at a fixed position also there are variations in the readings)

MMA8452 Basic Example
MMA8452Q is online...
0.14 0.60 -6.23
2.76 1.12 9.38
2.80 1.14 9.40
2.78 1.13 9.37
2.78 1.20 9.36
2.82 1.18 9.42
2.80 1.16 9.42
2.76 1.15 9.40
2.78 1.16 9.40
2.81 1.17 9.43
2.80 1.17 9.42
2.84 1.15 9.39
2.79 1.22 9.40
2.80 1.23 9.43
2.78 1.20 9.39
2.83 1.17 9.34
2.77 1.14 9.42

All the values are interms of g. Normally when the accelerometer is not moving then the acceleration should be 0 but here it is showing some value. Can you please tell me why is it so?

Thank you

Krodal:
It's hard to look at the code and see exactly what it is doing.

Your sensor is probably a MEMS sensor, and fluctuation is normal.
MEMS - Wikipedia

My problem with Sparkfun code is, that an error is no passed on to higher levels. For example the Wire.endTransmission() function returns a value if something is wrong. But with the code you use, you don't know if something is wrong.

Try shaking the device and see if the numbers change.

I suspect it is working OK but the numbers are not scaled the way you expect.

I know that this is an old thread, but I thought it would be worth clearing up the questionable output data.

Reviewing the code jahnavi was using, it's clear that Nate from SparkFun was thinking in terms of m/s2, that is to say, meters per second. On line 52, the acceleration is converted from units of G to units of m/s2. This is a pretty typical unit for measuring acceleration due to gravity.

So, the results jahnavi got with the sketch are not all that unreasonable. The vertical axis seems to hover around 9.4 m/s2, which is only 4% deviation from an expected 9.8 m/s2. The other two measurements are a little harder to explain. It could be due to lack of calibration, or setting the Accelerometer on an uneven surface.

I hope that my revival of this thread can help somebody! Thanks