The MPU6050 is a commonly used sensor module that integrates a 3-axis accelerometer, a 3-axis gyroscope, and a temperature sensor in a single compact package. It is useful for beginners because it is relatively easy to use and provides accurate measurements of orientation, motion, and tilt angles. The MPU6050 can be interfaced with microcontrollers like Arduino, Raspberry Pi, and others using I2C communication protocol, making it ideal for hobby projects such as robot control, gaming, and quadcopter stabilization. Overall, the MPU6050 is a versatile sensor that can provide valuable data for a wide range of applications.
In this tutorial, I demonstrate how to connect it with the Arduino Uno and start getting readings. Thankfully with a series of libraries, it is relatively easy to do.
-----
Before we get into it, consider subscribing or supporting the channel. Also, be sure to checkout our various stores to shop products for Raspberry Pi, Arduino, ESP32, and DIY electronics at ShillehTek!
Subscribe:
Support:
https://www.buymeacoffee.com/mmshilleh
Hire me at UpWork to build your IoT projects:
https://www.upwork.com/freelancers/~017060e77e9d8a1157
Visit ShillehTek Store for Arduino and Raspberry Pi Sensors and Pre-Soldered Components:
ShillehTek Website (Exclusive Discounts):
https://shillehtek.com/collections/all
ShillehTek Amazon Store:
ShillehTek Amazon Store - Canada
ShillehTek Amazon Store - Japan
Step 1-) Physical ConnectionThe connection is very simple. You only need four jumper wires exactly as shown in the diagram, these are the most popular pins when using the MPU6050. They are described as follows:
- GND (Ground): This pin is connected to the ground of the circuit. It is used as the reference point for all other signals.
- VCC (Voltage Supply): This pin is connected to the power supply of the circuit. It typically requires a 3.3V or 5V DC voltage to operate.
- SCL (Serial Clock): This pin is used to synchronize the data transfer between the MPU6050 and the microcontroller. It is the clock signal for I2C communication.
- SDA (Serial Data): This pin is used to transfer data between the MPU6050 and the microcontroller. It is the data signal for I2C communication.
The MPU6050 has four additional pins that are less commonly used (not needed in this tutorial:
- XDA (Auxiliary Serial Data): This pin is an additional data line for I2C communication. It can be used for connecting multiple I2C devices in a chain.
- XCL (Auxiliary Serial Clock): This pin is an additional clock line for I2C communication. It can also be used for connecting multiple I2C devices in a chain.
- ADO (Address Select): This pin is used to select the I2C address of the MPU6050. It can be connected to VCC or GND to change the default address of the device.
- INT (Interrupt): This pin is used to generate an interrupt signal when specific events occur, such as motion detection or data ready. The microcontroller can be programmed to respond to these interrupts and take appropriate actions.
For the sake of this tutorial, I assume you already know how to connect to the Arduino UNO in the Arduino IDE, and of course, you have the Arduino IDE installed.
- Connect to the board as follows (in the diagram), by going to the Tools tab and selecting the correct Board and Port.
- Install the Adafruit MPU6050 library with all corresponding dependencies
You can find the library manager on the left side of the Arduino IDE.
- The code is easy, thankfully the library itself comes with a full-fledged example. Go to the File tab and go to Examples, scroll to Adafruit MPU6050
Select the basic_readings.ino and upload it to Arduino with the upload button.
If you did everything correctly you will get readings as follows:
Congrats, you did a good job if you made it this far. If you lacked some context in this tutorial you can watch the video on Youtube. If you simply enjoyed these simple tutorials please like, comment, and subscribe to the channel!
Comments