MMA8451 Accelerometer
Contents
Description
The MMA8451 is a member of the MMA845x family which also includes the MMA8452 and the MMA8453.
The MMA8451 was originally manufactured by Freescale. The Dutch public company, NXP Semiconductors, bought Freescale in a merger that was completed in December 2015.
The MMA8451 is officially a discontinued product but (in 2025) is still stocked by resellers and available in several breakout board designs.
The MMA8451 is described in the datasheet (Page 1) as a smart, low-power, three-axis, capacitive, micromachined accelerometer with 14-bits resolution
.
This accelerometer's typical applications include use in e-compass applications, static orientation detection, tumble and freefall detection in portable devices, virtual reality and 3D gaming, pedometer step counting, motion detection for portable product power saving, shock and vibration monitoring.
The MMA8451 measures acceleration with a capacitive type sensor.
The values in the following table have been sourced from the product datasheet.
| Parameter | DIS3DH |
|---|---|
| Package and size | 16-pin QFN package, footprint 3mm x 3mm x 1mm. |
| Operating voltage range | 1.95V to 3.6V |
| Supply current (typically) [ODR/Oversampling] |
[1.56Hz / Low] : 6µA [800Hz / High] : 165µA Standby: 1.8µA |
| Zero-g level offset accuracy | ±20 mg |
| Measurement ranges | ±2g, ±4g, ±8g Default is ±2g. |
| Output resolution | 14-bit |
| Sensitivity (typically) | 4096 counts/g (±2g) 2048 counts/g ((±4g)) 1024 counts/g (±8g) |
| Output data rate (ODR) | 1.56Hz to 800Hz in 8 programmable steps |
| Serial interfaces | I2C |
Using the MMA8451's I2C Interface
The I2C interface is compliant with both normal mode (100kHz) and fast mode (400kHz). Single byte and multiple byte (burst mode) reading and writing is supported.
I2C addresses
There are two I2C addresses available. They are factory set and depend on whether the SOA pin is held at a Low or High logic level.
- SAO = 0 : 0x1C
- SAO = 1 : 0x1D
Reading MMA8451 registers
There is a very important point to made with respect to reading MMA8451 registers through the I2C interface. This involves how the stop condition is used.
- Master issues a start condition.
- Master writes the 7-bit slave address and adding LSB = 0 for write.
- Slave acknowledges.
- Master writes the slaves's register address.
- Slave acknowledges.
- Master issues a repeat start condition.
- Master writes the 7-bit slave address and adding LSB = 1 for read.
- Slave acknowledges and sends bytes of data. The Master acknowledges each byte received. When the required number of bytes have been received the Master does not acknowledge but instead issues a stop condition to cease transmission.
The point to note here is that if the Master issues a stop condition at the end of Step 4, the Slave will reset the register pointer and the desired register will not be read in the subsequent steps.
This is not usually the case with the I2C interfaces of many other sensors.
Acceleration Sampling Options
This accelerometer has a useful set of sampling options that the user may choose to configure.
Operating modes
-
Standby
Low current consumption mode (typically <2 µA) where data conversions are stopped but the I2C interface is still available. This is the default mode after the power-up sequence has completed. -
Active Mode
This is the normal acceleration measurement mode of the sensor. There are two states to the active mode: active/wake and active/sleep.- Active/sleep
The sensor is in lower power state where conversions are being performed at a lower data rate output. This state can immediately transition to the active/wake state on being triggered by any one of four separate interrupts; tap detection, orientation detection, motion/freefall and transient detection. - Active/wake
This state allows acceleration sampling at higher data rates with subsequent increased power use. Oversampling and low noise configuration can be used for better precision and accuracy.
- Active/sleep
Additional User Selections
-
Acceleration ranges
Ranges available: ±2g, ±4g, ±8g. Default is ±2g. -
Output data rate (ODR)
The output data rate is user selectable from 1.56Hz to 800Hz in eight discrete steps; 1.56, 6.25, 12.5, 50, 100 , 200, 400, 800 (default). -
Oversampling
Oversampling involves extra samples from the sensor being taken then the average is sent to the output. The higher the oversampling, the higher the precision of the acceleration read from the I2C interface. However increased oversampling comes at the cost of higher power consumption.
There are four oversampling modes; Normal, Low Noise Low Power, High Resolution, Low Power. The actual oversampling ratio depends on the OS mode selected and the ODR.
The largest amount of oversampling occurs in OS mode = High Resolution at an ODR = 1.56Hz. With these settings the oversampling ratio is a huge 1024. -
Low Noise
Separate and in addition to oversampling, the MMA8451 has a low noise specific setting that increases precision when active.
Measuring Acceleration
The MMA8451 measures both static and dynamic acceleration. Acceleration is reported in units of g where 1g = 9.81 m/s2 i.e. the acceleration due Earth's gravity.
The raw acceleration value for each axis is read from two 8-bit registers. The two bytes are combined to a single binary 14-bit representation. This is converted from its Two's Complementary format to a signed integer.
This is then scaled by simple division with the divisor being the sensitivity (counts/g). The sensitivity depends upon the measurement range. The float type result is the acceleration value in units of g.
There is a data ready interrupt that is asserted when fresh 3-axis acceleration data becomes available. There are also individual data ready interrupts available for each of the three axis; X, Y and Z.
FIFO Queue
The FIFO is a queue mechanism (First In - First Out) that when activated automatically begins storing datasets of raw 3-axis acceleration values.
The FIFO has the capacity to store 32 samples for each axis. The sample for each axis consists of two bytes. Therefore the FIFO memory size is 2 x 3 x 32 = 192 bytes.
There are several interrupts associated with the FIFO:
- FIFO_WATERMARK : Indicates that the FIFO contains at least a user defined number of samples in the buffer.
- FIFO_OVERRUN : Indicates that the FIFO buffer has overflowed, such that new data is replacing unread data.
These interrupts may be mapped to the INT1 or INT2 pins at the user's discretion.
The FIFO also has a trigger mode. In this mode samples are continually collected till some defined event occurs (such as a tap). When the event is detected the FIFO will retain a given number of samples (referred to as the watermark) collected prior to the event. More samples are collected post-event till the FIFO overflows.
The microcontroller can burst read all samples and perform an event analysis.
The use of the FIFO is not a trivial exercise. If it is to be used the developer should read the NXP application note AN4073 which goes into quite a level of detail and provides several useful pseudocode examples.
Sensor Generated Interrupts
The MMA8451 has a flexible interrupt architecture that can be configured with thresholds and timing values to assist in detecting a variety of scenarios.
All of the interrupts described below, once programmed, can be mapped to either of the two hardware pins INT1 and INT2.
Freefall detection
This involves monitoring al three axis for the condition where the magnitude of all acceleration samples are below a threshold for a configurable amount of time.
Motion detection
This is very flexible. When the accelerations exceed a set of thresholds for a given amount of time the motion interrupt is asserted.
Depending upon the thresholds and timing values different types of motions from a fast moving shake, a slow moving tilt or even a spinning motion can all be individually discerned.
Tap detection
The MMA8451 has embedded logic to detect single taps, double taps and directional taps. The user configurable options including high-pass and low-pass filtering are quite comprehensive.
Orientation detection
An advanced algorithm allows for the detection of all six possible orientations; face-up, face-down, portrait, portrait flipped, landscape left, and landscape right.
MMA8451 Chip ID
During the manufacturing process each chip has an MMA8451 identifier written to non-volatile memory.
The user is able to read this value from the WHO_AM_I register. A genuine MMA8451 will return the value of 0x1A.
MMA8451 MicroPython Driver
An MMA8451 MicroPython driver specifically written for the BBC micro:bit has been developed as part of this series on MicroPython for the micro:bit. The driver webpage also provides a detailed description of the driver's methods and properties with sample code.
The driver implements the base functionality:
- Setting power mode, ODR, measurement range (FS), oversampling and low noise configuration.
- Acceleration readings and data ready status.
- Measuring angles in the X and Y axis.
- Chip ID/identification.
The FIFO and Activity/Orientation interrupts are beyond the scope of this driver.
Inertial Measurement, Magnet Field Sensing
How they work
Weather Station Sensors
How they work
Pressure, Humidity, Temperature
Distance Sensors
Images
MMA8451 breakout board front
MMA8451 breakout board rear
Micrograph of the MMA8451 sensor chip on the breakout board
Low Dropout (LDO) voltage regulator, 3.3V, on MMA8451 breakout board
Pullup resistors (2.2kΩ) on the MMA8451 breakout board
Logic level conversion