The MPU6050 is a 6-axis motion tracking device made by InvenSense. It combines:
✅ 3-axis accelerometer (measures acceleration)
✅ 3-axis gyroscope (measures rotation)
✅ Communicates via I2C protocol
✅ Built-in Digital Motion Processor (DMP)
🧾 What Can It Measure?
Sensor
Measures
Unit
Accelerometer
Acceleration on X, Y, Z
m/s² or g
Gyroscope
Rotation on X, Y, Z axes
°/sec
DMP
Calculates pitch, roll, yaw
Degrees
🧰 Components Required
Component
Description
ESP32 Board
(Any Devkit)
MPU6050 Module
GY-521 or equivalent
Jumper Wires
Male-to-female preferred
Arduino IDE
With libraries installed
🔌 Wiring MPU6050 with ESP32
MPU6050 Pin
ESP32 Pin
Function
VCC
3.3V
Power
GND
GND
Ground
SDA
GPIO 21
I2C Data
SCL
GPIO 22
I2C Clock
MPU6050 works with 3.3V and 5V, but use 3.3V for safety with ESP32.
🧰 Step-by-Step Setup in Arduino IDE
✅ Step 1: Install Libraries
Open Arduino IDE
Go to Sketch > Include Library > Manage Libraries
Install:
MPU6050 by Electronic Cats or Jeff Rowberg (both work)
Wire (already built-in)🎯 Applications of MPU6050ApplicationUsage🚗 Vehicle trackingDetect tilts, crashes, movement🎮 Game controllersDetect hand motion🤖 RoboticsBalancing bots, orientation sensing🚀 DronesFlight control and stabilization🧍♂️ Gesture controlDetect specific hand/head movements🛠️ TroubleshootingIssueSolutionAll values zeroCheck wiring, power, I2C pinsMPU not foundUse I2C scanner, change addressNo outputConfirm Wire.begin(21, 22); is usedValues jump too muchUse averaging or DMP
HOW TO OPERATE// Basic demo for accelerometer readings from Adafruit MPU6050#include<Adafruit_MPU6050.h>#include<Adafruit_Sensor.h>#include<Wire.h>Adafruit_MPU6050 mpu;voidsetup(void){Serial.begin(115200);while(!Serial)delay(10); // will pause Zero, Leonardo, etc until serial console opensSerial.println("Adafruit MPU6050 test!"); // Try to initialize!if(!mpu.begin()){Serial.println("Failed to find MPU6050 chip");while(1){delay(10);}}Serial.println("MPU6050 Found!");mpu.setAccelerometerRange(MPU6050_RANGE_8_G);Serial.print("Accelerometer range set to: ");switch(mpu.getAccelerometerRange()){case MPU6050_RANGE_2_G:Serial.println("+-2G");break;case MPU6050_RANGE_4_G:Serial.println("+-4G");break;case MPU6050_RANGE_8_G:Serial.println("+-8G");break;case MPU6050_RANGE_16_G:Serial.println("+-16G");break;}mpu.setGyroRange(MPU6050_RANGE_500_DEG);Serial.print("Gyro range set to: ");switch(mpu.getGyroRange()){case MPU6050_RANGE_250_DEG:Serial.println("+- 250 deg/s");break;case MPU6050_RANGE_500_DEG:Serial.println("+- 500 deg/s");break;case MPU6050_RANGE_1000_DEG:Serial.println("+- 1000 deg/s");break;case MPU6050_RANGE_2000_DEG:Serial.println("+- 2000 deg/s");break;}mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);Serial.print("Filter bandwidth set to: ");switch(mpu.getFilterBandwidth()){case MPU6050_BAND_260_HZ:Serial.println("260 Hz");break;case MPU6050_BAND_184_HZ:Serial.println("184 Hz");break;case MPU6050_BAND_94_HZ:Serial.println("94 Hz");break;case MPU6050_BAND_44_HZ:Serial.println("44 Hz");break;case MPU6050_BAND_21_HZ:Serial.println("21 Hz");break;case MPU6050_BAND_10_HZ:Serial.println("10 Hz");break;case MPU6050_BAND_5_HZ:Serial.println("5 Hz");break;}Serial.println("");delay(100);}voidloop(){ /* Get new sensor events with the readings */sensors_event_t a, g, temp;mpu.getEvent(&a,&g,&temp); /* Print out the values */Serial.print("Acceleration X: ");Serial.print(a.acceleration.x);Serial.print(", Y: ");Serial.print(a.acceleration.y);Serial.print(", Z: ");Serial.print(a.acceleration.z);Serial.println(" m/s^2");Serial.print("Rotation X: ");Serial.print(g.gyro.x);Serial.print(", Y: ");Serial.print(g.gyro.y);Serial.print(", Z: ");Serial.print(g.gyro.z);Serial.println(" rad/s");Serial.print("Temperature: ");Serial.print(temp.temperature);Serial.println(" degC");Serial.println("");delay(500);}
🌡️ What is DS18B20?The DS18B20 is a digital temperature sensor from Maxim Integrated (now Analog Devices), known for:✅ Accurate temperature readings✅ Unique 64-bit serial code (for... Read More
18-01-2024Node MCU ESP8266 Board are so popular? Mainly because of the following features.Its true Arduino KillerLow-costWiFiLow PowerHigh GPIO PINCompatiblityMultiple Language... Read More
⏰ What is DS1307 RTC?The DS1307 is a real-time clock IC by Maxim Integrated that keeps track of:SecondsMinutesHours (12 or 24-hour mode)Day, Date, Month, YearAutomatically adjusts... Read More
IntroductionThe ESP32 is a powerful and versatile microcontroller that has gained immense popularity due to its low cost, high performance,... Read More
A servo motor is a type of motor designed for precise control of angular position, making it ideal for applications like robotics, RC vehicles,... Read More
📌 What is the DHT11 Sensor?The DHT11 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the... Read More
ESP32 with a water level sensor:Hardware Setup:Gather the necessary components:ESP32 development boardWater level sensor moduleJumper wiresBreadboard (optional)Power supply (3.3V or... Read More
09-06-2025🔧 Components Needed:ComponentQuantityESP32 Dev Board1L298N Motor Driver Module1DC Gear Motors (TT or BO motors)23 x Li-ion 18650 Cells (3.7V each)1 battery... Read More
ESP32 with 2-Channel Relay Module: A Beginner's GuideIntroductionThe ESP32 is a powerful microcontroller that has gained immense popularity due to... Read More
Leave a Reply
You must be logged in to post a comment.