Connor

a space for my professional and personal development.

Dealing with an Arduino Nano with 3 Serial Ports

Get rid of the gibberish from receiving/transmitting via your virtual soft serial ports on your Arduino Nano.

Gibberish you say?

Yes like this nasty ugly annoying character: �
All things aside, I’m not going to get into depth regarding why this occurs on a lower theoretical level which for those of us who do know it involves system timers, interrupt handling, processor utilization, etc.
At an attempt to mitigate loss of property I decided to make a GPS tracker with an Arduino Nano and an A7 module. My setup was pretty simple. It consisted of the A7 and Arduino Nano. The first Serial port was hardware and was used for software debugging and AT command responses. This port was set a 9600 baud. The second Serial port was virtual using SoftSerial.h and was set a 57600 baud. My third Serial port was using AltSoftSerial.h and was set at 9600 baud.

Serial Setup

Serial 1 -> PC Arduino IDE (9600)
Serial 2 -> Arduino Nano (D2, D3) -> A7 (UTXD, RTXD) (57600)
Serial 3 -> Arduino Nano (D8) -> A7 (GPS) (9600)

Why?

Although we could have chosen higher baud rates I decided after multiple trials to stick with lower baud rates. The caveat here is that all three serial ports on the Arduino Nano have to be equal to each other or at least of a lesser speed. For example I could obviously change the speed of Serial 1 on the Arduino, On Serial 2 we could also change the Serial speed by issuing “AT+IPR=57600” command. I chose 57600 because at the time I had set the speed on Serial 1 to 115200 and anything but 57600 on Serial 2 didn’t seem to work as it resulted in gibberish characters. But the issue then rolled over to the GPS interface of the A7 module. When I had set Serial 1 to 115200 the responses from the GPS TX pin on the A7 contained to much gibberish upon output to the monitor. Throughout multiple test I concluded that it was in fact that the two interfaces were at different speeds which was causing this issue. The A7 does not allow you to change the speed of the GPS TX pin, it’s hard coded at 9600. My solution was to change Serial 1 from 115200 to 9600. Occasionally I do get some gibberish characters here and there, but there is significantly a lot less than before if not none.
This was a result of a lot of time put into this small project since there really isn’t anything on the internet suggesting my solution. I could have gone with a Meduino Mega 2560 with four hardware Serial but I wanted to stay with something small and compact. I hope this helps others without wasting so much time as I did.

DROP A COMMENT

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.