-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isValid is always False #19
Comments
Is that in the while (GPS.available()) {
char c = GPS.read();
...
} to while (GPS.available()) {
char c = GPS.read();
console.print(c);
...
} so that the incoming characters are printed? That should help identify where the problem is. |
Thanks for the response! I did add a print and the individual characters printed as expected. The issue was with the while loop in the example, it never met a condition to break from it. However, it may have been a typo in the example, as I just changed the while loop to encapsulate everything and it started producing valid data. I also realized this example script was part of an Arduino provided Portenta H7 GSM package, not necessarily directly from the MicroNMEA package. #include <GPS.h>
#include <GSM.h>
#include <MicroNMEA.h>
#include "arduino_secrets.h"
constexpr auto pin { SECRET_PIN };
constexpr auto apn { SECRET_APN };
constexpr auto username { SECRET_USERNAME };
constexpr auto pass { SECRET_PASSWORD };
char nmeaBuffer[100];
MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
// Keep track of NMEA string processing
auto nmeaProcessStatus { false };
// Check for valid fix every checkValidInterval ms
constexpr unsigned long checkValidInterval { 5000 };
unsigned long checkValidNow {};
void setup()
{
Serial.begin(115200);
for (const auto timeout = millis() + 2500; !Serial && millis() < timeout; delay(250))
;
// GSM.debug(Serial);
delay(1000);
Serial.println("Starting Carrier Network registration");
if (!GSM.begin(pin, apn, username, pass, CATM1)) {
Serial.println("The board was not able to register to the network...");
// do nothing forevermore:
while (1)
;
}
Serial.println("Enable GNSS Engine...");
// GPS.begin() start and eanble the GNSS engine
GPS.begin();
Serial.println("GNSS Engine enabled...");
Serial.println("Waiting for a valid fix.");
checkValidNow = millis();
}
void loop()
{
while (GPS.available()) {
char c = GPS.read();
// process is true when a valid NMEA string has been processed
nmeaProcessStatus = nmea.process(c);
// } this was where the original while loop ended
if (nmeaProcessStatus && millis() > checkValidNow) {
checkValidNow = millis() + checkValidInterval;
// Output GPS information from previous second
Serial.print("Valid fix: ");
Serial.println(nmea.isValid() ? "yes" : "no");
if (!nmea.isValid())
return;
String navSystem;
switch (nmea.getNavSystem()) {
case 'N':
navSystem = "GNSS";
break;
case 'P':
navSystem = "GPS";
break;
case 'L':
navSystem = "GLONASS";
break;
case 'A':
navSystem = "Galileo";
break;
default:
break;
}
Serial.print("Nav. system: ");
Serial.println(navSystem);
Serial.print("Num. satellites: ");
Serial.println(nmea.getNumSatellites());
Serial.print("HDOP: ");
Serial.println(nmea.getHDOP() / 10., 1);
Serial.print("Date/time: ");
Serial.print(nmea.getYear());
Serial.print('-');
Serial.print(int(nmea.getMonth()));
Serial.print('-');
Serial.print(int(nmea.getDay()));
Serial.print('T');
Serial.print(int(nmea.getHour()));
Serial.print(':');
Serial.print(int(nmea.getMinute()));
Serial.print(':');
Serial.println(int(nmea.getSecond()));
long latitude_mdeg = nmea.getLatitude();
long longitude_mdeg = nmea.getLongitude();
Serial.print("Latitude (deg): ");
Serial.println(latitude_mdeg / 1000000., 6);
Serial.print("Longitude (deg): ");
Serial.println(longitude_mdeg / 1000000., 6);
long alt;
Serial.print("Altitude (m): ");
if (nmea.getAltitude(alt))
Serial.println(alt / 1000., 3);
else
Serial.println("not available");
Serial.print("Speed: ");
Serial.println(nmea.getSpeed() / 1000., 3);
Serial.print("Course: ");
Serial.println(nmea.getCourse() / 1000., 3);
nmea.clear();
}
} // changed to end while loop here
}
|
I am using the Portenta H7 with Portenta Cat. M1/NB IoT GNSS Shield, tying to run MicroNMEA_integration.ino example in the Arduino IDE. My GPS device is returning valid strings with data for $GPGGA and $GNRMC but it never sees them as valid.
Also I think the code gets stuck in this loop as the stream of nmea strings is continuous:
I changed it to:
Then it does break from the loop but these lines always return no for nmea.isValid()
The text was updated successfully, but these errors were encountered: