Category Archives: Python

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.

 

Create a KML File to Display your GPS Data on Google Earth

Below we show you an example KML file that allows you too display your logged GPS data on Google Earth. For simplicity, we have included two GPS points. First, notice that the ordered pairs are Longitude,Latitude. Notice this is reversed of what we would normally expect, but it is important to note the order . . . Longitude must be put as the first term in the ordered pair. Also notice that the ordered pair of data show up two times in the file. The first is to create the dot, or placemark on the map, and the second list creates the line over your logged path. Now, the challenge for you is to write a python program that takes your log.txt file, which contains simple comma delimited data, lat,lon, and use that to generate a .kml file as shown below.

 

Plotting X-Y-Z Magnetometer Data for Accurate Calibration

In this video lesson we create a PyQt5 Widget in Python to help calibrate the QMC5883L 3-Axis Magnetometer on the GY-87 module. The Widget plots the data coming from the Magnetometer in real time to allow more accurate calibration.

This is the circuit schematic for our project:

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

This is the simple code for the arduino to generate the raw data;

This is the code we run on the Python side to plot the raw data:

 

Logging GPS Data on Your Raspberry Pi Pico W GPS Tracker Project

In this lesson I show you how to log GPS data to the flash memory on your Raspberry Pi Pico W. This allows you to not only know where you are, but to also know where you have been. In this lesson, this is the schematic of your project circuit.

GPS Tracker
Schematic for Controlling GPS Tracker from the Breadvolt

For your convenience, here is the code we developed in the the video:

 

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.