0
votes

I want to connect Arduino nano and GNSS (SIMCom’s SIM33ELA standalone GNSS module).

First i wrote a program for rx/tx, wich is worked well, but now i want to use Software Serial and i got something wrong data.

#include <SoftwareSerial.h>
char incomingByte;   // for incoming serial data
double tbs;
SoftwareSerial mySerial(8, 9); // RX, TX
void setup() {
   Serial.begin(115200);     
   while (!Serial) {    
  }
  mySerial.begin(115200);
  while (!mySerial) {

  } 
}

void loop() {
    if (mySerial.available()) {
      tbs = mySerial.read();
      incomingByte = (char)tbs;
     Serial.print(incomingByte);
    }

   /*if (Serial.available() > 0) {        
      incomingByte = Serial.read();            
      Serial.print(incomingByte);              
      }*/

}

Any Idea?

Pictures about results:

Wrong data with Software serial

Good data with Serial

1
while (!mySerial) { } What's with that line? Did you see that in any of the SoftwareSerial Examples?Delta_G
Yes I saw.... but no one can help me ....Gábor Kőrösi
What SoftwareSerial example did you see that line in?Delta_G

1 Answers

0
votes

Mostly, don't read one character into a double floating-point variable. Just do this:

void loop()
{
  if (mySerial.available()) {
    char c = mySerial.read();
    Serial.write( c );
  }
}

You should also use AltSoftSerial on those two pins. SoftwareSerial is very inefficient, because it disables interrupts for long periods of time. It cannot transmit and receive at the same time. In fact, the Arduino can do nothing else while a character is transmitted or received.

For a GPS library, you could try NeoGPS. It's the only Arduino library that can parse the sentences from the newest devices. It's also smaller, faster, more reliable and more accurate than all other libraries.