How to implement an IMU using MPU-6050 and Fuelino Proto3

This guide shows how I implemented an IMU (Inertial Measurement Unit) using Fuelino Proto3 (equipped with Arduino Nano) and an MPU-6050 accelerometer and gyroscope module. I will use this library to calculate the motorcycle leaning angles (Tait-Bryan angles: roll pitch yaw) based on the raw sensors data logged on the Micro SD card.

Fuelino Proto3 (Arduino Nano) acquires the signals using I2C protocol, from MPU-6050. The PC (Microsoft Visual Studio Express 2015 C++) runs a software which polls Arduino via UART Serial communication every 100ms, retrieves accelerometer and gyroscope data, and calculates Tait-Bryan angles (yaw, pitch, roll) angles.
The result is shown, in 3D, on the PC using "glfw" library (OpenGL).

The source code of the programs are available below:

  • PC side: IMU_receive_glfw_20160213s. This project source code has to be compiled with Visual Studio C++ 2013 or 2015. In order to run it, you need to download and extract the GLFW library on your C: drive. Then, open the project and right click on the project name and properties and check that the GLFW library folder is the same as in your PC.
  • Arduino Nano side: Fuelino_SW_1_beta4_20170213s. You need to compile the source "ino" file using Arduino IDE (version 1.8.0 runs fine). This is the latest Fuelino Proto3 by now, and it supports many functions, including also sending IMU sensors raw data to the PC. You can test this function by sending via Serial, for example using RealTerm, the 4 characters "d101" followed by a "\n" (new line) or "\r" (return) characters. Arduino will return 18 bytes: the first 4 bytes (unsigned int) are the time, in ms. The following 12 bytes are accelerometers and gyroscope signals, each one 2 bytes signed int (short). The last 2 bytes are the checksum, and can be ignored.

Author: Davide Cavaliere

I am an Italian Electrical Engineer graduated at Politecnico di Milano. My interests are motorcycles and cars, electronics, programming, Internet of Things, and Japanese culture.

Leave a Reply

Your email address will not be published. Required fields are marked *