Arduino GPS Shield Functions Explainer

Today I’ll be explaining the functions of the Arduino GPS shield in 1Sheeld and how to use it to get longitude and latitude locations.

The Arduino GPS shield in 1Sheeld allows you to use your smartphone as a GPS receiver to be able to track your Arduino project wherever it is, using the GPS sensor on your smartphone.

If it’s the first time to hear of 1Sheeld board or didn’t use it before then it will be nice of you to check 1Sheeld’s getting started tutorial and then get back here.

First, it is important to understand how the GPS sensor works. GPS stands for Global Positioning System, and a GPS system is a receiver with an antenna that uses a network of 24 satellites covering Earth’s orbit. They provide position, timing and velocity information. Based on that, you can determine a single point of intersection between the longitude and latitude lines.


                                                                     BBC illustration of longitude and latitude lines

Now that we know how a GPS sensor works, let’s use the Arduino GPS shield by downloading 1Sheeld library, to access its functions.

1Sheeld Arduino GPS shield functions

  • getLatitude
  • getLongitude
  • isInRange
  • getDistance
  • radian
  • setOnValueChange

The first 2 functions: getLatitude and getLongitude

These are the 2 main functions of the Arduino GPS shield, they get the latitude and longitude data f the smartphone, so you are able to get its location.

From the description of the functions, you realize it has no parameters and 1 return value which is the latitude and the longitude. The values are returned as a float.

The syntax for these functions are:

GPS.getLatitude();

GPS.getLongitude();

A good use of these functions is the GPS car tracking device project by Mohammed Selim, where he put an Arduino, a 1Sheeld and a smartphone inside his car. The Arduino GPS shield in 1Sheeld gets the longitude and latitude of the car and the Arduino sends him an SMS containing the coordinates of the car.

isInRange function

Assume that you are building a project to know if your car is stolen or not. So, you put an Arduino GPS system in your car, you set a specific coordinates ranging 20 meters away from home, and you want to know if your car gets out of this range or not.

This is exactly what the isInRange function does. Form the description, you get to know that you need to feed this function the following parameters:

  • A certain latitude
  • A certain longitude
  • The maximum range of meters you would specify

The return would be a yes or no, which means a boolean return.

The syntax for this function is:

GPS.isInRange(latitude,longitude,range);

Example of this function:

getDistance

This function returns a distance between a given latitude and longitude, and the smartphone in your Arduino GPS project. The distance is returned in the form of a float representing the distance in meters.

To do that, you have to send 2 parameters which are the latitude and the longitude of the specific location you want to measure the distance between it and the Arduino GPS project.The syntax for this function is:

float GPS.getDistance(fixedLatitude,fixedLongitude);

radian

This is a helper function that converts the value of a GPS latitude or longitude reading from degree to radian. The default values from the Arduino GPS s come in a degrees format, but in some calculations, you’ll need to use the value in radian.

The function takes a float parameter in degrees and returns a float parameter in radians.

The syntax for this function is:

GPS.radian(latitude/longitude);

Finally, the setOnValueChange function

This is a default function in all 1Sheeld Arduino shields, it indicates a change in any of the values of a certain sensor shield, which in this case: The Arduino GPS shield.

This function triggers a function written by the user to run once there is a change in the latitude or longitude value.The syntax for this function is:

GPS.setOnValueChange(&userFunctionName);

An example of this function is:

At the end, I hope I have covered all the Arduino GPS Shield functions very clearly and if you have any queries please share them with me down in the comments.
And of course, don’t forget to check out lots of Arduino Projects made using 1Sheeld especially, that many of them have used the Arduino GPS shield.




Related Blogs

Arduino IoT

Arduino IoT Shield Functions Explainer

Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …

Arduino Plant Watering System

Arduino Plant Watering System (Arduino Home Hacks #3)

 Arduino Plant Watering System Welcome to our home automation hacks series #3, for so many times I had problems with watering my plants while traveling abroad and I have always needed a way to control it remotely, then I decided to do it with one of the fanciest ways you may ever hear off, …