hi R,
This is a simple program for an Arduino.
E
This is a simple program for an Arduino.
E
C-like:
// ESP/57 GPS extract coordinates
// Arduino
String strID ="";
String strTime="";
String strLat="";
String strLong="";
String GPSmessage = ""; // message buffer
bool msgEOL = false; // EOL flag
void setup() {
// initialize serial:
Serial.begin(9600); // user local
Serial1.begin(9600); // gps sensor port
// reserve 100 bytes for the GPSmessage:
GPSmessage.reserve(100);
}
void loop() {
// print the GPS message when a Fix arrives:
// if all GPS message types are being received, select 'GG' type
if (msgEOL) {
// Serial.println(GPSmessage); // Use to Check raw message
strID=(GPSmessage.substring(4,6));
if (strID == "GG"){
Serial.print("$");
Serial.print(GPSmessage.substring(8,14));
Serial.print(",N");
Serial.print(GPSmessage.substring(18,28));
Serial.print(",E");
Serial.println(GPSmessage.substring(31,42));
}
//clear the smessage:
GPSmessage = "";
strID="";
msgEOL = false;
}
}
// SerialEvent#1 occurs new GPS RXD message.
void serialEvent1() {
while (Serial1.available()) {
// get the new byte:
char gpsChar = (char)Serial1.read();
// add it to the GPSmessage:
GPSmessage += gpsChar;
// if the incoming character is a newline, set a EOL true
if (gpsChar == '\r') { // return code , no LF!
msgEOL = true;
}
}
}
Last edited: