Skip to content

MMA8452q Accelerometer


L2 Sensor




The MMA8452Q accelerometer is a device that communicates using the I2C communication protocol. It can be read from and written to through the I2C communication line with the SJTwo microcontroller.

The MMA452Q communicates over I2C.


The purpose of the accelerometer driver is to allow any microcontroller to communicate with an accelerometer like the MM8452Q. At the base, the driver obtains data of the X, Y, and Z axes independently. In addition, the driver includes processing sensor data to determine device pitch and roll.

Detailed Design


  1. Run initialization function from the I2C class.
  2. Check the "WHO_AM_I" register to ensure that communication is working properly and return the status.

Obtaining Data from Sensor

Data is obtained from the sensor by using the WriteThenRead() method from the I2C class. This function writes the appropriate register address into the acceleration sensor and then reads back the next 16 bits from the slave. Since data from the sensor is only 12 bits, the value returned from the sensor is divided by 16 to remove this offset and maintain the polarity. Furthermore, the pitch and roll functions fetch relevant axis values through the get functions for calculations.

Configuring the Sensor

The full scale range of the sensor can be configured through the "CFG" register. The user is given the option of setting the full scale range to 2G, 4G, or 8G.



Future Advancements


Testing Plan

Unit Testing Scheme

Integration Testing

The accelerometer driver will be tested with the I2C driver of the SJOne board until one is developed for the SJTwo board. When that happens, this driver will be ported over.

Demonstration Project

During demonstration, the driver should be able to successfully fetch sensor data, utilize the data in the functions, and configure the sensitivity settings. The demonstration should also yield results consistent with the specifications given in the datasheet.