Arduino Software Serial User Guide

The Arduino hardware has the built-in support for Serial communications on pins 0 and 1 (Hardware Serial) but in some circumstances such as when these pins are already in-use or you need more Serial ports for debugging, Software Serial may seem to be the solution.

Here will also use an example to demonstrate how to use Software Serial with you Arduino!

Software Serial Example

RX is digital pin 2 (connect to TX of other device)
TX is digital pin 3 (connect to RX of other device)

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX

void setup()
  while (!Serial) {

  Serial.println("Goodnight moon!");

  mySerial.println("Hello, world?");

void loop()
  if (mySerial.available())
  if (Serial.available())

In practice, you may also use other serial devices, such as serial wireless pass-through modules, serial sensors, etc., as long as it is standard. The serial devices are all programmed in much the same way.

Using Multiple Software Serial

When you need multiple serial devices to be connected, it is possible to create multiple software serial ports. But due to hardware limitation, Arduino UNO can only listen to one software serial at a time. Here provides an example for multiple software serial:

#include <SoftwareSerial.h>
SoftwareSerial serialOne(2, 3); // Software Serial ONE
SoftwareSerial serialTwo(8, 9); // Software Serial TWO

void setup() {
  while (!Serial) { // wait till Serial


void loop() {
  serialOne.listen(); // listening on Serial One

  Serial.println("Data from port one:");
  while (serialOne.available() > 0) {
    char inByte = serialOne.read();


  serialTwo.listen(); // listening on Serial Two

  Serial.println("Data from port two:");
  while (serialTwo.available() > 0) {
    char inByte = serialTwo.read();


Tech Support

Please submit any technical issue into our forum.