This project demonstrates how to interface an MPU6050 6-axis motion sensor (3-axis accelerometer + 3-axis gyroscope) with an Arduino using I²C communication. The sensor data is read, decoded, and printed to the Serial Monitor in a structured, human-readable format.
- 🔌 I²C communication via the built-in
Wire
library - 📈 Reads raw 16-bit signed accelerometer and gyroscope data for all axes
- 🖥️ Displays sensor data in labeled format using
Serial.print()
- 🧪 Simulated and tested in the Wokwi online Arduino environment
- 🎯 Ideal for beginners learning sensor interfacing, signed data handling, and I²C
MPU6050_Reader.ino
– The main Arduino sketchmpu6050_simulation.gif
– GIF showing live simulation of sensor readings3-Axis-Gyroscope-Accelerometer-Measurement.zip
– Includes the code and Wokwi project fileREADME.md
– This file
- Arduino Uno
- MPU6050 sensor module
- SDA → A4
- SCL → A5
- VCC → 5V
- GND → GND
- Arduino IDE
Wire.h
library (included by default)- Wokwi Arduino Simulator
- Open the
.ino
file in Arduino IDE or Wokwi. - Upload to your board or run in the simulator.
- Open the Serial Monitor to view live sensor data.
The output in the Serial Monitor looks like this:
X-Axis Acceleration: -245, Y-Axis Acceleration: 16384, Z-Axis Acceleration: 512,
X-Axis Gyroscope: 0, Y-Axis Gyroscope: 200, Z-Axis Gyroscope: -87
The MPU6050 outputs data in signed 16-bit format, where:
- The raw output range is from -32768 to +32767
- At ±2g accelerometer scale:
- 1g ≈ 16384
- 2g ≈ 32768 (maximum value)
So in the GIF, if you see an acceleration value close to ±16384, it indicates approximately ±1g — consistent with gravity when the sensor is still or tilted. Similarly, gyroscope values reflect angular velocity in raw counts that correspond to °/s after scaling.
Formula used for scaling:
g_force = raw_accel_value / 16384.0;
deg_per_sec = raw_gyro_value / 131.0;
You can simulate this project directly in Wokwi using the files provided in the ZIP.
- Scale raw 16-bit signed values to an SI equivalent.
- Add a second MPU6050 sensor for redundancy.
- Explore using higher speed baud rates for communication.
This project is open-source and available under the MIT License (if applicable).
Special thanks to the creators of the MPU6050 datasheet and the Wokwi Simulator community.
Created by Yasteer Sewpersad
Electronic Engineering Portfolio of Evidence