Calibrating a 3-Axis Magnetometer

In this video lesson we show you how to calibrate the QMC5883L 3-axis magnetometer. The lesson is geared toward this specific magnetometer, but the procedure will be the same for any 3-axis magnetometer. We then use the calibrated reading to measure and calculate the magnetic heading of the device. With this, we have created a calibrated digital compass. In this lesson we are using the GY-87 module, which contains the QMC5883L magnetometer. We are connecting the module to the arduino using the following schematic:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

In the video we develop two programs. The first program determines your sensor’s calibration constants. Then the second program uses those calibration constants to calculate heading, or yaw. The second program uses the offsets and scale parameters for MY PARTICULAR SENSOR. These values were determined using the first program. You must determine these values for your sensor, and then edit the second program to use your particular calibration parameters.

Program to determine your calibration parameters:

Once you get your calibration parameters, then put them into this program. This program will then calculate your compass heading:

 

Using the QMC5883L Magnetometers on the GY-87 Module

In this video lesson we activate the QMC5883L 3-axis magnetometer on our GY-87 module. We show how to read the raw magnetic field strength in the x, y, and z axis. Your homework assignment will be to then calibrate the measurements such that you center the measured values around 0, and create a unit circle. This calibration will be very similar to what we did for the accelerometers a few weeks ago. This is the schematic we continue to use in this lesson:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

This is the code we developed in todays lesson to read the raw data from the magnetometers.

 

Logging Data On Your Raspberry Pi Pico Using Flash Memory

In this video lesson, We show you how to log sensor data on your Raspberry Pi Pico W. We will start with simple read and write functions, and then show you how to write and read files line by line, and keep a log of your sensor data.

Our first program is very simple, and just shows how to write a line of data, and read a line of data the the Pico’s flash memory. Here is the code we used in the video for the first simple example.

In the second example, we show greater complexity by writing and reading a file, line by line. Each line contains comma delimited sensor data.

In these first two examples, when we open the file as ‘w’, the existing data is erased and a new file is created. In the example below, we open an existing file, and show how to append new data to the existing file without erasing the old data.

 

Improving MPU6050 IMU Arduino Project Performance with a Complimentary Filter

In this video lesson I show you how you can improve the performance of your Arduino MPU6050 IMU Project by incorporating a complimentary filter. We will combine the roll and pitch calculations from the accelerometer and gyro into a fused result which allows us to enjoy the best of both worlds.

MPU6050
Schematic for connecting the GY-87 module to the Arduino

For your convenience, the code developed is presented below:

 

Reducing Gyro Drift in MPU6050 IMU Arduino Project

 

In this video lesson we learn how to reduce drift in our roll, pitch, and yaw from the MPU6050 IMU Arduino Project. We will be using the following schematic in today’s work.

MPU6050
Schematic for connecting the GY-87 module to the Arduino

This is the code we developed in this lesson:

 

Making The World a Better Place One High Tech Project at a Time. Enjoy!