Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › accelerometer

How to Simulate an Adafruit MPU6050 with Arduino in Wokwi

By Freedom251 Team · · 3 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can test Arduino code for an MPU6050 without wiring a physical sensor. This guide uses Wokwi as its documented simulator example: its MPU6050 component communicates over I2C and works with the Adafruit_MPU6050 library. The original title’s “2022” is not needed for this current, simulator-specific walkthrough.

What the Wokwi MPU6050 simulator supports

Wokwi provides a simulated MPU6050 component with three-axis accelerometer, three-axis gyroscope and temperature readings. It communicates over I2C, uses address 0x68 by default, and uses 0x69 when its AD0 pin is connected to VCC. The component documentation also supplies an Arduino example using the Adafruit library. See Wokwi’s MPU6050 component documentation.

As an Amazon Associate I earn from qualifying purchases.

The simulator exposes starting acceleration, rotation and temperature attributes, so you can choose values to exercise your sketch. Its XDA and XCL pins are not implemented. These controls let you test code against simulated readings; they do not establish that the simulator models every behavior of a physical sensor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up the sketch and libraries

Use an Arduino project in Wokwi and add the MPU6050 component. For a typical Uno wiring setup, connect VCC to 5V, GND to GND, SDA to A4 and SCL to A5. The component’s usual required connections are VCC, GND, SDA and SCL. If you use another board or change the I2C address, check the board and component details rather than assuming the Uno pin mapping applies.

#1 Best Overall
HiLetgo 3pcs GY-521 MPU-6050 MPU6050 3 Axis Accelerometer Gyroscope Module 6 DOF 6-axis Accelerometer Gyroscope Sensor Module 16 Bit AD Converter Data Output IIC I2C for Arduino
  • MPU-6050 MPU6050 6-axis Accelerometer Gyroscope Sensor
  • Communication mode: standard IIC communication protocol
  • Chip built-in 16bit AD converter, 16bit data output
  • Gyroscopes range: +/- 250 500 1000 2000 degree/sec
  • Acceleration range: ±2 ±4 ±8 ±16g

In the Arduino IDE, install Adafruit MPU6050 through Library Manager. Install its documented dependencies, Adafruit BusIO and Adafruit Unified Sensor, as well. The Adafruit guide includes a basic_readings sketch that reads acceleration, rotation and temperature. See the Adafruit Arduino MPU6050 guide and the Adafruit_MPU6050 library repository.

Read and print sensor values

This minimal sketch starts the sensor, checks that it responds, and prints acceleration values. It uses the same library and basic initialization pattern as the documented Wokwi example.

Rank #2
AOICRIE 3pcs GY-521 MPU 6050 MPU6050 3 Axis Accelerometer Gyroscope Module 6 DOF 6-Axis Accelerometer Gyroscope Sensor Module Pre-Soldered for Raspberry Pi Pico and Other Models
  • MPU-6050 MPU6050 Module: adopts the standard IIC communication for communication and is powered by 3V-5V for sustainable use.
  • 3 Axis Accelerometer Gyroscope Module: Gyroscope range: ± 250 500 1000 2000 ° / s; Acceleration range: ± 2 ± 4 ± 8 ± 16 g; Transmission can pass I2C up to 400kHz or SPI up to 20MHz.
  • MPU 6050 Chip built-in: with three 16-bit analog-to-digital converters (ADCs) for digitizing the gyroscope outputs and another three ones for digitizing the accelerometer outputs.
  • Universally Compatible: This sensor is easy to use with just about any microcontroller that has an I2C interface, for Raspberry Pi and ESP32 models.
  • What You Will Get: 3pcs Pre-Soldered GY-521 mpu-6050 mpu6050 3 axis accelerometer sensor. Ready to plug in and go.
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;

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

  if (!mpu.begin()) {
    Serial.println("MPU6050 not found");
    while (1) {
      delay(10);
    }
  }
}

void loop() {
  sensors_event_t accel, gyro, temp;
  mpu.getEvent(&accel, &gyro, &temp);

  Serial.print("Acceleration X: ");
  Serial.print(accel.acceleration.x);
  Serial.print(" Y: ");
  Serial.print(accel.acceleration.y);
  Serial.print(" Z: ");
  Serial.println(accel.acceleration.z);

  delay(500);
}

In Wokwi, start the simulation and open Serial Monitor to see the output. The Adafruit guide specifies 115200 baud for viewing its example output. To print the other measurements, use gyro.gyro.x, gyro.gyro.y and gyro.gyro.z for rotation, and temp.temperature for temperature.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change the simulated readings

Wokwi’s MPU6050 component lets you set initial accelerometer values in g, gyroscope values in degrees per second, and temperature. One g is 9.80665 m/s². Use the component’s documented attributes and units when selecting values, then run the sketch again to see how your code responds. These are simulator inputs—not physical movement or a guarantee that all real-sensor effects are reproduced.

Rank #3
KEAcvise 6-Pack GY-521 MPU6050 Sensor Module, 6-Axis IMU
  • Product Name MPU-6050 MPU6050 6-Axis Accelerometer Gyro Sensor, which is a key component for motion sensing applications.
  • Communication Protocol Utilizes the standard IIC communication protocol, enabling reliable data transfer between the sensor and other connected devices.
  • AD Converter and Data Output Incorporates a built-in 16-bit AD converter, providing precise 16-bit data output for accurate measurement and analysis.
  • Gyroscope Range Offers a gyroscope range of +/- 250, 500, 1000, and 2000 degrees per second, allowing for the detection of various rotational speeds and movements.
  • Acceleration Range The acceleration range spans ±2, ±4, ±8, and ±16 grams, facilitating the measurement of different levels of linear acceleration in various applications such as inertial navigation and motion tracking.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What changes when you use a physical sensor

A real breakout measures actual motion and temperature, and its wiring and voltage limits depend on that specific board. Adafruit’s own breakout supports 3.3V and 5V logic; its guide says to connect VCC to 5V when using a 5V Arduino, or to the 3V supply on a 3V board, then connect ground, SCL and SDA to their matching pins. Do not assume a third-party MPU6050 board has the same voltage support or pinout. Check its documentation before connecting it. See Adafruit’s MPU6050 guide and its MPU-6050 breakout description.

Simulation is useful for developing and exercising the I2C/library path and trying chosen values. It does not replace checking electrical compatibility, wiring, or behavior on the hardware you intend to use.

Best Value
3PCS GY-521 MPU-6050 MPU6050 6-Axis Accelerometer Gyroscope Sensor Module, 3-Axis IMU Motion Sensor with 16-Bit AD Converter, I2C IIC Interface
  • 【6-Axis Accelerometer & Gyroscope】The GY-521 MPU6050 sensor module combines a 3-axis accelerometer and a 3-axis gyroscope to provide 6-axis motion data, including acceleration and angular velocity information for motion sensing, tilt detection, rotation and robotics projects.
  • 【16-Bit Digital Motion Data】Built-in 16-bit ADCs provide digital acceleration and gyroscope data. The accelerometer supports selectable ±2g, ±4g, ±8g and ±16g ranges, while the gyroscope supports ±250, ±500, ±1000 and ±2000°/s ranges for different motion sensing applications.
  • 【I2C/IIC Communication Interface】The MPU6050 module communicates with microcontrollers and development boards through a standard I2C/IIC interface. Clearly labeled VCC, GND, SCL, SDA, XDA, XCL, AD0 and INT pins help simplify wiring, prototyping and project integration.
  • 【Compact GY-521 IMU Sensor Module】The compact GY-521 breakout board integrates the MPU6050 motion sensor and supporting components into a convenient module for breadboards, prototypes, embedded systems and DIY electronics projects.
  • 【For Robotics & DIY Electronics】Suitable for robotics, balancing projects, motion tracking, tilt detection, orientation sensing, gesture detection, embedded electronics and educational projects. Package includes 3 GY-521 MPU6050 accelerometer gyroscope sensor modules.
Rank #4
HUAREW GY521 MPU6050 3 Axis Gyroscope and 3 Axis Accelerometer Module adopts 16 Bit AD Converter Data Output IIC I2C for Arduino(3 pcs)
  • 【ProductMaterial】: MPU6050 Module using immersion gold PCB, machine welding process to ensure quality
  • 【Chip built-in】: With three 16 bit AD converter, 16 bits of data output, for digitizing the gyroscope outputs and accelerometer outputs
  • 【Application】: The sensor can be used to develop various entertaining applications and systems to proceed with Reality enhancement,Electronic Image Stabilization,Optical lmage Stabilization, Compatible with Arduino and Raspberry Pi
  • 【Basic Features】: Digitally output 6-axis or 9-axis rotation matrix, quaternion, and Euler Angle format fusion calculation data, Removed sensitivity between accelerator and gyroscope axes, reducing setting effects and sensor drift
  • 【MPU6050 sensing range】: The angular velocity sensing range is ±250、±500、±1000 and ±2000°/sec,can accurately track fast and slow movements. The accelerator sensing range is ±2g、±4g±8g and ±16g; Transmission can pass I2C up to 400kHz

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

accelerometerAdafruitArduinoGyroscopeMPU6050Wokwi

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.