Basically the serial output is always zero. I’ve checked my connections, all seems fine. Tried the GPS on an arduino and it worked just fine also.
I amended the code, adding serial Prints to maybe see where the problem is, here it is;
String inWord;
char inByte;
String data;
int LockLED = D1;
void setup() {
// cloud variable
Particle.variable("STU", data);
// GPS Serial
Serial.begin(9600);
pinMode(LockLED, OUTPUT);
digitalWrite(LockLED, HIGH);
delay(2000);
digitalWrite(LockLED, LOW);
}
void loop() {
Serial.print("data: ");
Serial.println(Serial.available());
while (Serial.available() > 0) {
inByte = Serial.read();
if (inByte == '\n') {
// END OF LINE
Serial.print("inByte: ");
Serial.print(inByte);
// check is data we want
// you can change this to get any data line values
if (inWord.startsWith("$GPRMC")) {
// put data string in variable
data = inWord;
Serial.print("data: ");
Serial.print(data);
// clear the inword variable
inWord = "";
// does the GPS Receiver have lock?
// get the char at pos 17 and test to see if it is an A i.e VALID V = INVALID
char lock = data.charAt(17);
Serial.print("lock: ");
Serial.print(lock);
if (lock == 'A') {
// YES Switch on Lock LED
digitalWrite(LockLED, HIGH);
} else {
// NO turn off lock led
digitalWrite(LockLED, LOW);
}
} else {
// clear the inword variable as not the data we want
inWord = "";
}
} else {
// build data string
inWord += inByte;
}
} // end if serial
} // end loop
my output on the serial monitor is always “data: 0”
See the picture below :