MMA8452 Accelerometer - no readings?

Hi everyone,

Im working on a project to prevent bad posture, but I got some trouble with my two MMA8452 accelerometers. I have imported this library (Library) and I'm trying to make the example work (Example code), but I don't get any readings. The line "MMA8452Q Test Code!" is printed in my serial.monitor and that is it. I have had a look into the code, and I figured out that it can't perform line 53, accel.init();, it simply just stops. I have tried to import other libraries, used other example codes and been writing my own code, but nothing works.

Hope you can help me out..

Regards Mads R. Svendsen,

I have attached a photo of the setup.

And I have seen and read the other posts on this forum concerning the same type of sensor. However, I could not find an answer to my problem :confused:

How did you determine the program stopped at line 53?
Did you try inserting some "debugging prints"?

Like:

void loop()
{
Serial.println("got this far...");

klubfingers:
How did you determine the program stopped at line 53?
Did you try inserting some "debugging prints"?

Like:

void loop()
{
Serial.println("got this far...");

Yes.. Just before line 53 (line 46), there is a Serial.print and I added one just after. That's how i figured it out.

Are those 22K resistors in series with the I2C lines? Why are the I2C lines not connected directly to the MMA8452 board like they should be?

Remove the resistors and connect the SDA and SCL lines directly from the Uno to the board.

edit: That is if the MMA8452 board has a I2C logic level converter. If not, you will need to get one. The max voltage the inputs will take is 3.6v, and the logic level on the Uno is 5v.

That is a Sparkfun unit. You will need a logic level converter.

Here is a logic level converter by Sparkfun.

First of all, thanks for the answers Klubfingers and SurferTim :slight_smile:

It was meant to be two 330 resistors, but you are right, it is 22K, which might be the problem. And they are not in line with I2C, but with the SDA and SCL. I have not used the I2C. I did the connection based on this webpage

I have done a bit of searching the internet to figure out if the MMA8452 accelerometer has a logic level converter, and I found a discussion on the topic, that concluded that I dont need one, as long as I use the 3.3V output on the arduino board.

So I guess I can do as you suggest but with the 3.3V instead of the 5V?

And they are not in line with I2C, but with the SDA and SCL.

SDA and SCL are the I2C lines.

I have done a bit of searching the internet to figure out if the MMA8452 accelerometer has a logic level converter, and I
found a discussion on the topic, that concluded that I dont need one, as long as I use the 3.3V output on the arduino board.

I did not need to do any real searching, except to find your breakout board. This one. It does not have a logic level converter.

This is from the "Features" on that page: 1.6 V to 3.6 V interface voltage
The datasheet states the same thing on the first page under "Features".
http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf

You are not required to follow the datasheet specs on any device, but if it doesn't work, then maybe you should have followed them.

Looks like you have the series resistors right, just wrong value, should be 330R, but I think you still need pullups on SDA & SCL (4k7) unless that is automatically done internally by the I2C library (Wire). I don't know.

Peruse this:

Thanks a lot for the answers :slight_smile:

The sensors are now working perfectly giving me some real good data-sets.

Regards Mads R. Svendsen,

I just spend whole night fighting with it.

I have a GY-45 MMA8452 accelerometer and my model do have an I2C logic level converter. I have no idea why I couldn't see the data. After wiring, rewiring and using different libraries I managed to get it to work. In the end, I am back to basic where I started. Sort of. My OLED is working and MMA8452 is working. Now I need to feed the data to the screen and do some calculations on it.

The library that I am using.
SparkFun_MMA8452Q_Arduino_Library