What's the difference between all the Software Serial Libraries? Which one is Arduino Nano compatible?
This answer lists the 4 basic choices:
HardwareSerial
, always the best. Simply use the pre-definedSerial
variable. On some Arduinos, there are extra HardwareSerial ports, calledSerial1
,Serial2
, etc. The Nano only hasSerial
.AltSoftSerial
, the best of the software serial libraries. Only one instance is allowed, and it is must be used on one of the Input Capture pins (pins 8 & 9 for a Nano).My
NeoSWSerial
is next best. It works on any two pins, but only at baud rates 9600, 19200 and 38400.SoftwareSerial
is the worst choice. It works on any two pins, but it is very inefficient. It disables interrupts for the entire time that a character is being sent OR received, and it cannot do both at the same time (unlike all the other serial choices). This can interfere with other parts of your sketch, other device communications, or with libraries.
If you could use a slower baud rate, you could keep your debug prints on Serial
, and use either AltSoftSerial
or NeoSWSerial
for your device.
But if you have to use 115200, the only reliable choice is Serial
. Although AltSoftSerial
and SoftwareSerial
allow that baud rate, they may not send/receive data correctly.
In that case, I would suggest using Serial
for the 115200 device. Unless you are using an ISP, you will have to disconnect the device to upload a new sketch over USB.
Then use AltSoftSerial
or NeoSWSerial
for your debug statements. You will need a TTL Serial-to-USB adapter (aka FTDI) on the selected pins to connect to the PC. The Serial Monitor
or other Terminal emulator program will read from that USB COM port.