Using SoftwareSerial to read data from GPS at 57600 baud


I am having some difficulties reading data from my gps ( at 57600 baud. Reading at 9600 baud works ok’ish (sometimes a character is dropped, but not often), but when reading at 57600 baud using SoftwareSerial characters are consistently dropped. It seems that it is mostly the \r\n characters.
I have made the following very short sketch that shows the problem:

//#include <SoftwareSerial.h>
#include <AltSoftSerial.h>

// setup gps serial
int gpsTxPin = 8;
int gpsRxPin = 9;
//SoftwareSerial gpsSerial(gpsTxPin, gpsRxPin);
AltSoftSerial gpsSerial;

void setup()

void loop()
    char c =;

Running the above with AltSoftwareSerial, or hardware serial, works perfectly and I can see a string of correct nmea sentences printed on the serial monitor. When I use SoftwareSerial, the nmea sentences are not separated correctly with \r\n.

Any ideas on why?

ps. when I did the test, I had the GPS configured for 57600 baud, 5hz output and GPRMC and GGA nmea sentences.

ALtSoftSerial is a better "software" serial as it uses hardware interrupts to receive data.

The normal software serial heavily depends on the absence of "disturbing" interrupts
which corrupts its timing especially at higher baud rates..

The normal software serial heavily depends on the absence of "disturbing" interrupts
which corrupts its timing especially at higher baud rates..

I hope this is not the case. It would be disappointing if the standard software serial library couldn't handle 57600 baud, and something that would need to be made very clear in the documentation.
However, I am not sure this is the case. The altsoftwareserial page (AltSoftSerial Library, for an extra serial port) states that both that and the normal softwareserial is good for at least 57600 baud.

For my project, I am having a hard time using the altsoftwareserial as that uses the same pins as my CAN-BUS shield. So unless I want to make some hardware changes to the shield, I don't think the combination work :frowning:

Outputting data at 115200 baud (using hardware serial) causes quite a few interrupts. It is possible you are actually receiving the data correctly but not sending it, or maybe vice-versa. Combining software and hardware serial can push the hardware over the edge. How about decoding the GPS data and only outputting the decoded data?

Your trivial example, although it might seem good to "prove it works" is actually the thing most likely to fail.

At 115200 baud you need an interrupt every 87 µS, however at at 57600 baud the SoftwareSerial library will turn interrupts off for 173 µS while it receives one byte. You can see there could be problems combining them.

Ahh yes, that might be a problem. I will try and modify the example so that it doesn't read and write at the same time, and see if that helps.