What is MPU6050 Sensor (Accelerometer and Gyroscope Sensor) with Arduino Leave a comment

The MPU6050 sensor combines an accelerometer and gyroscope, measuring acceleration and angular velocity in multiple axes. It’s widely used for motion sensing, orientation tracking, and stabilization control in devices like drones, robots, and virtual reality systems, providing essential data for precise 3D positioning.

To use the MPU6050 accelerometer and gyroscope sensor with an Arduino, follow these steps:

  1. Components Needed:
    • Arduino board (e.g., Arduino Uno or Arduino Nano)
    • MPU6050 sensor module
    • Jumper wires
    • Breadboard (optional)
  2. Wiring Connections:
    • Connect the VCC pin of the MPU6050 to 5V on the Arduino.
    • Connect the GND pin of the MPU6050 to the GND on the Arduino.
    • Connect the SDA pin of the MPU6050
    • Connect the SCL pin of the MPU6050
  3. Install Libraries:
    • To interface with the sensor, you’ll need to install the “Adafruit MPU6050” library. You can do this through the Arduino Library Manager.
  4. Upload Code:
    • Use the following sample code to read data from the sensor and display it on the serial monitor:
  5. Testing:
    • Open the Arduino IDE, upload the code to your Arduino, and open the serial monitor (Ctrl+Shift+M). You should see real-time data from the this sensor, including acceleration and gyroscope readings.
    • This setup allows you to interface the MPU6050 accelerometer and gyroscope sensor with an Arduino and read the motion and orientation data for various applications, including robotics and motion-controlled devices.
Arduino Code

Arduino Code

***************************************************************************************************************

/* Company Name:LK Tronics
* Author: Research & Development Department
EXPERT GUIDANCE TO BRING YOUR DREAM PROJECT TO LIFE
* Date: 2020/ 05/ 14
* https://lk-tronics.com/
***********************************************
* All rights reserved. No part of this code may be reproduced, distributed,
* or transmitted in any form or by any means, including photocopying, recording,
* or other electronic or mechanical methods, without the prior written permission
* of LK Tronics, except in the case of brief quotations embodied in
* critical reviews and certain other noncommercial uses permitted by copyright law.

************************************************/
#include <Wire.h>
#include <Adafruit_MPU6050.h>

Adafruit_MPU6050 mpu;

void setup(void) {
  Serial.begin(9600);
  if (!mpu.begin()) {
    Serial.println("MPU6050 sensor, check wiring!");
    while (1);
  }
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  Serial.print("Acceleration: ");
  Serial.print(a.acceleration.x);
  Serial.print(" m/s^2\t");
  Serial.print(a.acceleration.y);
  Serial.print(" m/s^2\t");
  Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  Serial.print("Rotation: ");
  Serial.print(g.gyro.x);
  Serial.print(" rad/s\t");
  Serial.print(g.gyro.y);
  Serial.print(" rad/s\t");
  Serial.print(g.gyro.z);
  Serial.println(" rad/s");

  delay(1000);
}

***************************************************************************************************************

VISIT OUR FACEBOOK PAGE FOR MORE INFO | MORE PRODUCT IN OUR SHOP

Leave a Reply