-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPS \ GSM
More file actions
69 lines (63 loc) · 1.87 KB
/
GPS \ GSM
File metadata and controls
69 lines (63 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <TinyGPS.h>
#include <SoftwareSerial.h>
SoftwareSerial GPS(7,8); // configure software serial port
//SoftwareSerial gsm(9,10);
char speed=8;
int i;
// Create an instance of the TinyGPS object
TinyGPS shield;
void setup()
{
//pinMode(speed,INPUT);
GPS.begin(9600);
Serial.begin(9600);
// gsm.begin(9600);
}
// The getgps function will interpret data from GPS and display on serial monitor
void getgps(TinyGPS &gps)
{
Serial.println("AT+CMGF=1"); //select text mode
delay(1000);
Serial.println("AT+CMGS=\"9496617237\"");
// Define the variables that will be used */
float latitude, longitude;
// Then call this function
shield.f_get_position(&latitude, &longitude);
//gps.f_get_position(&latitude,&longitutde);
Serial.println("THE POSITION OF THE VEHICLE NUMBER ***** IS");
Serial.print("Latitude: ");
Serial.print(latitude);
Serial.print(" Longitude: ");
Serial.println(longitude);
Serial.println(" NALANCHIRA" );
Serial.print("Altitude ");
Serial.print(gps.f_altitude());
Serial.print("m ");
Serial.print(gps.f_speed_kmph());
Serial.println("km/h");
Serial.write(26);
/*Serial.println("yes the information is available");
Serial.println(latitude);
Serial.println(longitude);*/
}
void loop()
{
if((digitalRead(speed)==HIGH) || Serial.available()>0)
{
do
{ i=1;
byte a;
if ( GPS.available() > 0 ) // if there is data coming from the GPS shield
{
a = GPS.read(); // get the byte of data
if(shield.encode(a)) // if there is valid GPS data...
{
getgps(shield); // then grab the data and display it on the LCD
i=0;
}
else
continue;
}
}while(i=1);
}
}