MMA8452 Accelerometer not working?-Arduino Uno- Cheese cake for the best answer!


Im a noob with a big desire to learn about this world!

With my new project im trying to make this MMA8452Q Accelerometer to work, but i cant!

The output using arduino software is (using serial port COM3 (9600)) nothing but:

“MMA8452Q Test Code!”.

Debugging a little bit i found that the problem is in the line “accel.init();” of the .ino file. It gets stucked there!

There u have my circuit (which has a led cause i thought that maybe the accelerometer was broken and the current wasnt flowing xD).

BTW! My circuit is not using 330 ohm resistors, it uses 100. About the red wire… well haha, its just there to maintain the chip more rigid to the board.

This is the code im using (copied and pasted from a tutorial) (Anyway i will upload the .ino, .cpp and .h files):

SFE_MMA8452Q Library Basic Example Sketch
Jim Lindblom @ SparkFun Electronics
Original Creation Date: June 3, 2014

This sketch uses the SFE_MMA8452Q library to initialize the
accelerometer, and stream values from it.

Hardware hookup:
Arduino --------------- MMA8452Q Breakout
3.3V --------------- 3.3V
GND --------------- GND
SDA (A4) --/330 Ohm/-- SDA
SCL (A5) --/330 Ohm/-- SCL

The MMA8452Q is a 3.3V max sensor, so you’ll need to do some
level-shifting between the Arduino and the breakout. Series
resistors on the SDA and SCL lines should do the trick.

Development environment specifics:
IDE: Arduino 1.0.5
Hardware Platform: Arduino Uno

This code is beerware; if you see me (or any other SparkFun employee) at the
local, and you’ve found our code helpful, please buy us a round!

Distributed as-is; no warranty is given.
#include <Wire.h> // Must include Wire library for I2C
#include <SFE_MMA8452Q.h> // Includes the SFE_MMA8452Q library

// Begin using the library by creating an instance of the MMA8452Q
// class. We’ll call it “accel”. That’s what we’ll reference from
// here on out.
MMA8452Q accel;

// The setup function simply starts serial and initializes the
// accelerometer.
void setup()
Serial.println(“MMA8452Q Test Code!”);

// Choose your adventure! There are a few options when it comes
// to initializing the MMA8452Q:
// 1. Default init. This will set the accelerometer up
// with a full-scale range of +/-2g, and an output data rate
// of 800 Hz (fastest).
// 2. Initialize with FULL-SCALE setting. You can set the scale
// using either SCALE_2G, SCALE_4G, or SCALE_8G as the value.
// That’ll set the scale to +/-2g, 4g, or 8g respectively.
//accel.init(SCALE_4G); // Uncomment this out if you’d like
// 3. Initialize with FULL-SCALE and DATA RATE setting. If you
// want control over how fast your accelerometer produces
// data use one of the following options in the second param:
// ODR_800, ODR_400, ODR_200, ODR_100, ODR_50, ODR_12,
// ODR_6, or ODR_1.
// Sets to 800, 400, 200, 100, 50, 12.5, 6.25, or 1.56 Hz.
//accel.init(SCALE_8G, ODR_6);

// The loop function will simply check for new data from the
// accelerometer and print it out if it’s available.
void loop()
// Use the accel.available() function to wait for new data
// from the accelerometer.
if (accel.available())
// First, use to read the new variables:;

// will update two sets of variables.
// * int’s x, y, and z will store the signed 12-bit values
// read out of the accelerometer.
// * floats cx, cy, and cz will store the calculated
// acceleration from those 12-bit values. These variables
// are in units of g’s.
// Check the two function declarations below for an example
// of how to use these variables.
//printAccels(); // Uncomment to print digital readings

// The library also supports the portrait/landscape detection
// of the MMA8452Q. Check out this function declaration for
// an example of how to use that.

Serial.println(); // Print new line every time.

// The function demonstrates how to use the accel.x, accel.y and
// accel.z variables.
// Before using these variables you must call the
// function!
void printAccels()
Serial.print(accel.x, 3);
Serial.print(accel.y, 3);
Serial.print(accel.z, 3);

// This function demonstrates how to use the,,
// and variables.
// Before using these variables you must call the
// function!
void printCalculatedAccels()
Serial.print(, 3);
Serial.print(, 3);
Serial.print(, 3);

// This function demonstrates how to use the accel.readPL()
// function, which reads the portrait/landscape status of the
// sensor.
void printOrientation()
// accel.readPL() will return a byte containing information
// about the orientation of the sensor. It will be either
byte pl = accel.readPL();
switch (pl)
Serial.print(“Portrait Up”);
Serial.print(“Portrait Down”);
Serial.print(“Landscape Right”);
Serial.print(“Landscape Left”);

SFE_MMA8452Q.h (3.07 KB)

SFE_MMA8452Q.cpp (9.36 KB)

MMA8452Q_Basic.ino (4.87 KB)

Is cheesecake allowed on this forum?


Heeyyy solved!

Im stupid and i didnt solde pins to the accelerometer. I tho it would work without solding, that the contact would be enough hahahaha xD