-
Notifications
You must be signed in to change notification settings - Fork 39
/
Stupendous.ino
88 lines (78 loc) · 2.12 KB
/
Stupendous.ino
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <TinyGPS++.h>
#include <SoftwareSerial.h>-
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
static const int RXPin = 4, TXPin = 5;
static const uint32_t GPSBaud = 9600;
int a=13;
TinyGPSPlus gps;
WidgetMap myMap(V0);
SoftwareSerial ss(RXPin, TXPin);
BlynkTimer timer;
float spd;
float sats;
String bearing;
char auth[] = "RuiuXjdjHNad9nWFLkjXD2675k21LUTB";
char ssid[] = "Aditya Bansal";
char pass[] = "1357924680";
unsigned int move_index = 1;
void setup()
{
Serial.begin(115200);
Serial.println();
ss.begin(GPSBaud);
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, checkGPS);
pinMode(a,INPUT);
}
void checkGPS(){
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
Blynk.virtualWrite(V4, "GPS ERROR");
}
}
void loop()
{
if (digitalRead(a)==LOW)
{
while (ss.available() >0)
{
if(gps.encode(ss.read()))
displayInfo();
}
if (gps.location.isUpdated())
{
if (gps.encode(ss.read()))
displayInfo();
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
}
Blynk.run();
timer.run();
}
void displayInfo()
{
if (gps.location.isValid() )
{
float latitude = (gps.location.lat()); //Storing the Lat. and Lon.
float longitude = (gps.location.lng());
Serial.print("LAT: ");
Serial.println(latitude, 6);
Serial.print("LONG: ");
Serial.println(longitude, 6);
Blynk.virtualWrite(V1, String(latitude, 2));
Blynk.virtualWrite(V2, String(longitude, 2));
myMap.location(move_index, latitude, longitude, "GPS_Location");
spd = gps.speed.kmph(); //get speed
Blynk.virtualWrite(V3, spd);
sats = gps.satellites.value();
bearing = TinyGPSPlus::cardinal(gps.course.value()); // get the direction
Blynk.virtualWrite(V5, bearing);
}
Serial.println();
}