MikroElektronika Learn

Click Boards

MEMS Sensors: Conversion of the Physical World to the Digital World

26 May , 2016  

MEMS sensors or Micro-Electro-Mechanical Systems are the sensors and actuators at the bare metal of embedded systems. MEMS are used for airbag systems, automatic door locks, security systems , earthquake detection, inkjet printers, kitchen appliances, and of course computer peripherals. In this blog we will explore the different ways you can use MEMS sensors. We will also take a look at the elements of a MEMS sensor and how specific MEMS sensors work like accelerometersgyros and magnetometers as well as some ways that MikroElektronika uses them.


Sensors are used for taking mechanical elements of the MEMS sensor and using the electrical elements to process the data produced, and in most cases use Integrated Circuitry ( IC ) to communicate that data with a micro controller. There are many different types of sensors for sensing different types of data such as acceleration, rotational and linear movement, torque, pressure, and temperature sensors. Pressure sensors are used in vehicles to sensor tire pressure, fuel pressure, oil pressure, and the air pressure within the intake manifold of the engine.



Accelerometers measure acceleration in an x, y and z axis. There are many different ways to measure acceleration in an accelerometer, but the most common approach is by sensing changes in capacitance. When there are two structures near each other there is a measurable electrical capacitance between them. If an accelerometer is moved in any direction the capacitance changes, and after converting this capacitance to a voltage, we can use this as a measurement of acceleration, gyro, etc.


Closeup view of MEMS sensor

The capacitive accelerometer uses micro structures that look like small hair brushes connected to a fixed point. When acceleration is applied to this structure the small fingers of the structure move closer or farther away from each other, changing the electrical capacitance between them. Using circuitry the accelerometer converts this capacitance to a voltage for measurement.

There are many types of accelerometers, but the main difference between accelerometers is the amount of “g” that can be accurately measured. “Low G” accelerometers can measure around 20 g or less and are best suited for low response time, low current consumption, and are usually what is found in smartphones. “High G” accelerometers are designed to detect many more gs, in this case ±100g/±200g/±400g scales can be acheived, and are much more suitable for automotive solutions where the amount of gs is much higher than a smartphone.

Accel 3 Click

Here at MikroElektronika we use accelerometers on click boards like Accel 3 for development uses, as well as in projects such as the Magic Ball click pack to be able to sense which way the board is turned. Here is an example of using our libraries to sense a tap on the accelerometer.


Source code can be found on either Libstock or Github.

Accel 3 Click library
0 forks.
0 stars.
0 open issues.
Recent commits:

This code is an example using the EasyMXPro V7 development board and our TFT display to initialize, calibrate, and implement an application using the Accel 3 Click.  The first step is to setup our applications’ I2C communication, gpio output / inputs,  TFT display, UART, and of course the Accel 3 Click.

The next step is to calibrate the raw 16 bit values that the accelerometer gives us, into a measurment of “g”s.

In this calibration, we are finding the sensitivity of our sensor. This can be determined by applying 1 g acceleration to each axis. This is done by pointing the axis towards the center of the Earth, taking its’ value and storing it, rotating the sensor 180 degrees and then storing that value as well. In this example, we take many values of each axis pointing towards the center of the Earth and away, so that we have an average value to work with. By subtracting the larger output from the smaller value, and dividing the result by 2, this is how we find the sensitivity of the sensor.

Finally, we have our while loop. This is where we get our x, y and z values from the accelerometer, and check to see if our z axis has experienced more than 25 gs ( drop from a high distance ), and alerts the user with a hazard image. Great example right? Don’t go dropping your development board, this is just a test.

(Board still works, but not recommended)

Digital Gyros


To help understand how a gyro works let’s look at a plane and the different rotations that can happen on all three different axes. yaw( z-axis ), pitch( y-axis ), and roll( x-axis ).  If the plane is to turn left or right, it would simply rotate on the z axis, and if the plane wanted to rotate turning one wing of the plane toward the sky and the other towards the earth, it would rotate on the x axis. Finally, if the plane wanted to increase or decrease its’ altitude it would rotate on the y axis.

plane_gyro_exampleBasically, MEMS gyroscopes are designed to detect rotation on any of the three axes described above. We use the data output from this sensor to prevent rolling over in modern automobiles, keep drones level in the sky, or even play your favorite games on your phone or portable gaming devices.  MikroElektronika has click boards such as the Gyro Click, for sensing rotations or our 3D Motion Click which uses a 3-axis accelerometer, a gyroscope, a magnetometer, and a motion co-processor to provide reliable and accurate positioning and orientation information for your projects needs.


Another great MEMS sensor is the magnetometer. Magnetometers use coils on a different bar for each axis to detect the magnetic field in each axis ( x, y, z ). Based on Lorentz force, when one of these bars experience a strong magnetic force, the current passing through the bar will cause it to bend. The magnetometer can then use that calculation and send it to the micro controller for determining the direction of north. At MikroElektronika we have a Compass Click that uses a IC interface capable of measuring both linear acceleration and magnetic field. Using these sensors we are able to use this click board for compasses, position detection, map rotation, pedometer, display orientation and many more.



MEMS sensors are a fundamental part of what makes the technology of tomorrow seem smart, and also helps us monitor things that processors and clever software would never be able to do on their own.



Libstock libraries for Accel 3 Click 2016

Manual for Accel 3 Click 2016

Accelerometer Wiki Page 2016

Magnetometers Engineers Garage 2012

Gyros Info 2016

Lorentz force Wiki Page 2016


Products mentioned

, , , , , , , , , ,

Firmware Engineer at MikroElektronika from Oregon with a passion for learning and programming.