Article Preview
Buy Now
FEATURE
Balancing Act
Using an accelerometer and gyroscope sensor with your Raspberry Pi
Issue: 22.5 (September/October 2024)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He has university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 21,320
Starting Page Number: 21
Article Number: 22503
Resource File(s):
project22503.zip Updated: 2024-09-02 10:58:57
Related Web Link(s):
>wget http
Excerpt of article text...
The MPU6050 measures acceleration and the position of an object. It is used for drones, self-balancing robots, vehicle tilt sensors, and to detect rotation. This is a common chip used in the industry and can be purchased for a number of Raspberry Pi and Arduino-compatible boards.
For instance, the latest Chevrolet ZR2 truck has a tilt sensor that is used to measure the angle of the truck when driving off the main road. If you want to ensure that a drone or quadcopter remains level, then an MPU6050 may be a good choice.
What makes the MPU6050 unit even better is that it uses I2C communication, which requires only a few wires! Roll and pitch are common measurements. The MPU6050 would work well with an additional compass gauge to reliably measure yaw and an elevation gauge to measure the height above the ground.
This example and the accompanying free library calculates the angles in the x-axis and y-axis directions, acceleration, and all the raw accompanying data. Equipment used includes a Raspberry Pi 5, MPU6050, Xojo 2023 R4, Raspberry Pi OS, and the free lgpio library. A video of the running example is available on YouTube (
https://youtu.be/gNzrLWRh18Q
). See Figure 1.The final result is to calculate the x-axis and y-axis angles in degrees and display them on the screen. Raw gyroscope and acceleration data are read from the MPU6050, and only the first decimal point is shown for each value.
...End of Excerpt. Please purchase the magazine to read the full article.