I’m having trouble getting a GPS fix with a new asset tracker (V2). My code is below. Every minute my event log records a ticker update, and the GPS update returns “No Fix”. When I call the “gps” function, it returns “0”.
The GPS antenna isn’t blocked, and I’ve tested it both indoors and outdoors.
Does anyone know if this is a code problem, or maybe a hardware problem?
Thanks
//CODE
#include <AssetTracker.h>
#include <math.h>
AssetTracker t = AssetTracker();
FuelGauge fuel;
int led = D6; // This is where your LED is plugged in. The other side goes to a resistor connected to GND.
int ticker=0;
void setup()
{
Particle.variable("ticker",&ticker, INT);
Particle.function("gps", gpsPublish);
t.begin();
t.gpsOn();
}
void loop()
{
ticker = ticker+1;
delay(1000);
if (ticker % 60 == 0) {
// Ticker message to confirm particle and publishing is working
String Message = "Time = " + String(ticker/60);
Particle.publish("Minute",Message);
// Turn on GPS, Update it, and publish location
t.updateGPS();
if (t.gpsFix()){
Particle.publish("GPS", t.readLatLon(), 60, PUBLIC);
}
else{
Particle.publish("GPS", "No Fix");
}
}
}
int gpsPublish(String command) {
if (t.gpsFix()) {
Particle.publish("G", t.readLatLon(), 60, PRIVATE);
// uncomment next line if you want a manual publish to reset delay counter
// lastPublish = millis();
return 1;
} else {
return 0;
}
}