In order to learn how to create a lightweight interface with GPS devices I wrote a library to work with my NEO-6M GPS module.
With this library you can set the baud, sample rate, turn on/off individual NMEA sentences, and parse NMEA data. The source code is hosted on GitHub here.
Please take a look, critique it (I can use the constructive criticism ), and use it for your own projects if you want to.
Here is an example sketch that shows how to use the library:
#include "neo6mGPS.h"
neo6mGPS myGPS;
void setup()
{
 pinMode(13, OUTPUT);
 digitalWrite(13, HIGH);
Â
 Serial.begin(115200);
 while(!Serial);
Â
 myGPS.begin(Serial1);
}
void loop()
{
 if(myGPS.available())
 {
  Serial.print(myGPS.utc);   Serial.print(" | ");
  Serial.print(myGPS.navStatus); Serial.print(" | ");
  Serial.print(myGPS.lat);   Serial.print(" | ");
  Serial.print(myGPS.latDir);  Serial.print(" | ");
  Serial.print(myGPS.lon);   Serial.print(" | ");
  Serial.print(myGPS.lonDir);  Serial.print(" | ");
  Serial.print(myGPS.sog_knots); Serial.print(" | ");
  Serial.print(myGPS.cog_true); Serial.print(" | ");
  Serial.println();
 }
}
pert:
What is the purpose of these lines of your example sketch?:
 pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
I use Teensy 3.5 boards that do not have power leds like normal Arduinos. To work around this, all of my sketches use the pin 13 led as a makeshift power led.
Idk why an Arduino 33 BLE Sense would not have the class usb_serial_class in it's core. Maybe someone with more experience with such an Arduino can help. While I might take a look at adjusting the library, you're probably better off using NeoGPS.h instead.
I have tested this library on a Nano, Uno and on a Mega2560. None of these works with your example sketch
On the Nano and Uno the errormessage tells that Serial1 was not defined and on the Mega2560 it screams error: ‘usb_serial_class’ does not name a type
So… yeah… anybody has an idea what to do to make it work on a Nano? What I’m trying is to print the coordinates from the GPS to a SSD1306 OLED display (128x32) with the u8g2 library. I have a Neo-6M GPS module. Here my code:
#include "neo6mGPS.h"
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
neo6mGPS myGPS;
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);Â // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED
#define INFO_SCREEN_DELAY 3000
void setup()
{
 // turn on power led
 pinMode(13, OUTPUT);
 digitalWrite(13, HIGH);
  u8g2.begin();
 Serial.begin(115200);
 while(!Serial);
Â
 myGPS.begin(Serial1);
}
void loop()
{
 if(myGPS.available())
 {
  Serial.print(myGPS.utc_year); Serial.print(" | ");
  Serial.print(myGPS.utc_month); Serial.print(" | ");
  Serial.print(myGPS.utc_day); Serial.print(" | ");
  Serial.print(myGPS.utc_hour); Serial.print(" | ");
  Serial.print(myGPS.utc_min); Serial.print(" | ");
  Serial.print(myGPS.utc_sec); Serial.print(" | ");
  Serial.print(myGPS.lat_dd);  Serial.print(" | ");
  Serial.print(myGPS.lon_dd);  Serial.print(" | ");
  Serial.print(myGPS.sog_knots); Serial.print(" | ");
  Serial.print(myGPS.cog_true); Serial.print(" | ");
  Serial.print(myGPS.navStatus);
  Serial.println();
  char mylat=myGPS.lat_dd;
  char mylon=myGPS.lon_dd;
   u8g2.clearBuffer();
 u8g2.setFontMode(1);
 u8g2.setFont(u8g2_font_cu12_tr); Â
 u8g2.setCursor(0,15);
 u8g2.print("Link: ");
 u8g2.setCursor(0,30);
 u8g2.print(mylat);
 u8g2.setCursor(20,30);
 u8g2.print(mylon);Â
 u8g2.sendBuffer();
 delay(1000);
 }
}
Yeah, the lib was written for Teensy MCUs only and was honestly more of a personal academic exercise that I figured others might find useful. I suggest using NeoGPS.h instead.