Using Serial with a Boron 404x

Hello,
I am looking to use a Boron 404x and a GPS module to receive GPS cords and send them as an event. I cannot figure out how to work the serial as there is no software serial for the Boron 404x. I used a simple example from Adafruit that used software serial. If someone could explain how to convert software serial into useable serial for the Boron 404x I would really appreciate it. Below is what I currently have:

#define GPS_SERIAL       Serial1
#define GPS_BAUD         9600
#define GPS_UPDATE_DELAY 60000

Adafruit_GPS GPS(&GPS_SERIAL);

void setup() {
    GPS.begin(GPS_BAUD);
    GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
    GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
    delay(1000);
    String setup_str = "starting";
    Particle.publish("GPS Update", setup_str, PRIVATE);
}

void loop() {
   GPS.read();

  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA())) // Check if we successfully parsed the NMEA sentence
      return;
  }

  if (GPS.fix) {
    float latitude = GPS.latitudeDegrees;
    float longitude = GPS.longitudeDegrees;
    String fixed = "FIXED";
    Particle.publish("GPS Update", fixed, PRIVATE);
    String data = "lat: " + String(latitude, 6) + ", lon: " + String(longitude, 6);
    Particle.publish("GPS Update", data, PRIVATE);
  } else {
    String not_fixed = "not fixed";
    Particle.publish("GPS Update", not_fixed, PRIVATE);
  }

  delay(GPS_UPDATE_DELAY);
}

That looks mostly correct. What is the problem you are having? A compile issue? What events are you getting in the console?

You may want to switch to using USB serial debugging instead of publishing events.

Also since you set the update frequency to 1 Hz but also have a delay at the bottom of the loop, it's possible that the sentences will be corrupted because the overflow the serial buffer. The best thing to do is call GPS.read through GPS.parse as often as possible, and use a different technique to lower the publish rate than using delay.

Thanks for the reply. I used an example from the asset tracker example and got it working.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.