I am using a Photon with a GPS module. My code works however I have an issue upon startup where the photon breathes green. If I repeatedly power on the system it eventually connects, breathes cyan and publishes to the cloud however; it takes roughly 10 minutes. It has something to do with the GPS connecting and before I rip my code apart I figured I would see if anyone can see an obvious error in my code that would cause the photon to breathe green.
void loop() {
Blynk.run();
if (millis() > startTime + 60000) {
startTime = millis();
Particle.publish("GPS1 Location", slocation);
}
while (Serial1.available() > 0)
if (gps.encode(Serial1.read())) {
displayInfo();
delay(2000);
}
if (millis() > 5000 && gps.charsProcessed() < 10) {
msg5 = "No GPS detected";
Blynk.virtualWrite(V5, msg5);
while(true);
}
}
void displayInfo() {
if (gps.location.isValid()) {
lat = gps.location.lat();
lon = gps.location.lng();
Blynk.virtualWrite(V0, 1, lat, lon, "car");
slocation = String(lat) + "," + String(lon);
msg5 = "Good Signal";
Blynk.virtualWrite(V5, msg5);
}
else
{
msg5 = "Poor Signal";
Blynk.virtualWrite(V5, msg5);
}
}