Category Archives: Python

Measure Distance Between Two GPS Points with the Haversine Equations

In this video lesson we show how we can modify our GPS tracker project to calculate the distance between any two GPS points. User presses the onboard button to log the first data point. Then the user travels to the next point, and then presses the button again. The system calculates the distance between those two points, and the heading angle between the first and second point.

This is a schematic of the circuit we are using:

GPS Tracker
Schematic for Controlling GPS Tracker from the Breadvolt

For your convenience, this is the code developed in the video lesson:

 

Python PyQt5 Magnetometer Calibration Program

In this video lesson we show how to calibrate a QMC5883L 3-Axis magnetometer using python and PyQt5. The program presents the user with a visual representation of the magnetic vector, allowing more precise calibration of the sensors. We are using the GY-87 module, and it is connected like this:

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

This is the simple code on the Arduino side, sending the raw magnetometer data:

 

This is the calibration code, running on the Python side;

 

Python Program to Calculate Distance and Heading Between Two GPS Points Using Haversine Formula

In this video lesson we will develop a python program to calculate the distance and heading between any two GPs positions on earth.  The  equations  we will  be  coding  up  are  below:Haversine Formula

The code which we developed is:

 

Controlling Brightness of Arduino LED Remotely Using PyQt and WiFi

In this lesson we will use PyQt5, UDP and WiFi to control the brightness of an Arduino LED circuit remotely. The PyQt generates a constantly updating sin wave, which it plots on a PyQt graph, and then transfers the brightness in real time to the arduino project. This lesson teaches many important skills including UDP, WiFi, PyQt5, Python, Arduino and LEDs.

When using the breadvolt, or any battery power supply on a breadboard project, do not turn the power supply on while the Arduino is connected to USB, as you could generate voltage conflicts. It is an either or. If the USB is connected, the power supply should be OFF. The schematic for the arduino circuit is shown below:

Schematic of our Arduino Uno R4 Wifi connected to an RGB LED

In the video, we develop code for the server, on the arduino, and the client, running in Python on the desktop. We present the code below for your convenience.

This is the Server code for the Arduino:

You will need to open a new tab, and save the following code as “secrets.h” with the program above.

On the Python side, this is the Client code:

 

Plot Live Data in Python Using PyQt5

In this video lesson we show you how to plot live data in Python using PyQt5. In this lesson, we generate the data in python on the fly, but in future lessons we will bring the data in from the Arduino Project over WiFi using UDP. For your convenience, the code we developed in this lesson is below: