Our prices are exclusive of taxes and shipping. 18% GST shall be added during check out. Happy Shopping! :)  

Robocraze Welcome to Robocraze

MPU6050 Accelerometer #Tutorial

An accelerometer is an electromechanical device that will measure acceleration forces. These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic ie. caused by moving the accelerometer.

MPU6050 Accelerometer #Tutorial

In this article, we will look at the MPU6050 accelerometer and interface it with a Raspberry PI. The MPU6050 sensor module is a complete 6-axis Motion Tracking Device. It combines a 3-axis Gyroscope, a 3-axis Accelerometer and a Digital Motion Processor all in a small package. It has an I2C bus interface to communicate with the host controller (R-Pi).

 

 

The MPU6050 has 8 pins as mentioned below.

 

  1. VCC: +5V DC power supply pin

  2. GND: Ground pin

  3. SCL: Serial Clock pin

  4. SDA: Serial Data pin

  5. XDA: Auxiliary Serial Data pin

  6. XCL: Auxiliary Serial Clock pin

  7. AD0: Slave Address select pin.

  8. INT: Interrupt pin

 

The AD0 pin is used to change the I2C address of the MPU6050. Connecting this pin to +5v sets the address of the sensor to 0x69 and connecting it to ground sets it to 0x68. This is helpful if you have two MPU6050’s or another sensor with the same I2C address on the I2C bus.

 

The connection diagram is as shown below. This will work for both RPi 3 b and b+ variants.

 

In the image above the pin connections are as follows:

 

MPU6050-Raspberry Pi (board pins)

VCC-4

GND-34

SDA-3

SCL-5

 

Refer to the python code for reading accelerometer readings from the MPU6050 and displaying on the terminal. Link for the code: https://github.com/Robocraze/MPU6050

 

Upload the above code to a raspberry pi and run it using python3. Running it will print the accelerometer and gyroscope value along the three axes once every 500 ms on the terminal.

 

 

In the code above we have created a class for the mpu6050 which abstracts all the functions that will be required to get readings from and set parameters of the mpu6050. You can use that class as a tool to develop various applications using the mpu6050.

This application can be extended much further to detect the orientation of robots, their location (using a technique called inertial navigation), to build self-balancing bots, in quadcopters for roll, pitch, yaw angle calculations and many more.

 

Tutorial:

 

Grab Yours Today - here

Write Your Comment

Only registered users can write comments. Please, log in or register