All posts by admin

Measuring Roll, Pitch, and Yaw Using 3-Axis Gyro on the MPU6050

In this video lesson we describe how to measure roll, pitch, and yaw using the MPU6050. We describe the issues associated with drift in these gyros and will propose a path forward in dealing with the drift issue.

We are using the following circuit for this project:

MPU 6050
Schematic for Creating a Tilt Meter

And this is the code we develop in today’s lesson.

 

Two Axis Tilt Meter Displaying Pitch and Roll Using an MPU6050 on the Raspberry Pi Pico W

In this video lesson, we demonstrate how to create a two-axis tilt meter. The device displays both the pitch and roll on an OLED. In addition to this quantitative display of tilt and roll, it also shows a carpenter’s level type visual, where a circle, or bubble moves to indicate tilt. When the circle is centered on the crosshairs, the device is flat in both axis.

For your convenience, this is the schematic we are using:

MPU 6050
Schematic for Creating a Tilt Meter

And we also include the code we developed in this lesson.

 

Measure Pitch and Roll with the MPU6050


MPU 6050
Schematic for Creating a Tilt Meter

This is a simple example of how to measure Pitch and Roll using a 3-axis accelerometer as found on the MPU6050.

 

Schematic for Tilt Meter Using the MPU6050

Below we show the detailed schematic we use for the Tilt Meter we are developing based on the MPU6050 IMU sensor.

MPU 6050
Schematic for Creating a Tilt Meter

This is the simple code for measuring acceleration in the x and y axis. We will develop this much further in future lessons, but this is just to verify things are hooked up correctly, and that we can measure accelleration.

 

Convert HSV to RGB in Micropython


In this video lesson we showed how to convert an angle on the HSV color wheel into an RGB value that can be applied to an RGB LED. In effect, we can find a color we like on the HSV color wheel, and turn the LED in our project that color. The video above shows the framework we are using, and then derives the equations, and then develops the code. For your convenience, the code for the conversion is shown below. To make this a library, we save it as h2RGB.py on our Raspberry Pi Pico W. You can save it either in the same folder your main programs are in, or in the lib folder. To use the library, then simply import the file (h2RGB) and call the method h2RGB.getRGB(degrees), where degrees is the point on the HSV color wheel you want to convert. All of this is explained in detail in the above video.