14

There are so many Software Serial Libraries, what are the differences between them? And which one I can use with my Arduino Nano? For my Arduino Nano I need one Hardware Serial Port and one Software Serial port at a baud rate of 115200.

On which pins of the Arduino Nano can I use the software serial library?

0

1 Answer 1

20

This answer lists the 4 basic choices:

  • HardwareSerial, always the best. Simply use the pre-defined Serial variable. On some Arduinos, there are extra HardwareSerial ports, called Serial1, Serial2, etc. The Nano only has Serial.

  • 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.

4
  • Is AltSoftSerial the same in performance and characteristics, only that NeoICSerial adds the functionality of what? I did not understand completely. github.com/SlashDevin/NeoICSerial Feb 1, 2017 at 15:12
  • 2
    @WilliamRoy, NeoICSerial just adds the attachInterrupt method to AltSoftSerial. You probably don't need to handle each character in an interrupt. Just use AltSoftSerial and call the available() and then read() if a char is ready. Similarly, NeoHWSerial adds the same attachInterrupt feature to the core HardwareSerial. However, NeoSWSerial is a completely different class (it also has the attachInterrupt feature).
    – slash-dev
    Feb 1, 2017 at 16:36
  • "SoftwareSerial is the worst choice". I think at the moment it is improved, based on Neo. If you have time please update the answer. Thanks! Jan 27 at 16:50
  • both NeoSW and AltSoft cannot work with ISR vectors.
    – aleXela
    Nov 7 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.