Aim:
A GPS module is a device that uses Global Positioning System to determine the location of a vehicle or person. GPS receivers are used to provide reliable navigation, positioning and timing services to the users at anytime and anywhere on the earth. This Global positioning system uses 24 to 32 satellites to provide the data to the receivers. GPS has become very important for worldwide navigation and it is useful for land surveying, way marking, map-making, tracking and surveillance commerce and scientific uses.
Description:
GPS receivers have many applications in aircraft, ships, sea vessels and the like for navigation purposes. Smartphones with maps (like Google Maps) find routes to a specific destination such as a restaurant, hospital or hotel. With the help of a GPS, a target camp can be located and a missile launched to destroy it.
The GPS receiver module includes an antenna and a built-in processor. The built-in processor calculates the required information from the signals’ output serially in form of strings using NMEA (expanded as National Marine Electronics Association) 0183 protocol. These strings are received serially by the host computer for display or by host processor/controller to take any decision or action.
NEMA protocol includes standard messages given by the GPS receiver. Some standard message outputs from NMEA are GGA, ZDA, VTC, RMC, GSA and GSV. The string starts with $GPRMC tag and gives time, latitude, longitude, etc.
Block Diagram
Schematic
Code
// ***************************************************
// Project: Interfacing GPS module with Arduino
// Author: Hack Projects India
// Module description: Operate GPS
// ***************************************************
String inputString = ""; // a string to hold incoming data
String lat="",lon="";
void setup() {
// initialize serial:
Serial.begin(9600);
}
void loop() {
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\r'||inChar == '\n') {
if(inputString[0]=='$'&&inputString[1]=='G'&&inputString[2]=='P'&&inputString[3]=='R'&&inputString[4]=='M'&&inputString[5]=='C'&&inputString[18]=='A')
{
Serial.print("Latitude=");
Serial.write(inputString[20]);
Serial.write(inputString[21]);
Serial.write('.');
Serial.write(inputString[22]);
Serial.write(inputString[23]);
Serial.write(inputString[25]);
Serial.write(inputString[26]);
Serial.write(inputString[27]);
Serial.write(inputString[28]);
Serial.println(" ");
Serial.print("Longitude=");
Serial.write(inputString[32]);
Serial.write(inputString[33]);
Serial.write(inputString[34]);
Serial.write('.');
Serial.write(inputString[35]);
Serial.write(inputString[36]);
Serial.write(inputString[38]);
Serial.write(inputString[39]);
Serial.write(inputString[40]);
Serial.write(inputString[41]);
Serial.println(" ");
}
inputString = "";
}
else{
inputString += inChar;
}
}
}
No comments:
Post a Comment