MPU6050 is a frequently preferred sensor in aircraft, balance robots and many other areas.
It is a 6-axis IMU board with a 3-axis Gyro and a 3-axis angular accelerometer.
Features:
- Operating Voltage: 3.0 V – 5.0 V
- Gyro Measurement Range: ±250, ±500, ±1000, ±2000 ⁰/s
- Angular Accelerometer Measurement Range: ±2, ±4, ±8, ±16 g
- Communication Interface : I2C
- Dimensions: 20.3mm X 15.6mm
Documents:
- Sample Arduino Application
- Arduino Playground
- Example Raspberry Pi Application
Package Included:
- 1 x MPU6050 Acceleration and Gyro Sensor Board
- 1 x 1×8 Header(Male)
- 1 x 1×8 Header(Male-90⁰)
Test code
//www.ekostra.com
#include <Wire.h>
const int MPU6050_ADDR = 0x68; // MPU-6050 I2C address
int16_t accelerometer_x, accelerometer_y, accelerometer_z;
int16_t gyroscope_x, gyroscope_y, gyroscope_z;
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(MPU6050_ADDR);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // Set to 0 to wake up the MPU-6050
Wire.endTransmission();
}
void loop() {
// Read accelerometer and gyroscope data
readMPU6050Data();
// Print the values
Serial.print("Accelerometer: ");
Serial.print("X = "); Serial.print(accelerometer_x);
Serial.print(", Y = "); Serial.println(accelerometer_y);
Serial.print(", Z = "); Serial.println(accelerometer_z);
//Serial.print("Gyroscope: ");
//Serial.print("X = "); Serial.print(gyroscope_x);
//Serial.print(", Y = "); Serial.print(gyroscope_y);
//Serial.print(", Z = "); Serial.println(gyroscope_z);
delay(20); // Delay for 1 second
}
void readMPU6050Data() {
Wire.beginTransmission(MPU6050_ADDR);
Wire.write(0x3B); // Starting register for accelerometer data
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_ADDR, 14, true); // Request 14 bytes from MPU-6050
accelerometer_x = Wire.read() << 8 | Wire.read();
accelerometer_y = Wire.read() << 8 | Wire.read();
accelerometer_z = Wire.read() << 8 | Wire.read();
delay(100);
gyroscope_x = Wire.read() << 8 | Wire.read();
gyroscope_y = Wire.read() << 8 | Wire.read();
gyroscope_z = Wire.read() << 8 | Wire.read();
}
Reviews
Clear filtersThere are no reviews yet.