Reefwing MPU 6050 GY-521 IMU Arduino Library

David Such
7 min readAug 5

To provide compatability with the Reefwing AHRS Library, we have been forced to release libraries for the following IMUs:

The control board that is used on our Stewart Platform (Figure 1 — this flight simulator will be the subject of a separate article), comes with an MPU6050, so once again we need to create our own library. Or so we thought…

The primary additions for the Reefwing IMU libraries is to use the Reefwing imuTypes library header to make it compatible with the Reefwing AHRS Library and allow easy graphing of IMU values via the Reefwing xIMU3 data visualisation library. The second addition is achieved by providing a time stamp for each sensor reading. While we are going to the trouble of creating our own versions, we also add in some additional functionality, not found in the standard libraries.

Figure 1. 6 DOF Stewart Platform [Image Credit]

The Reefwing MPU6050 Library is available via the Arduino IDE Library Manager or you can download it directly from the Reefwing Software GitHub Repository.

The MPU-6050

The MPU-6050 consists of a 3-axis gyroscope and 3-axis accelerometer. The sensor ranges are:

  • Gyroscope: + 250, 500, 1000, 2000 ° / s
  • Accelerometer: ± 2, ± 4, ± 8, ± 16 g

As usual our first step is to have a look at the MPU-6050 data sheet. There we made the discovery that:

The MPU-6000 and MPU-6050 are identical, except that the MPU-6050 supports the I²C serial interface only, and has a separate VLOGIC reference pin. The MPU-6000 supports both I²C and SPI interfaces and has a single supply pin, VDD, which is both the device’s logic reference supply and the analog supply for the part.

This is great news since we have already written a library for the MPU-6000! The bad news is that our Library only currently supports SPI, since that was all we needed. To handle the MPU-6050, we will need to add support for I²C…

David Such

Reefwing Software · Embedded Systems Engineer · iOS & Android Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control

Recommended from Medium

Lists

See more recommendations