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?

up vote 8 down vote accepted

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.

  • 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 – William Roy Feb 1 '17 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 '17 at 16:36

Serial software emulate a serial port, diferent from a native port which has register to save all bits in order and them set a flag to call the main loop, a software serial has nothing of that. Software serial must receive all bits, one by one, so you must read a digital port, wait a specific time and read the digital pin again. You must make it 10 times (1 start bit, 8 data bits and 1 end bit). The time is very important. For use a software serial you need to worry more about performance.

You can use a digital interrupt pin for the RX pin, so you are "called" in the down border (start bit) and the received the 8 bits.

  • This doesn't even attempt to answer the original question. – Edgar Bonet Feb 1 '17 at 14:08
  • Yes, this doesn't attempt to answer the original questio because the Arduino community don't know do youself Peripheral code. – rodrigo Feb 1 '17 at 15:12

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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