Using NeoGPS with Nano 33 IoT

I am trying to use the library NeoGPS with a Nano 33 IoT.
According to the link above, it is compatible with samd.

From what I understand, Hardware Serial can be used, however the pins must be defined. I'd like to not use the RX/TX pins on the board so I do not have to disconnect when uploading a sketch.

When I try to compile the basic example (NMEA.ino) I get an error "trace_all not declared in this scope" which I'm guessing is related to the serial issue.

Can anyone point me in the right direction of how to define the new hardware serial ports to use it with NeoGPS?

No need to worry. The Arduino Nano 33 IoT has native USB and therefore RX and TX are not used for the Serial Monitor. To use the pin you need to use Serial1 instead of Serial. Serial is a virtual serial over USB and Serial1 is using the UART.

Thanks for the info.
I tried to use Serial1 and received the same errors.
It seems that the errors compiling lie in the Streamers.h file.

I get a huge list of errors when compiling. Most of them are "reference to Print ambiguous" and then things related to trace_header and trace_all are declared void or "not declared"

I get these errors without changing anything on the library. Same errors after I modified GPSport.h to only include the 3 lines for Serial1.

I found this on Github

https://github.com/SlashDevin/NeoGPS/issues/144

As suggested I just commented the line "class Print;" in DMS.h and NeoTime.h and the code compiles. There are still a pile of warnings. Give it a try.

It looks like the library has not been touched for years. I am not sure if that is good or bad.

Any reason why you are not using TinyGPS or TinyGPS++? I do not find the marketing message from NeoGPS convincing. :slight_smile: The library seems complicated just to save a few bytes of RAM. TinyGPS is two files with a total of 600 lines of standard code.

I would happily use TinyGPS++, however it relies on SoftwareSerial in its code, and this unit doesn't support SoftwareSerial. (compiling errors).
I'm not sure how to modify the code to use Hardware Serial.
I'm quite new at all of this. Thanks

No worry, it does not. Can you post your code?

Just remove the SoftwareSerial header file in your code and then use Serial1.

I'm trying to run the example "DeviceExample"

I have it boiled down to:

#include <TinyGPS++.h>
static const int RXPin = 3, TXPin = 2;
TinyGPSPlus gps;
Serial1 ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
//  ss.begin(GPSBaud);
}
void loop()
{
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

Then it continues to display the data.

I know line #4 here is wrong. I don't know how to declare Serial1 to be able to continue to use the ss() function.

You can use #define to tell the compiler to replace some text with something else.

https://www.arduino.cc/reference/en/language/structure/further-syntax/define/

#include <TinyGPS++.h>
TinyGPSPlus gps;
#define ss Serial1

void setup()
{
  Serial.begin( 115200 );
  ss.begin( GPSBaud );
}
void loop()
{
  while ( ss.available() > 0 )
    if ( gps.encode( ss.read() ) )
      displayInfo();
  if ( millis() > 5000 && gps.charsProcessed() < 10 )
  {
    Serial.println( F( "No GPS detected: check wiring." ) );
    while ( true );
  }
}

May I recommend you go one step further and redefine Serial1 with a specific name e.g.

#define gpsSerial  Serial1

Then replace all ss. with gpsSerial. e.g. gpsSerial.read() This will make the code easier to read especially when you read it in a few weeks.

Serial1 uses the pins TX and RX. See Arduino Nano 33 IoT Pinout diagram.

1 Like

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