Category Archives: Python

Ultimate 9-axis Program for Easily and Accurately Calibrating a 9-axis IMU on Arduino

In this video lesson we show how to easily calibrate a 9-axis IMU. We are using the GY-87 IMU module which contains a MPU6050 for measuring acceleration and rotational velocity, and the QMC5883L magnetometer. In this work, we have three programs. The first is simple arduino program for measuring and printing the data from the 9 sensors. Then, the second program is a python program on your PC which will allow you to simply and accurately calibrate the 9 sensors, from the data coming from the first program. Then the third program is a program on the arduino that reads the data from the sensors, and then uses the calibration data that was generated to create accurate, calibrated sensor data.

This is the schematic of the circuit we are working with:

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

Then this is the arduino code we use to calibrate the sensors:

This next program is to be run on your PC. It is a python program that will read the data coming from the arduino, and will then help you calibrate your sensors.

Then finally we take the calibration parameters from the python program, and incorporate them on the Arduino side to allow reading the data from the sensors, and reporting calibrated numbers. Remember, in the program below, you should use your calibration parameters instead of mine. That is, edit the program below for your specific calibration numbers.

 

Python Program to Convert GPS Log file into a KML File for Display on Google Earth

In this video lesson we show you how you can transfer data from your Raspberry Pi Pico W GPS Project to your PC for display on Google Earth. This program transfers the Pi Pico GPS Log file to your PC, and as the transfer is done, the program converts the log.txt file into a .kml file for display on Google Earth.

 

Improving Digital Compass Accuracy With a Low Pass Filter

In this video lesson we add a low pass filter to our calibration and digital compass program. This allows more precise calibration, and removes the jitter from the digital compass display. We continue to use the QMC5883L 3-Axis Magnetometer, which is on our GY-87 IMU module. We are using the following schematic for our project:

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

We collect the data using the GY-87 connected to an Arduino. Below is the simple program which takes the magnetometer data and sends it to the serial port.

The code for the Python side to do the calibration and display a Digital Compass is:

 

Calibrated Compass Display in Python and PyQt5

In this video lesson we develop a Graphical Digital Compass using python and PyQt5. The data comes from a QMC5883L magnetometer connected to an arduino. The magnetometer is on the GY-87 IMU module. The arduino sends the raw data to python. With the raw data in Python, we then calibrate the sensor, and create a graphical representation of a digital compass. The circuit schematic we are using is:

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

The simple program for collecting the raw data on Arduino is:

On the python side, this is the code we developed which both calibrates the magnetometers, and displays a Digital Compass.

 

Portable GPS Data Tracker Using the Raspberry Pi Pico W

In today’s video we show how to run your GPS tracker remotely by saving the program as main.py, and powering from the Sunfounder Breadvolt power supply.  We also show how to prevent the problem of main.py locking up the serial port. We do this by adding a ‘kill switch’, that terminates the main.py program, so the log file can be transferred to your PC.

This is the schematic used for today’s lesson.

GPS Tracker
Schematic for Controlling GPS Tracker from the Breadvolt

For your convenience, this is the code we developed in today’s video.