ESP32 Accelerometer Gyroscope Module
The ESP32 Accelerometer Gyroscope Module integrates an MPU-6050 sensor with the ESP32 microcontroller, enabling precise motion detection and orientation tracking capabilities. Using the I2C protocol for communication, the module reads acceleration and rotational data in three axes (X, Y, Z). This facilitates applications such as tilt sensing, gesture recognition, and orientation-based control systems in IoT projects and robotics. Integration is straightforward via Arduino IDE, making it ideal for rapid prototyping and sensor-driven applications.
Components Needed
- ESP32 development board
- MPU-6050 accelerometer gyroscope module
- Jumper wires
- Breadboard (optional)
Circuit Setup:
Connections:
MPU-6050 to ESP32:
VCC to 3.3V
GND to GND
SCL to GPIO 22 (ESP32 SCL)
SDA to GPIO 21 (ESP32 SDA)
Connect the INT pin (if used for interrupt) to any available GPIO pin on ESP32.
Arduino IDE Setup:
Make sure you have the Arduino IDE installed and set up for ESP32 development. You can follow the official guide for setting up ESP32 boards in Arduino IDE.
Instructions:
Install Libraries:
In the Arduino IDE, go to
Search for "MPU6050" and install the library by Electronic Cats or other trusted sources.
Upload the Code:
Connect your ESP32 board to your computer via USB.
Select the correct board and COM port under
Upload the code to your ESP32 board by clicking the upload button (right arrow icon).
Monitor Output:
Open the Serial Monitor (
Set the baud rate to 115200 (or adjust accordingly as per
You should see accelerometer and gyroscope data printed every second, showing values for X, Y, and Z axes.
Notes:
Ensure the MPU-6050 module is correctly powered (3.3V for VCC and GND).
Adjust I2C pins (GPIO 21 and GPIO 22) in the code if using different pins on your ESP32.
This example reads raw accelerometer and gyroscope data. For precise motion tracking or orientation estimation, consider implementing sensor fusion algorithms (like Kalman filters) or using libraries that provide higher-level orientation data.
Handle interrupts if using the INT pin for motion detection or interrupt-based reading.