Connecting MPU6050 With ESP32

Introduction: Connecting MPU6050 With ESP32

About: pursuing Bachelors in Electronics and Communication at Chandigarh University

In this project, i am going to interface MPU6050 sensor with ESP32 DEVKIT V1 board.

MPU6050 is also known as 6 axis sensor or 6 degree of freedom(DOF) sensor. Both accelerometer and gyrometer sensors are present in this single module. Accelerometer sensor give output readings in terms of force applied on object due to gravity and gyrometer sensor give output in terms of angular displacement of the object in clockwise or anticlockwise direction.

MPU6050 sensor use SCL and SDA line of ESP32 DEVKIT V1, therefore, we will be using wire.h library in the code for I2C communication. We can attach two MPU6050 sensors with same SCL and SDA lines at address 0x68 and 0x69 with ESP32 DEVKIT V1.

Step 1: Components Required

1. ESP32 DEVKIT V1 board -

2. MPU6050 sensor -

3. Jumper wires -

4. Breadboard(optional) -

5. Arduino IDE software

Setting up your Arduino IDE before uploading code in ESP32 is very important : -

Step 2: Circuit Schematic

Circuit Schematic will be different for different ESP 32 board so take care of Pins you are connecting

ESP32 --> MPU6050 Pins

VIN(5V) --> VCC




Step 3: Code

Steps to follow while uploading code in ESP32 board

1. Click on upload.

2. If no error. At the bottom of Arduino IDE, when we get message Connecting ...,...,

3. Press Boot button on ESP 32 board till you get the message done uploading.

4. After you code is uploaded successfully. Press enable button to restart or start code uploaded on ESP32 board.

Step 4: Serial Monitor(Result)

Be the First to Share


    • Lamps Challenge

      Lamps Challenge
    • Puzzles Challenge

      Puzzles Challenge
    • Rice & Grains Challenge

      Rice & Grains Challenge



    1 year ago

    First thing I noticed is that it won't flash when the MPU6050 unit is attached to the 5v of the ESP32 - must be loading it. I am trying a separate supply. Also, to the best of my knowledge does the MPU unit not give out velocity and acceleration only - not position in degrees. It is a rate gyro and accelerometer so units must be degrees/s or rad/s and rad/s^2 for angular acceleration. You have to integrate the output to get position.


    Question 1 year ago on Introduction

    I am using MPU6050 interfaced with ESP32 as an Access Point and having several tasks running on both the cores . When I2C clock rate is 100KHz, I get legit values, but when I2C clock rate is changed to 400KHz, the MPU6050 gives "-1"(error). What can be the issue ?
    Thanks in advance