Software Serial in Arduino

The SoftwareSerial library was developed to ensure that any pins of Arduino can exchange Serial data with other peripherals, like GNSS receivers, using software. Arduino Uno, for example, has only one HardwareSerial port (pins 0 and 1), which is connected to the USB via the USB to UART conversion chip. Thus, if you have any other peripheral that requires serial communication, in the absence of SoftwareSerial, you’d have to do away with USB Serial communication.

SoftwareSerial has some limitations −

  • If you are using multiple SoftwareSerial ports, only one can receive data at a time

  • Speeds can be up to a maximum of 115200 bps

Other limitations of this library, specific to some Arduino boards, can be found here.

The SoftwareSerial library is included in Arduino IDE Versions 1.0 and above, and you don’t need to install it separately. Defining the Software Serial is very straightforward. An example is shown below −

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

As you can see, you need to create a SoftwareSerial object using two arguments − the RX pin and the TX pin. The other functions are similar to Serial. For example,

Serial.begin(9600) translates to mySerial.begin(9600)

Serial.println("Hello World") has the equivalent mySerial.println("Hello World") and so on.

You are encouraged to go through the examples that come in with the SoftwareSerial library. They can be found in File → Examples → SoftwareSerial.