73. PathFinder Compass

Overview

  • In the given task, we have to create a device that can calculate the distance and direction between the camp location and the soldier's location.
  • Instead of an Army GPS device, we are going to send a GPS string via a Serial terminal to avoid hardware complexity.
  • Communication between the serial terminal and the MCU occurs via UART (Universal Asynchronous Receiver-Transmitter).
  • Since the GPS module operates at a baud rate of 9600, it is essential to set the baud rate of both the MCU and the serial monitor to 9600 to ensure proper communication.

Hardware Connection

We have to connect the MCU board to the PC using a USB cable.

Firmware 

  • In the given task, we have created our own custom GPS string.
    • String = X=18.532525,Y=73.850457”.
    • X = Latitude(degree)
    • Y = Longitude(degree)

Distance Calculation using the Haversine formula

  • We used the Haversine formula for distance calculation using latitude and longitude.
  • It’s used to calculate the shortest distance between two points on the Earth’s surface. It provides good accuracy for small distances.
Haversine-Formula-description

Note: In the given string, and Y coordinates are in degrees, so we have to convert them into radians

Direction calculation using the Bearing Angle

  • The bearing angle is used for the calculation of the direction between two points.
  • The bearing angle (also called the azimuth) is the angle between the north direction and the direction of the line connecting two GPS coordinates, measured clockwise from north.
  • It is a crucial concept in navigation, as it provides the direction from one point to another.
  • To calculate the direction, we first need to determine the bearing angle using the following formula.
Bearing-Formula-description
  • θ is in radians, so we have to convert it to degrees. And normalize it to [0 to 360].
  • Normalize the Bearing Angle
    • The bearing angle should be in the range [0°, 360°]. If the result is negative, add 360° to normalize it.
  • Depending on the bearing angle, we will decide which direction soldiers should travel.

 

Sr.NoRange of angleDirections
1.

337.5° to 360° 

 and

to 22.5°

North

2.

22.5° to 67.5°

 

Northeast

3.

67.5° to 112.5°

 

East

4.112.5° to 157.5°

Southeast

5.157.5° to 202.5°

South

6.202.5° to 247.5°

Southwest

7.

247.5° to 292.5°

 

West

8.292.5° to 337.5°

Northwest

 

So, by connecting and configuring the MCU and UART communication, we can implement the task.

Below are the solutions to the given task using different microcontrollers

  1. STM32
  2. ESP32
  3. Arduino UNO



 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!