Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

MPU6050 with ESP32-C3 SuperMini — accelerometer and gyro

Read acceleration, rotation and temperature from an MPU6050 (GY-521) on an ESP32-C3 SuperMini, with I2C moved to GPIO5/6 off the strapping pins.

Arduino C++Verified — core esp32 3.3.12, Adafruit MPU6050 2.2.9, 3 Nov 2026Compile-only

Community draft — report a mistake

The MPU6050 is a 6-axis motion sensor — accelerometer plus gyroscope — for tilt alarms, self-balancing robots and gesture input. The GY-521 board has its own regulator and pull-ups, so it is happy on the SuperMini’s 3V3.

Wire SDA to GPIO5 and SCL to GPIO6. The sketch sets a ±4 g / ±500 °/s range with a 21 Hz filter, a sensible start for hand-held or robot use.

Wiring

ESP32-C3 SuperMiniOnly the pins used are shown · 3.3 V logicMPU6050 (GY-521)GND3V35 · 56 · 6VCCGNDSCLSDAXDA (not connected)XCL (not connected)AD0 (not connected)INT (not connected)
Every connection
ESP32-C3 SuperMiniMPU6050 (GY-521)WireNotes
3V3VCCred
GNDGNDblack
6SCLyellow
5SDAblue

3.3–5 V (on-board 3.3 V regulator) part, 3.3 V board. The GY-521 has a 3.3 V regulator and pulls SDA/SCL up to 3.3 V, so it works on both 3.3 V boards and a 5 V Uno without a level shifter.

Board quirks

  • I2C on GPIO5/6: the core’s defaults (GPIO8/9) are the SuperMini’s LED and BOOT button, both strapping pins.
  • Leave AD0 open for 0x68. Tied to 3V3 it moves to 0x69 — useful for two IMUs, or when a DS3231 (also 0x68) shares the bus.
  • The SuperMini is light enough to mount on the moving part itself; keep the IMU rigidly fixed, because a loose board reads as vibration.

Code

mpu6050-esp32c3.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// MPU6050 (GY-521) accelerometer + gyro on an ESP32-C3 SuperMini over I2C (address 0x68).
// VCC → 3V3, GND → GND, SDA → GPIO5, SCL → GPIO6. AD0 open (0x68), INT unused.
#include <Wire.h>
#include <Adafruit_MPU6050.h>

constexpr int SDA_PIN = 5;
constexpr int SCL_PIN = 6;
Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  delay(1500);  // let the native USB serial port enumerate
  Wire.begin(SDA_PIN, SCL_PIN);  // GPIO8/9 are strapping pins on the C3 — not used for I2C
  if (!mpu.begin(0x68, &Wire)) {
    Serial.println("MPU6050 not found at 0x68 — check wiring (AD0 high = 0x69)");
    while (true) delay(1000);
  }
  mpu.setAccelerometerRange(MPU6050_RANGE_4_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
  Serial.println("MPU6050 ready");
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);
  Serial.printf("Accel X %.2f Y %.2f Z %.2f m/s²  Gyro X %.2f Y %.2f Z %.2f rad/s  %.1f °C\n",
                a.acceleration.x, a.acceleration.y, a.acceleration.z,
                g.gyro.x, g.gyro.y, g.gyro.z, temp.temperature);
  delay(500);
}

Library: Adafruit MPU6050 (Adafruit (also install Adafruit Unified Sensor and Adafruit BusIO)) — compiled with Adafruit MPU6050 2.2.9.

Expected serial output

Serial Monitor · 115200Output
MPU6050 ready
Accel X 0.21 Y -0.15 Z 9.79 m/s²  Gyro X -0.01 Y 0.02 Z 0.00 rad/s  31.2 °C
Accel X 0.19 Y -0.14 Z 9.81 m/s²  Gyro X -0.02 Y 0.01 Z 0.00 rad/s  31.2 °C

Common errors

“MPU6050 not found at 0x68”

Check the I2C pins and AD0. Some clone chips report a different WHO_AM_I and the library rejects them. Full fix.

Gyro values drift when still

Normal offset. Average 200 readings at rest at start-up and subtract them.

↑↓ to move · Enter to open