Hello support community,
I would appreciate your support in the following situation:
I have a M9N Sparkfun i2c, an Arduino MEGA and the Sparkfun UBLOX GNSS Library.
In the code’s loop (see below), I am constantly asking for the coordinates ant other data (with approx 2 seconds between each set of interrogations); The device works well for a random time (5 minites to 4 hours), and then freezes. Using my noob investigation methods (serial println’s everywhere in the code), i noticed it freezes right when calling the myGNSS.getLatitude(); I also printed the library’s debug, using: myGNSS.enableDebugging(Serial, false);
The debug freezes here:
...Test 1
...Sending: CLS:NAV ID:PVT Len: 0x0 Payload:
...sendCommand: Waiting for No ACK response
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: Reading 100 bytes
...
Whyle it normally prints the whole thing as so:
...Test 1
...Sending: CLS:NAV ID:PVT Len: 0x0 Payload:
...sendCommand: Waiting for No ACK response
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: OK, zero bytes available
...checkUbloxI2C: Reading 100 bytes
...Incoming: Size: 92 Received: CLS:NAV ID:PVT Len: 0x5C Payload: 58 16 62 16 E7 7 2 2 8 12 1D 37 1E 0 0 0 86 AD FB FF 3 3 FA 18 F9 E3 8B F 84 8E 80 1A D3 14 2 0 C2 8C 1 0 36 8 0 0 BE A 0 0 1 0 0 0 F9 FF FF FF FA FF FF FF 7 0 0 0 7A 87 F3 0 DF 0 0 0 DD 4D 5C 0 5F 0 0 0 EE 13 4F 2F 0 0 0 0 0 0 0 0
...packetCfg now valid
...packetCfg classAndIDmatch
...waitForNoACKResponse: valid data with CLS/ID match after 852 msec
My loop code is:
void loop() {
bool dateTimeCheck = false;
int del = 250; //printing delay times
printingActive = false;
twist.setColor(100, 100, 100);
delay(1000);
if (millis() - lastTime > 1200000) {
printingActive = true;
lastTime = millis();
}
if (twist.isPressed()) {
twist.setColor(0, 255, 0); //Set the Red, Green, and Blue LED brightnesses
printingActive = true;
printer.wake();
delay(1000);
//printData("", 200);
//printer.flush();
}
pressure = sezorBME.readFloatPressure() * 0.00750062;
temperature = sezorBME.readTempC();
delay(500);
twist.setColor(0, 0, 100); //Set the Red, Green, and Blue LED brightnesses
delay(500);
Serial.println("Test 1");
latitude = myGNSS.getLatitude(1500) / 10000000.000000;
delay(100);
longitude = myGNSS.getLongitude(1500) / 10000000.000000;
delay(100);
heading = myGNSS.getHeading(1500) / 100000.0000; //degrees
delay(100);
speed = myGNSS.getGroundSpeed(1500) * 0.00194384; //mm/s to knots
delay(100);
SIV = myGNSS.getSIV(1500);
delay(100);
Serial.println("Test 2");
if (SIV > 7 && speed > 0.8 && myGNSS.getGnssFixOk()) {
//getGnssFixOk
distanceLog += distanceInKmBetweenEarthCoordinates(ilatitude, ilongitude, latitude, longitude);
ilatitude = latitude;
ilongitude = longitude;
//distanceLog2 = myGNSS.assumeAutoNAVODO(bool enabled)
}
delay(100);
year = myGNSS.getYear(1500);
delay(100);
month = myGNSS.getMonth(1500);
delay(100);
day = myGNSS.getDay(1500);
delay(100);
hour = myGNSS.getHour(1500);
delay(100);
minute = myGNSS.getMinute(1500);
delay(100);
second = myGNSS.getSecond(1500);
delay(100);
Serial.println("07 - read date");
//myGNSS.setDGNSSConfiguration()
String datecheck = String("");
if (myGNSS.getTimeValid(1500) && myGNSS.getDateValid(1500)) {
datecheck = datecheck + "DT: OK";
} else {
datecheck = datecheck + "DT: NOT OK";
}
String title = "\n** BOOK ENTRY nr." + String(logbookEntry) + " **\n";
String dateTime = String(year) + "/" + String(month) + "/" + String(day) + ", " + String(hour) + ":" + String(minute) + ":" + String(second) + "; ";
//String coords1 = "LAT: " + String(latitude, 6) + ";";
//String coords2 = "LONG: " + String(longitude, 6) + ";";
String coords = "LAT: " + String(latitude, 6) + "; LONG: " + String(longitude, 6) + ";";
String navi = "HEADING: " + String(heading, 3) + "; ";
String navi2 = "SPD: " + String(speed, 2) + "; ";
String logprint = "Dist. log: " + String(distanceLog, 2);
String logprint2 = "Dist. log2: " + String(distanceLog2, 2);
String weather = "T: " + String(temperature, 2) + ", P: " + String(pressure, 3);
String other = "SIV: " + String(SIV) + "; Sail[ ]/Engine[ ]\nWIND Spd:______WIND Dir:______";
Serial.println("\nDATA Pack:\n");
Serial.println(dateTime);
Serial.println(datecheck);
Serial.println(coords);
Serial.println(navi);
Serial.println(navi2);
Serial.println(logprint);
Serial.println(logprint2);
Serial.println(weather);
Serial.println(other);
Serial.println();
if (printingActive == true) {
//printer.justify('C');
//printer.printBitmap(traversLogo_width, traversLogo_height, traversLogo_data);
//printer.feed(1);
//--------------------------------
printEntry(title, del);
//--------------------------------
printTitle("DATE/TIME:", del);
printDataL(dateTime, del);
printData(datecheck, del);
//--------------------------------
printTitle("COORDS:", del);
printData(coords, del);
//printData(coords2, del);
//--------------------------------
printTitle("NAVI:", del);
printData(navi + navi2, del);
//printDataL(navi2, del);
printData(logprint, del);
printData(logprint2, del);
//--------------------------------
printTitle("WEATHER:", del);
printData(weather, del);
printData("Prs. diff: " + String(pressure - lastPressure, 3), del);
//--------------------------------
printTitle("OTHER:", del);
printData(other, del);
}
twist.setColor(100, 100, 100);
delay(1000);
if (printingActive == true) {
printer.feed(2);
printingActive = false;
printer.sleep();
logbookEntry++;
lastPressure = pressure;
}
}
Any opinions and recommendations? Thank you very much!
George