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
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:
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.
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.
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:
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:
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:
/* This function will be invoked each time a new value comes to arduino from the
smartphones gps sensor. */
/* Turn on the led once any button is pressed*/
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.
Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …
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 …
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 …
“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, …
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 …
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. …