Accelerometers

MEMS sensor basics, I2C interface.

Darshan N
Updated: 19 March 2026
8 min read

An accelerometer is a sensor that measures proper acceleration, meaning the acceleration experienced by a body relative to freefall. In embedded systems, accelerometers are used for tilt sensing, vibration monitoring, fall detection, and inertial navigation. Modern accelerometers are built using MEMS (Micro-Electro-Mechanical Systems) technology and communicate with microcontrollers primarily through I2C or SPI interfaces.

MEMS Accelerometer System OverviewMEMS StructureProof mass on springCapacitive sensingSignal ConditionerCharge amplifierAnti-alias filterADC + DSP Core12-16 bit ADCDigital filter / FIFOI2C / SPI Digital InterfaceSCL, SDA (I2C) or SCK, MOSI, MISO, CS (SPI)MicrocontrollerReads X, Y, Z acceleration dataCommon ICsMPU-6050 (I2C)ADXL345 (SPI/I2C)Key ParametersRange: ±2g to ±16gSensitivity: LSB/g valueAt rest flat on table: X=0g, Y=0g, Z=+1g (earth gravity). Tilt changes X and Y values.
Figure 1: MEMS accelerometer system block diagram showing internal structure, digital interface, and microcontroller connection

Core Concept Explanation

MEMS accelerometers work on the principle of a microscopic proof mass suspended by tiny silicon springs etched onto a silicon wafer. When the sensor accelerates, the proof mass tends to remain stationary due to inertia while the surrounding structure moves. This relative displacement between the proof mass and fixed electrodes changes the capacitance of small interdigitated capacitor structures. The measured capacitance change is proportional to the acceleration.

The internal signal chain converts this capacitance change into a digital value. A charge amplifier converts charge to voltage, an anti-aliasing filter limits bandwidth, and a high-resolution ADC (typically 12 to 16 bits) digitizes the signal. The DSP core applies digital filtering and formats the output as signed integer values corresponding to acceleration in each of the three axes (X, Y, Z).

The output data is accessed through I2C or SPI. For I2C, the accelerometer has a 7-bit device address (e.g., 0x68 or 0x69 for MPU-6050, selectable via the AD0 pin). The microcontroller initiates a read transaction by sending the device address and the register address of the acceleration data, then reads the returned bytes. Each axis produces a 16-bit signed integer from two consecutive registers (HIGH byte and LOW byte).

Mathematical Expression

The raw digital output from the accelerometer register is a signed 16-bit integer. To convert this to physical acceleration in g (where 1g = 9.81 m/s²), it must be divided by the sensitivity of the sensor in LSB/g. Sensitivity depends on the selected measurement range. For the ADXL345, sensitivity is 256 LSB/g at ±2g range, 128 LSB/g at ±4g, 64 LSB/g at ±8g, and 32 LSB/g at ±16g.

The formula is: Acceleration (g) = Raw_Value / Sensitivity. For the MPU-6050, the sensitivity at ±2g range is 16384 LSB/g. So an output of 8192 from the Z-axis register means 8192 / 16384 = 0.5g. At rest with the sensor horizontal, the Z-axis should read approximately 16384 (representing 1g from gravity), and X and Y should be near 0.

Practical Understanding

Initializing the MPU-6050 over I2C requires writing to its power management register (register 0x6B) to wake the device from sleep mode. By default the MPU-6050 starts in sleep mode to save power. Writing 0x00 to register 0x6B wakes it up. The accelerometer full-scale range is set in register 0x1C. Reading acceleration data requires reading 6 consecutive bytes starting from register 0x3B (ACCEL_XOUT_H).

The I2C communication protocol uses two wires: SCL (serial clock) and SDA (serial data). The microcontroller is always the master and the accelerometer is the slave. Pull-up resistors (typically 4.7k ohms) are required on both SCL and SDA lines. The maximum I2C clock speed for the MPU-6050 is 400 kHz (Fast Mode). For ADXL345 via SPI, the device supports SPI Mode 3 (CPOL=1, CPHA=1) at up to 5 MHz.

Tilt angle calculation uses the accelerometer readings and inverse trigonometric functions. For a device lying flat, the roll angle about the X-axis is: Roll = atan2(Ay, sqrt(Ax^2 + Az^2)) and pitch about Y-axis is: Pitch = atan2(-Ax, sqrt(Ay^2 + Az^2)). These values are in radians and must be converted to degrees by multiplying by 180/pi.

Example
Given:
MPU-6050 accelerometer, range set to ±2g
Sensitivity = 16384 LSB/g
Raw Z-axis register reading = 15565
Raw X-axis reading = 2048

Why this formula applies:
Raw 16-bit signed integer divided by sensitivity gives acceleration in g.

Formula:
Acceleration (g) = Raw_Value / Sensitivity

Substitution:
Az = 15565 / 16384 = 0.950 g
Ax = 2048 / 16384 = 0.125 g

Calculation:
Tilt (pitch) = atan(-Ax / sqrt(Ay^2 + Az^2))
Assume Ay = 0:
Pitch = atan(-0.125 / 0.950) = atan(-0.1316) = -7.5 degrees

Final Answer:
Device is tilted 7.5 degrees from horizontal about Y-axis.
Exam Tip: MEMS accelerometers measure gravity at rest. A stationary sensor lying flat reads Z = +1g, X = 0g, Y = 0g. If tilted 90 degrees onto its side, one horizontal axis reads ±1g and Z reads 0g. This is the basis of tilt detection and is a common exam scenario.
MPU-6050 I2C Connection and Register Read SequenceMCUI2C MasterSCLSDA3.3VGNDMPU-6050SCLSDAVCCGNDAD0: sets addr4k7pull-upI2C Read Sequence1. START condition by MCU2. Send 7-bit addr 0x68 + Write bit3. Send register addr 0x3B (ACCEL_X)4. RESTART + addr 0x68 + Read bit5. Read 6 bytes (X_H,X_L,Y_H,Y_L,Z_H,Z_L)6. STOP conditionRaw = (HIGH_byte << 8) | LOW_byteAccel(g) = Raw / 16384Axis Output at Different OrientationsOrientationX (g)Y (g)Z (g)Flat face up00+1Tilted 90 on left-100Face down00-1Tilted 90 forward0+10
Figure 2: MPU-6050 I2C connection, read sequence protocol steps, and axis output values at different orientations

Mechanism and Key Points

  • MEMS proof mass displacement due to acceleration changes differential capacitance. Charge amplifier converts this to a proportional voltage, which is digitized by the internal ADC.
  • I2C transaction starts with a START condition (SDA goes LOW while SCL is HIGH), followed by the 7-bit device address with a read or write bit, then data bytes, and ends with a STOP condition.
  • Wake-up register for MPU-6050: write 0x00 to register 0x6B. Range register: write 0x00 to 0x1C for ±2g. Accelerometer data starts at register 0x3B and spans 6 bytes.
  • Combining two 8-bit registers into a 16-bit signed value: Raw = (HIGH_byte << 8) | LOW_byte. If Raw > 32767, subtract 65536 to get the signed value.
  • FIFO buffer in MPU-6050 stores up to 1024 bytes of sensor data, allowing burst reads that reduce bus overhead and enable precise sampling intervals independent of I2C transaction timing.

Quick Revision

  • MEMS accelerometer uses capacitive sensing of proof mass displacement. Output is proportional to acceleration in g.
  • Acceleration in g = Raw_16bit_value / Sensitivity (LSB/g). Sensitivity depends on range setting.
  • MPU-6050: I2C address 0x68 (AD0=0) or 0x69 (AD0=1). Wake by writing 0x00 to register 0x6B. Data at 0x3B to 0x48.
  • ADXL345: supports both SPI and I2C. Sensitivity 256 LSB/g at ±2g. SPI Mode 3 at up to 5 MHz.
  • At rest flat: Z = +1g, X = Y = 0g. This represents gravity vector. Tilt changes distribution among axes.
  • Tilt angle: Roll = atan2(Ay, sqrt(Ax^2+Az^2)), Pitch = atan2(-Ax, sqrt(Ay^2+Az^2)). Multiply by 180/pi for degrees.
  • Exam trap: MPU-6050 starts in sleep mode. Forgetting to write 0x00 to 0x6B is the most common initialization error.

Accelerometers Quiz

Test your knowledge of MEMS accelerometer principles and I2C interfacing.

Question 1 of 3

Q1.In a MEMS capacitive accelerometer, acceleration is measured by detecting changes in which physical parameter?