I am having issues with using a BN-220 GPS module on both the Boron (402) and the Argon. I believe it has to do with Serial1. The GPS module works well with a Nodemcu (esp8266), and although it works on both the Argon and Boron, they both continually reset - sometimes after a few minutes and sometimes after hours of operation.
I started with Jordy Moors’s code, using the TinyGPS++ library, but couldn’t seem to get the GPS module to be read by the program. I then tried AssetTrackerRK.h which works well for periods of time (minutes to 10s of minutes) and then resets.
I gave up on using TinyGPS++ and used some code from the community (can’t remember who’s now - rickkas7 or ScruffA perhaps?) which just reads from Serial1 and publishes a message for Node Red to parse using a NMEA node.
However, both the Argon and Boron still reset after a period of time (usually less than an hour).
I assume the issue has something to do with how I’m using Serial1 but I don’t know why and not sure what to do next to find out.
Both the Argon and Boron are using firmaware v2.0.1
Latest codes is as follows (don’t really know how to include code):
SYSTEM_THREAD(ENABLED);
// Constants
const size_t READ_BUF_SIZE = 64;
const unsigned long CHAR_TIMEOUT = 10000;
unsigned long publishFreq = 30000;
unsigned long lastPublish = 0;
char GLL[7] = "$GNGLL";
char readBuf[READ_BUF_SIZE];
char gnGLL[READ_BUF_SIZE];
int overflow = 0;
char* reading;
size_t readBufOffset = 0;
unsigned long lastCharTime = 0;
void setup() {
Particle.variable("GLL",gnGLL);
Particle.variable("overflow",overflow);
Serial1.begin(9600);
}
void loop() {
// Read data from serial
while(Serial1.available()) {
if (readBufOffset < READ_BUF_SIZE) {
char c = Serial1.read();
if (c != '\n') {
// Add character to buffer
//readings[i][readBufOffset] = c;
readBuf[readBufOffset++] = c;
lastCharTime = millis();
}
else {
// End of line character found, process line
//readings[i][readBufOffset] = 0;
readBuf[readBufOffset] = 0;
readBufOffset = 0;
if (strncmp(readBuf,GLL,6) == 0) {
strcpy(gnGLL,readBuf);
}
if (millis() - lastPublish >= publishFreq) {
lastPublish = millis();
Particle.publish("$GNGLL", gnGLL);
Serial1.flush();
}
}
}
else {
Serial1.println("readBuf overflow, emptying buffer");
overflow++;
readBufOffset = 0;
}
}
if (millis() - lastCharTime >= CHAR_TIMEOUT) {
lastCharTime = millis();
readBuf[readBufOffset] = 0;
Particle.publish("got timeout: %s", readBuf);
readBufOffset = 0;
}
}