Memsic2125 Accelerometer (Mx2125)

Memsic2125 Accelerometer (Mx2125) © GPL3+

Need to gauge angles? Here's your module!

  • 3,803 views
  • 0 comments
  • 12 respects

Components and supplies

Apps and online services

About this project

Need your project to detect an angle or an incline? Here's your module, the Memsic 2125 (Mx2125)!

What is This?

The Mx2125 is a tiny but powerful accelerometer, or a sensor that can gauge tilt. The module has six pins: two GND, one VCC, a x-axis pin, a y-axis pin, and a temperature sensor (using analog output). The accelerometer can measure the x and y axis tilt (or the pitch and roll).

Wiring it Up

It's very easy to wire up the Mx2125. You only need 5-7 wires: a wire for power (an extra wire if you want to connect it a breadboard's power-bus), two wires for ground (again, add a wire if you want to connect them to the breadboard's power-bus), one wire for the x-axis output pin, and one wire for the y-axis output pin. If you just want to measure tilt, you won't need to wire the temp pin. There is a Fritzing diagram int he Schematics section showing how to wire up the module with 7 wires.

With the module facing up, the order of the pins (from top-left to bottom-left then top-right to bottom-right) are: temp, y-axis output, GND, VCC, x-axis output, and GND.

The best part is that there are no resistors or other components needed when wiring, just pin to Arduino (or what ever board you are using).

Programming it (in Arduino c)

It's very easy to program the Mx2125. There are three simple steps to get input: 1) set the pinMode of the the pins that are attached to the x/y-axis output to INPUT, 2) use pulseIn to get input form the module, and 3) use a short equation to convert the input into milli-g (basically a unit that we can use).

That's it! There's a copy of the three steps in code form (plus outputting the information into the serial monitor) in the Attachments section of this project.

Last Notes

The module runs on 5v, it may harm it if it is given too much voltage.

Please leave feedback on this tutorial, thank you!

Code

xyReaderArduino
This is the one and only code file you will need to get the x and y axis angle
const int xP = 11;
const int yP = 12;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(xP, INPUT);
  pinMode(yP, INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  int px, py;
  int ax, ay;

  px = pulseIn(xP, HIGH);
  py = pulseIn(yP, HIGH);

  ax = ((px / 10) - 500) * 8;
  ay = ((py / 10) - 500) * 8;

  Serial.print(ax);
  Serial.print("\t");
  Serial.print(ay);
  Serial.println();

  delay(100);

}

Schematics

Hookup
Fritzing of how to hook-up the Mx2125 to pins 2 (x-axis) and 3 (y-axis)
Mx2125hookup bb
Mx2125 Size
Comparison to the Arduino Uno and a half size breadboard
Comparedto

Comments

Similar projects you might like

Level Platform Using Accelerometer

Project tutorial by Mark Tashiro

  • 16,966 views
  • 15 comments
  • 29 respects

Ultra-Sonic "Ping" Sensor

by MicroBob

  • 25,331 views
  • 6 comments
  • 32 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 49,046 views
  • 63 comments
  • 145 respects

Smoke Detection using MQ-2 Gas Sensor

by Aritro Mukherjee

  • 213,112 views
  • 36 comments
  • 133 respects

Android Controlled 6DoF Robotic Arm

Project in progress by Team Mans

  • 11,065 views
  • 0 comments
  • 17 respects
Add projectSign up / Login