Creative Commons images are CC BY-NC-SA 3.0


SparkFun Triple Axis Accelerometer Breakout - MMA8452Q
project on
hackster.io project

Ship IoT with the TI CC3100 and Google Sheets
by Mark Easley

Description: This breakout board makes it easy to use the tiny MMA8452Q accelerometer in your project. The MMA8452Q is a smart low-power, three-axis, capacitive MEMS accelerometer with 12 bits of resolution. This accelerometer is packed with embedded functions with flexible user programmable options, configurable to two interrupt pins. Embedded interrupt functions allow for overall power savings relieving the host processor from continuously polling data.

The MMA8452Q has user selectable full scales of ±2g/±4g/±8g with high pass filtered data as well as non filtered data available real-time. The device can be configured to generate inertial wake-up interrupt signals from any combination of the configurable embedded functions allowing the MMA8452Q to monitor events and remain in a low power mode during periods of inactivity.

This board breaks out the ground, power, I2C and two external interrupt pins.

Not sure which accelerometer is right for you? Our Accelerometer and Gyro Buying Guide might help!

Note: If you are looking for the SparkFun Triple Axis Accelerometer Breakout with headers, it can be found here or in the Recommended Products below.

Get Started with the MMA8452Q Breakout Hookup Guide

Features:

  • 1.95 V to 3.6 V supply voltage
  • 1.6 V to 3.6 V interface voltage
  • ±2g/±4g/±8g dynamically selectable full-scale
  • Output Data Rates (ODR) from 1.56 Hz to 800 Hz
  • 12-bit and 8-bit digital output
  • I2C digital output interface (operates to 2.25 MHz with 4.7 kΩ pullup)
  • Two programmable interrupt pins for six interrupt sources
  • Three embedded channels of motion detection
  • Orientation (Portrait/Landscape) detection with set hysteresis
  • High Pass Filter Data available real-time
  • Current Consumption: 6 μA – 165 μA

Documents:

Recommended Products

Customer Comments

  • Where can I find the board specs (size, holes, etc) [Mechanical Drawings]

  • Can two of these be used on the same i2c bus?

    • Yes, they will need different addresses, but there is a jumper on the back of the board to change the address.

  • FYI, the comment on the schematic that says SA0 = 0 by default is wrong. With the jumper open SA0 = 1, making the default address 0x1d.

  • The library was designed for the Arduino UNO development board so there can be some issues with libraries if you are trying to port it to another microcontroller. If you see this error output when trying to upload to an ESP8266 through the Arduino IDE, this is due to the fact that the MMA8452Q’s library is using a variable that is already used by the ESP8266 core:

    Arduino: 1.6.4 (Windows 7), Board: "SparkFun ESP8266 Thing, 80 MHz, 115200, 4M (3M SPIFFS)"
    
    In file included from SparkFun_MMA8452Q_Basic.ino:34:0:
    C:\Users\bobby.chan\Documents\Arduino\libraries\SparkFun_MMA8452Q/SparkFun_MMA8452Q.h:32:11: error: 'STATUS' redeclared as different kind of symbol
    STATUS = 0x00,
           ^
    In file included from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697/tools/sdk/include/ets_sys.h:11:0,
                 from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/pgmspace.h:9,
                 from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/WString.h:29,
                 from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/Print.h:26,
                 from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/Stream.h:26,
                 from C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697\libraries\Wire/Wire.h:28,
                 from SparkFun_MMA8452Q_Basic.ino:33:
    C:\Users\...\AppData\Roaming\Arduino15\packages\SparkFun\hardware\esp8266\1.6.4-673-g8cd3697/tools/sdk/include/c_types.h:58:3: error: previous declaration of 'typedef enum STATUS STATUS'
     } STATUS;
       ^
    Error compiling.
    

    Try modifying the MMA8452Q’s library by changing the variable name with a text editor by :

    changing STATUS to STATUS_M in the file SparkFun_MMA8452Q.cpp on line 95

    changing STATUS to STATUS_M in the file SparkFun_MMA8452Q.h on line 32

  • I’m surprised that no one has mentioned this, but from the I2C module description in the datasheet (5.10.1):

    The MMA8452Q expects repeated STARTs to be used to randomly read from specific registers.

    Unfortunately it seems that BCM2835 (RaspberryPi’s SoC) does not support repeated START sequence. This means that this accelerometer is not compatible with the I²C bus on RaspberryPi.

    More information in the link here.

  • I am using the MMA8452Q Triple Axis Accelerometer Breakout on a breadboard circuit that is connected to a mini-Bully PIC24HJ64GP502 (no longer sold by Spark Fun) to detect motion of the board. As long as my MMA8452Q is situated in a horizontal plane when I download its code from the PIC24 microcontroller, it seems to work fine (i.e., the I1 pin outputs a 3.3 volt signal when the breadboard is moved, and it outputs zero volts when motionless). However, if the MMA8452Q is not situated in a horizontal plane during downloading of its code, it does not function appropriately (i.e., the I1 pin constantly outputs 3.3 volts whether there is motion of the breadboard or not). This is important because my application circuit will eventually be connected to my wrist when first activated, and then worn throughout the night while I sleep (I just need to know when motion occurs, not any of the characteristics of the motion).

    I have set the MMA8452Q’s registers thus:

    write2I2C1(MMA8452Q_ADDR, FF_MT_CFG, 0x78); // ELE=0, OAE=1, ZEFE=1, YEFE=1, XEFE=1 write2I2C1(MMA8452Q_ADDR, FF_MT_THS, 0x8F); // DBCNTM=1, THS[6:0]=15 threshold=(15)x(0.063g)=0.945g write2I2C1(MMA8452Q_ADDR, FF_MT_COUNT, 0xFF); // 0xFF=255(decimal), ODR=800Hz, debounce time=(1.25/1000)x(255)=0.319 second write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x04); // ODR=800HZ, LNOISE=1, F_READ=0, ACTIVE=0 (STANDBY mode) write2I2C1(MMA8452Q_ADDR, CTRL_REG2, 0x00); // disable SELF TEST, disable RESET, OVERSAMPLING MODE (Normal), disable auto-SLEEP write2I2C1(MMA8452Q_ADDR, CTRL_REG3, 0x08); // enable FF_MT wake up, IPOL=0(interrupt polarity=active low), enable PUSH PULL write2I2C1(MMA8452Q_ADDR, CTRL_REG4, 0x04); // disable auto SLEEP/WAKE interrupt, enable FF_MT interrupt write2I2C1(MMA8452Q_ADDR, CTRL_REG5, 0x04); // FF_MT interrupt output signal assigned to INT1 pin of MMA8452Q write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x05); // now place MMA8452Q (accelerometer) in ACTIVE mode to detect motion

    Can anyone advise me as to how to get the MMA8452Q to work properly no matter its spatial orientation when initially programmed by the microcontroller?

    Thanks

  • Hi, I just two two of this module and it work well, so I was looking at the datasheet and it got no way recommended layout footprint for this component MMA8452Q. Could you share the library of this component for me or any recommended layout footprint?

  • Does the Breakout Board come with the MMA8452Q Accelerometer already soldered to it? Or do I need to purchase the accelerometer along with the board?

    • It comes with it soldered on it. We make it explicitly clear if the sensor is not included on the breakout board.

  • What is the purpose of I1 and I2? Interupting the board to send data? Seems strange if you need repeated START’S to read the data…

  • Where is the sketch located from the simple sketch video above?

  • Anyone know if these are affected by magnetic fields? I have a couple of ideas for projects using digital accelerometers where the easiest attachment method would be a magnet to hold it on the steel structure (to measure the variance from horizontal – and with an expected change on one of them to be on the order of 10 degrees/hour, a gyro is inappropriate).

  • What are the dimensions of this board? I can’t seem to find it on the page or in any of the included documents.

  • What is the difference between this and SEN-10955? https://www.sparkfun.com/products/10955

    • The component footprints got larger for easier QC. It’s a hard to see change small but if you open two tabs and click between them you’ll see the footprints got larger. We used to use a very tight footprint for our 0603 parts. This worked great for years but as our production got more complex we needed AOI (automated optical inspection). For the best possible testing we increased the footprints so that the AOI could see and rate a full solder fillet.

      • That’s really cool. I’ll take a slightly larger footprint as a trade for good automated QA inspection.

Customer Reviews

4.5 out of 5

Based on 6 ratings:

5 star
3
4 star
3
3 star
0
2 star
0
1 star
0

Works as expected!

Accelerometer works great!


0 of 1 found this helpful:

still struggling with MMA8452Q

First, Sparkfun is amazing ! I use a PICAXE 14M2. I found some helpful code on PICAXE FORUM. But my HI2CIN instruction does not bring in data from my accelerometer. I have had good luck with I2C protocol until I tried this device for use with my QUAD and also another device T5403 barometric pressure sensor. But I have not given up on these while I’m pursuing other approaches for my experimental QUAD. Note that I bypass RC and speak to QUAD directly from my micro-controller.


Easy to use

Easy to find libs and code examples. Works as expected.


This is awesome!

I love this device. I’m completing a security system within intrusion sensors based on this device, and I am quite impressed. There are many interrupt functions that allow this to be used in low-power battery applications. I’m currently using this with a Moteino, and when the circuit is asleep, the entire system consumes roughly 30uA! The accelerometer interrupts are what make this possible. For those interested, I’ve expanded on Sparkfun’s library here:

https://github.com/mattmunee/MMA8452Q_Arduino_Library

It’s a work in progress, but it now has code for using ALL of the interrupt functionality.


Works easily with the Teensy 3.1

I found that setup was easy, and the I2C connection worked out-of-the-box, with the example program. I found it easy to incorporate into my project. 10 minutes soldering to add the pins 20 minutes of software learning inside the Arduino/Teensyduino environment Done.


Related Tutorials

Blynk Board Washer/Dryer Alarm

March 31, 2016

How to configure the Blynk Board and app to notify you when your washer or dryer is done shaking.