Another illustration that demonstrate how to use MPU6050 on Raspberry Pi. The MPU 6050 sensor board contains a MEMS ACCELEROMETER and MEMS GYRO a single chip that provide a very accurate data, as it contains 16bits analog to digital conversion hardware for each channel that captures the X, Y, and Z channel at the same time. The board sensor uses i2c Bus interface that you can just hookup to your Raspberry Pi.

The MPU 6050 combines both an accelerometer and a gyro together in one single chip. There two type of MPU version there is 6050 and 9150 that has a MAGNETOMETER (Compass) integrate to chip. On this illustration we will cover only the MPU 6050 without using the magnetometer. Getting the raw values for the accelerometer and the gyro is quite easy. The sleep mode has to be disable and then the registers for the accelerometer and gyro can be read. The sensor also contains 1025 bytes FIFO buffer that can be programmed to be place into FIFO buffer and the buffer can be ready by the microcontroller.
The FIFO buffer is used together with the interrupt signal if the MPU 6050 places a data into the FIFO buffer it send signals to the Raspberry PI with the interrupt signal. The Raspberry Pi knows that there is a data coming from FIFO buffer that ready to be read.

The MPU 6050 always acts as a slave to the Arduino with the SDA and SCL pins connected to i2c BUS. The board has also its own i2c controller to be a master on a second sub i2c bus. It uses the pins AUX_DA and AUX_CL for the second sub i2c BUS you can control the magnetometer and the values of the magnetometer can be passed into the Raspberry Pi.

The sensor has a Digital Motion Processor (DMP) or Digital Motion Processing Unit these DMP can be programmed with firmware and can do a complex calculation with the sensor values.

The Digital Motion Processor can calculate directly to the chip at this state the load reduce for the Raspberry Pi. The DMP can even do a calculations with the sensor values of another chip, for example if the magnetometer connected to the second i2c Bus.

Required Components

  • Raspberry Pi / Banana Pi / Orange Pi  (If your using Banana Pi or Orange See first the GPIO Pin Mapping)
  • Rotary Encode
  • Solder Less Bread Board
  • Jumper Wire / DuPont Wire

Wiring Diagram

Configuring Raspberry Pi i2C Bus Interface

Uploading the code

C Code : Example 1

C Code : Example 2

Python Code

Downloads

Download MPU 6050 Datasheet | Pdf

 

Wiring MPU 6050 MEMS Accelerometer GYRO on RPI
Facebooktwittergoogle_plusredditpinterestmail
Tagged on:                         

Leave a Reply

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