In this blog, we will learn how to measure gravitational acceleration, rotational velocity, and temperature using the MPU-6050 accelerometer and gyroscope module, NodeMCU ESP8266, and Qubitro.
These times when everyone is working from home, the main problem we are facing is backbone issues that is occurring because we are not maintaining proper posture while sitting in front of our computers, so this project can be very useful to determine the posture of a human body as MPU-6050 is an ideal sensor to know the orientation of moving objects and we can easily do the analysis at the Qubitro platform.
The MPU-6050 is a 3-axis accelerometer and 3-axis gyroscope sensor. The accelerometer measures the gravitational acceleration, and the gyroscope measures the rotational velocity and temperature.
- NodeMCU ESP8266
- MPU-6050 Accelerometer and Gyroscope Module
- M-F Jumper wires
- VCC of MPU-6050 to 3.3V of ESP8266
- GND of MPU-6050 to GND of ESP8266
- SCL pin of MPU-6050 to D1 of ESP8266
- SDA pin of MPU-6050 to D2 of ESP8266
Installing required Libraries
Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open.
- Type "Adafruit MPU6050" on the search box and install the library.
- Type "Adafruit Unified Sensor" on the search box scroll down to the last library, and install it.
- Type "Adafruit Bus IO" on the search box and install the library.
- Install "Qubitro MQTT client" from Arduino IDE library manager if not already installed.
First, let's look at the basic example that prints the sensor readings in the Serial Monitor. Go to File > Examples > Adafruit MPU6050 > basic_readings
After running the basic_readings code you will see the following output in the serial monitor.
Connecting to Qubitro Platform
- SignUp/Login on the Qubitro Portal
- Create a new project with a description
- Choose a connectivity method and add details and description.
- Go to the device settings and there you can see your unique device id and device token
Add your wifi SSID, password also add your unique device ID and token in the below code.
Compile and upload this code to your board and now you are ready to send the data to the Qubitro MQTT broker.
Here is the output which you will see in Arduino IDE serial monitor.
Go to the project dashboard and you can see the data received from MPU-6050.
You can also create an analytics chart for real-time sensor data analysis.
So this was all about this project and we can enhance this project to posture correction devices like creating neckbands, motion tracking devices, etc.
I hope you will also try it and for more exciting blogs content involving Qubitro. Don't forget to subscribe to Qubitro Blog.