Created
December 2, 2016 11:39
-
-
Save HeinPauwelyn/abda9c038413adaed60030afe485200e to your computer and use it in GitHub Desktop.
GPS data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
bool gotGPGGA = false; | |
int teller = 0; | |
String text = ""; | |
String json = ""; | |
if (SoftSerial.available()) | |
{ | |
while (SoftSerial.available()) | |
{ | |
char read = SoftSerial.read(); | |
buffer[count++] = read; | |
if (String(read) == ",") { | |
if (text == "$GPGGA") { | |
gotGPGGA = true; | |
} | |
if (gotGPGGA) { | |
switch (teller) { | |
case 1: | |
json += "{ \"uur\": \"" + text.substring(0, 2) + ":" + text.substring(2, 4) + ":" + text.substring(4, 6) + "\", "; | |
break; | |
case 2: | |
json += "\"lat\": \"" + text + "\", "; | |
break; | |
case 3: | |
json += "\"latChar\": \"" + text + "\", "; | |
break; | |
case 4: | |
json += "\"lon\": \"" + text + "\", "; | |
break; | |
case 5: | |
json += "\"lonChar\": \"" + text + "\" }"; | |
break; | |
} | |
teller += 1; | |
} | |
text = ""; | |
} | |
else { | |
text += read; | |
} | |
if (count == 64) { | |
if (json != "") { | |
Serial.println(json); | |
} | |
break; | |
} | |
} | |
delay(2000); | |
clearBufferArray(); | |
count = 0; | |
} | |
} | |
void clearBufferArray() | |
{ | |
for (int i = 0; i < count; i++) | |
{ | |
buffer[i] = NULL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment