# How to use a gyroscope in our Arduino projects

In this entry, we will expand on the use of a gyroscope, another sensor that, due to its characteristics, complements very well with the use of an accelerometer, something we will see in the last entry of the IMU series.

In the previous entry, we saw the fundamentals of accelerometers, a very useful component that allows us to determine the acceleration and orientation of a device.

## What is a gyroscope?

A gyroscope (also called gyro) is a device that allows measuring the angle of rotation turned by a certain mechanism.

Unlike accelerometers, gyroscopes are purely differential devices, meaning there is no absolute reference; instead, we always measure angles relative to an arbitrary reference.

There are various types of gyroscopes (mechanical, ring laser, fiber optic). Those used in MEMS are called Coriolis effect vibrating gyroscopes (CVG), which can somewhat be considered an evolution of the Foucault pendulum.

We remember that the Coriolis force is a fictitious force that appears on a moving body when it is in a rotating system.

The value of this force is,

Do not confuse with the centripetal force, which is a real force that must be exerted on a system to make it rotate, or with the centrifugal force, which is a fictitious force in non-inertial systems.

The principle of operation of a CVG is that a vibrating object tends to vibrate in the same plane even if it rotates. The Coriolis effect causes the vibrating object to exert a force on the support, and by measuring this force, we can determine the rotation to which the gyroscope is subjected.

To register the effect of the Coriolis force, a MEMS has structures similar to those of the accelerometer. Certain parts of the body are subjected to vibration by resonance, and the effect of the Coriolis force deforms the structure (which can be measured by the variation of the system’s capacitance).

Just like in the case of accelerometers, the norm is that the gyroscopes we use are 3-axis, meaning that they independently register the rotation in X, Y, and Z, which allows us to determine the magnitude and direction of the rotation.

One of the consequences of using the Coriolis force is that vibrating gyroscopes, unlike other types of gyroscopes, do not register the turned angle but the angular velocity (which is the rate of change of the angle with respect to time).

The units in the international system are rad/s (equivalently s-1), although other units such as º/s, rev/s (rps), or rev/min (rpm) are often used.

To obtain the position angle of the sensor, it is necessary to perform the integration with respect to time (something that the internal electronics of the sensor usually does)-

We never tire of repeating that integral measurements are never a good idea because they involve the accumulation of measurement errors and noise, which causes drift in the measurement.

Indeed, the biggest problem we find with vibrating gyroscopes is that in the medium and long term they have drift (meaning that the measurement gradually deviates from the real value, even with the sensor static).

On the contrary, gyroscopes are fast-response sensors with high precision in short times. Moreover, they respond well to sudden changes and are relatively immune to noise, always in short time ranges.

If you have read the entry on the accelerometer, you will see that their measurement characteristics are opposite to those of gyroscopes, so (attention SPOILER) they complement each other very well.

We will explore this in depth in the next entry, how to measure tilt with IMU, Arduino, and complementary filter, where we will finally combine both devices to create a more robust sensor than either one independently. :::