Project Overview
ESP32 + MPU6050: In this project, you connect an ESP32 to an MPU6050 accelerometer/gyroscope so you can start reading motion data for IoT and embedded system projects using the Arduino IDE.
This guide focuses on the physical wiring basics and the code setup you need to integrate the MPU6050 with an ESP32.
- Time: 20 to 40 minutes
- Skill level: Beginner
- What you will build: A working ESP32 + MPU6050 setup that compiles and runs in the Arduino IDE and outputs usable accelerometer and gyroscope readings
Parts List
From ShillehTek
- Breadboard - for quick solderless prototyping
- Jumper wires - for making stable I2C and power connections
External
- ESP32 development board
- MPU6050 accelerometer/gyroscope module (GY-521 or equivalent)
- USB cable for programming the ESP32
- Arduino IDE (installed on your computer)
Note: MPU6050 modules are typically used over I2C. Always confirm your specific module pin labels and voltage requirements before powering it from the ESP32.
Step-by-Step Guide
Step 1 - Prepare your ESP32 and Arduino IDE
Goal: Get the Arduino IDE ready to compile and upload code to your ESP32.
What to do: Install and open the Arduino IDE, connect your ESP32 to your computer over USB, and make sure you can select an ESP32 board and the correct serial port.
Expected result: The Arduino IDE recognizes your ESP32 and is ready to upload sketches.
Step 2 - Wire the MPU6050 to the ESP32
Goal: Make the physical connections required for power and I2C communication between the ESP32 and the MPU6050.
What to do: Connect the MPU6050 module to the ESP32 using the module pin labels (power, ground, and I2C lines). Use your module documentation to match the MPU6050 SDA and SCL pins to the ESP32 I2C pins you plan to use.
Expected result: The MPU6050 is powered correctly and connected to the ESP32 over I2C (SDA/SCL).
Step 3 - Add MPU6050 support in the Arduino IDE
Goal: Ensure your Arduino environment has the library support needed to talk to the MPU6050.
What to do: In the Arduino IDE, install an MPU6050-compatible library (or open an example sketch from your chosen library) so you can initialize the sensor and read accelerometer and gyroscope values.
Expected result: Your sketch compiles with the required includes and MPU6050 initialization code available.
Step 4 - Upload a test sketch and read sensor data
Goal: Verify the ESP32 can communicate with the MPU6050 and produce usable readings.
What to do: Upload a simple MPU6050 test sketch from the Arduino IDE (for example, a library example). Open the Serial Monitor to view output and confirm that accelerometer and gyroscope data updates as you move the sensor.
Expected result: The Serial Monitor shows live motion readings from the MPU6050 when connected to the ESP32.
Conclusion
You now have an ESP32 communicating with an MPU6050 accelerometer/gyroscope so you can start using motion data in Arduino IDE based projects. This setup is a solid foundation for motion sensing, stabilization, and other embedded applications.
Want the exact parts used in this kind of build? Grab what you need from ShillehTek.com. If you want help customizing this project or building something similar for your product, check out our consulting: https://shillehtek.com/pages/iot-consulting.