I encounter the problem that I cannot get a GPS FIX with Model H. Unfortunately it is not possible to use search in this forum for words like gps, fix, led and so on.
I tried to build a minimal GPS client. I cannot get a GPS FIX with the following code.
I would be happy if someone more experienced could give me a hint what I am doing wrong.
Code: Select all
#include <FreematicsPlus.h>
#define GPS_SERIAL_BAUDRATE 115200L
#define USE_GNSS 2
FreematicsESP32 sys;
GPS_DATA* gd = 0;
uint32_t lastGPStime = 0;
void setup() {
delay(1000);
// initialize USB serial
Serial.begin(115200);
if (sys.begin(USE_GNSS == 1, USE_GNSS == 2)) {
Serial.print("TYPE:");
Serial.println(sys.devType);
}
gd = new GPS_DATA;
if (sys.gpsBegin(GPS_SERIAL_BAUDRATE)) {
Serial.println("GPS: module initialized");
}
else {
Serial.println("GPS: module is unavailable");
}
// init LED pin
pinMode(PIN_LED, OUTPUT);
digitalWrite(PIN_LED, LOW);
}
void printLocationData (GPS_DATA* gd) {
float kph = gd->speed * 1852 / 1000;
Serial.print("[GPS] - ");
if (gd->time != 0 && lastGPStime == gd->time) {
char buf[32];
sprintf(buf, "%02u:%02u:%02u.%c",
gd->time / 1000000, (gd->time % 1000000) / 10000, (gd->time % 10000) / 100, '0' + (gd->time % 100) / 10);
Serial.print(buf);
Serial.print(' ');
Serial.print(gd->lat, 6);
Serial.print(' ');
Serial.print(gd->lng, 6);
Serial.print(' ');
Serial.print((int)kph);
Serial.print("km/h");
if (gd->sat) {
Serial.print(" SATS:");
Serial.print(gd->sat);
}
Serial.println();
digitalWrite(PIN_LED, HIGH);
}
else {
Serial.println("NO FIX");
}
}
void loop() {
sys.gpsGetData(&gd);
printLocationData(gd);
delay (15000);
}
Code: Select all
TS : 0
Date : 260820
Time : 10203450
LAT : 0.00
LON : 0.00
ALT : 0.00
Speed : 0.00
Heading : 0
HDOP : 15
Sats : 0
Sentences: 0
Errors : 0