Skip to main content

wokwi-mpu6050 6-Axis Accel & Gyro Sensor

Integrated sensor with 3-axis accelerometer, 3-axis gyroscope and a temperature sensor with I2C interface.

Pin names

NameDescription
VCCVoltage supply
GNDGround
SCLI2C clock line
SDAI2C data line
XDAUnused*
XCLUnused*
AD0Address select pin
INTInterrupt*

* These pins are not currently implemented in the simulator. If you need them, please open a request.

You normally only need to connect the VCC, GND, SCL, and SDA pins. The I2C address of the device is 0x68. You can change the address of 0x69 by connecting the AD0 pin to VCC.

Attributes

NameDescriptionDefault value
accelXInitial x acceleration value (g)"0"
accelYInitial y acceleration value (g)"0"
accelZInitial z acceleration value (g)"1"
rotationXInitial x rotation value (deg/sec)"0"
rotationYInitial y rotation value (deg/sec)"0"
rotationZInitial z rotation value (deg/sec)"0"
temperatureInitial temperature value (celsius)"24"

Units

All the acceleration values (x/y/z) use g-force units, where 1g = 9.80665 m/s². The gyroscope measures angular rotation and returns the number of degrees per second.

Arduino code example

The example below uses the Adafruit MPU6050 library to read and display the acceleration values from the sensor. On Arduino Uno, connect the SDA pin to A4, and the SCL pin to A5.

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;

void setup(void) {
Serial.begin(115200);

while (!mpu.begin()) {
Serial.println("MPU6050 not connected!");
delay(1000);
}
Serial.println("MPU6050 ready!");
}

sensors_event_t event;

void loop() {
mpu.getAccelerometerSensor()->getEvent(&event);

Serial.print("[");
Serial.print(millis());
Serial.print("] X: ");
Serial.print(event.acceleration.x);
Serial.print(", Y: ");
Serial.print(event.acceleration.y);
Serial.print(", Z: ");
Serial.print(event.acceleration.z);
Serial.println(" m/s^2");
delay(500);
}

Run this example on Wokwi

Simulator examples