Use NEO-6m GPS on Nano BLE sense without SoftwareSerial

Hello

my project is basically a datalogger that is supposed to write IMU and GPS data onto an SD-Card.
The logging and everything works, but I cant read the GPS module.
With my UNO I am able to read the GPS data.

On the nano I cant use the Gpsneo library, since it seems to need the SoftwareSerial library which does not work on the Nano BLE sense.

I use an example of the library:

#include <SoftwareSerial.h>
#include <Gpsneo.h>

Gpsneo gps(0,1);  //(rx,tx)


char time[10];
char status[3];
char latitud[11];
char latitudHemisphere[3];
char longitud[11];
char longitudMeridiano[3];
char speedKnots[10];
char trackAngle[8];
char date[10];
char magneticVariation[10];
char magneticVariationOrientation[3];


void  setup()
{
    Serial.begin(9600);
}
void loop()
{
    //Just simple do getDataGPRMC, and the method solve everything.
    gps.getDataGPRMC(time,
                    status,
                    latitud,
                    latitudHemisphere,
                    longitud,
                    longitudMeridiano,
                    speedKnots,
                    trackAngle,
                    date,
                    magneticVariation,
                    magneticVariationOrientation);

   Serial.println(time);
   Serial.println(status);
   Serial.println(latitud);
   Serial.println(latitudHemisphere);
   Serial.println(longitud);
   Serial.println(longitudMeridiano);
   Serial.println(speedKnots);
   Serial.println(trackAngle);
   Serial.println(date);
   Serial.println(magneticVariation);
   Serial.println(magneticVariationOrientation);
}

I get the following error message:

minimumRecommendedFull:1:10: fatal error: SoftwareSerial.h: No such file or directory

 #include <SoftwareSerial.h>

          ^~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1
SoftwareSerial.h: No such file or directory

How can I read the GPS data without software serial?

I am a real newbie to arduino...

Thanks in Advance!

I found some kind of solution myself, if someone faces the same problem.
However it does not do anything to the NMEA sentences, it only prints them to Serial

Use the tinyGPS++ library
connect GPS RX -> Arduino TX and TX to RX

#include <TinyGPS++.h>
TinyGPSPlus gps;

void setup() {
  Serial1.begin(9600);
  Serial.begin(9600);
}

void loop() {
  while (Serial1.available()) {
    if (gps.encode(Serial1.read())) {
      String msg = Serial1.readStringUntil('\r');
      Serial.print(msg);
    }
  }
}
2 Likes

Its not just some kind of solution. You found the way it should be done. Software Serial should be avoided whenever you have hardware serial also known as UARTs available. Many of the newer microcontroller have multiple of them and you should make use of them, because doing it in software requires quite a lot of processor resources and is time critical.

UARTs use a asynchronous protocol. That means the receiver has to kind of guess when the signal from the sender is valid. This is done by agreeing a fixed speed and by starting with a know condition e.g. signal changing from HIGH to LOW after it has been HIGH for a certain amount of time. Then for a short amount of time bits can be send and will be sampled by the receiver. But because clocks will never run exactly at the same speed after a while the sending and receiving clocks will drift away and the signal can no longer be read with certainty. So a short break has to be inserted. e.g. after every byte.

Synchronous protocols (e.g. SPI, I2C) use a clock signal to tell the receiver when the data is valid.

Regarding the NMEA sentences. The the gps.ecode() function decodes the NMEA messages when the message has been received completely and stores them in internal variables. You just need to read them. Every time you call the function and give it one byte it checkes whether the message is completed and has no errors. If so the values will be extracted and stored internally. You can then use the class functions to retrieve them. Have a look at the examples.

If you have any question feel free to ask.