Skip to content

Instantly share code, notes, and snippets.

@adamfowleruk
Created July 13, 2014 22:51
Show Gist options
  • Save adamfowleruk/db642b44f9bee7ea5100 to your computer and use it in GitHub Desktop.
Save adamfowleruk/db642b44f9bee7ea5100 to your computer and use it in GitHub Desktop.
NMEA decoder and Airbot UBlox GPS working on Arduino Pro Mini 3.3V
#include <nmea.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX - change for your connections
NMEA nmeaDecoder(ALL);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(9600); // UBlox data rate is low by default
}
void loop() // run over and over
{
if (mySerial.available()) {
if (nmeaDecoder.decode(mySerial.read())) {
Serial.print("Lon: ");
Serial.print(nmeaDecoder.gprmc_longitude());
Serial.print(", Lat: ");
Serial.print(nmeaDecoder.gprmc_latitude());
Serial.print(", Speed: ");
Serial.print(nmeaDecoder.gprmc_speed(KMPH));
Serial.print(", Course: ");
Serial.println(nmeaDecoder.gprmc_course());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment