Skip to main content

How to Use SoftwareSerial on Arduino (Connect Multiple Serial Devices)

In the previous tutorial, you learned how Arduino uses hardware serial communication through pins 0 (RX) and 1 (TX). That built-in serial port is mainly used to communicate with your computer through the USB cable and Serial Monitor.

But here is the problem beginners quickly face:

Many popular modules use serial communication, such as:
Arduino Uno has only one hardware serial port.
So how can we connect these modules while still using the Serial Monitor?

The solution is SoftwareSerial.

In this tutorial you will learn how to create additional serial ports using normal digital pins.

By the end, your Arduino will be able to talk to multiple serial devices.

What is SoftwareSerial?

SoftwareSerial is a special Arduino library that allows digital pins to behave like RX and TX pins.

This means Arduino can create extra serial ports using software instead of hardware.

Hardware Serial vs Software Serial

HardwareSerial                               Software Serial

Uses built-in UART hardware        Uses software to mimic UART
Fixed pins (0 & 1)                           Any digital pins
Very fast                                          Slightly slower
Used for USB communication       Used for external modules


Key idea:
SoftwareSerial allows Arduino to communicate with serial modules without using pins 0 and 1.

This is why most Arduino Bluetooth tutorials use pins 10 and 11.

Why SoftwareSerial is Important

Most Arduino expansion modules communicate using UART serial.

Examples include:
Without SoftwareSerial, you would need to disconnect your module every time you upload code.

SoftwareSerial solves this problem completely.

SoftwareSerial Wiring Rules

The same serial rules still apply:
  • TX connects to RX
  • RX connects to TX
  • Both devices must share GND
  • Both must use the same baud rate
Even though we use different pins, the communication principle is identical.

First SoftwareSerial Example

We will create a second serial port using pins 10 and 11.

This example will forward messages between:
  • Serial Monitor (hardware serial)
  • SoftwareSerial port (pins 10 and 11)
This is the same logic used when connecting Bluetooth modules.

Arduino Code

Upload this sketch:

#include <SoftwareSerial.h>

// Create software serial port
SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(9600);     // Hardware serial (USB)
  mySerial.begin(9600);   // Software serial

  Serial.println("SoftwareSerial is ready");
}

void loop() {

  // Data from SoftwareSerial → Serial Monitor
  if (mySerial.available()) {
    char c = mySerial.read();
    Serial.write(c);
  }

  // Data from Serial Monitor to SoftwareSerial
  if (Serial.available()) {
    char c = Serial.read();
    mySerial.write(c);
  }

}

How This Code Works

Step 01: Import the Library

#include <SoftwareSerial.h>

This enables software-based serial communication.

Step 02: Create a New Serial Port

SoftwareSerial mySerial(10, 11);

Pin mapping:
  • Pin 10 → RX
  • Pin 11 → TX
You just created a second serial port.

Step 03: Start both Serial Ports

Serial.begin(9600);
mySerial.begin(9600);

Arduino is now running two serial communications at the same time.

Step 04: Forward Incoming Data

The loop continuously checks for incoming data from both sides and forwards it. This creates a bridge between the Serial Monitor and your external module.

Testing the SoftwareSerial Communication

Now let’s verify that the SoftwareSerial bridge works correctly.

Step 01: Upload the code

Upload the sketch to your Arduino.

Step 02: Open Serial Monitor

Set:
  • Baud rate → 9600
  • Line ending → Both NL & CR
You should see: SoftwareSerial is ready

Step 03: Send a test message

Type a message in the Serial Monitor and click Send.

What happens internally:
  • Serial Monitor sends data → Hardware Serial
  • Arduino forwards it → SoftwareSerial pins (10 and 11)
Right now, there is no external module connected, but the communication bridge is working and ready for devices like Bluetooth modules.
You have successfully created a serial bridge.

Real-World Usage Example

This exact setup is used when connecting modules such as:
  • HC-05 / HC-06 Bluetooth
  • GPS receivers
  • GSM modules
  • ESP8266 WiFi modules
Instead of forwarding messages to nothing, the Arduino will soon forward them to a real device.

This is why SoftwareSerial is one of the most important Arduino skills for beginners.

Common Beginner Mistakes

1) Upload fails when module is connected

If you connect a module to pins 0 and 1, uploading may fail.

Solution:

Use SoftwareSerial pins (10 & 11) for modules.

2) Garbage characters in Serial Monitor

Occurs because of baud rate mismatch.

Solution:

Ensure both lines use the same baud rate:
Serial.begin(9600);
mySerial.begin(9600);

3) No communication with module

Check:
  • TX ↔ RX crossed correctly
  • Common GND connected
  • Module powered correctly

4) Wrong pin order in SoftwareSerial

Remember:
SoftwareSerial mySerial(RX, TX);
First pin = RX
Second pin = TX

Many beginners accidentally reverse them.

Limitations of SoftwareSerial

SoftwareSerial is powerful but has some limitations:
  • Slower than hardware serial
  • Not ideal for very high baud rates
  • Only one SoftwareSerial port can listen at a time
For beginner projects, however, it works perfectly.

Frequently Asked Questions

Can I use any digital pins for SoftwareSerial?

Yes, most digital pins work. Pins 10 and 11 are commonly used.

Is SoftwareSerial slower than hardware serial?

Yes, but it is fast enough for most Arduino modules.

Can Arduino run multiple serial ports at once?

Yes. One hardware serial + one SoftwareSerial works perfectly.

Conclusion

In this tutorial, you learned how to create additional serial ports using the SoftwareSerial library. This allows Arduino to communicate with multiple serial devices without using the default RX and TX pins.

You are now ready to start building real projects using Bluetooth and other wireless modules.

Comments

Popular posts from this blog

Arduino Serial Communication Beginner Guide (UART Explained)

Serial communication is the backbone of most Arduino projects. It allows your Arduino to talk to your computer, Bluetooth modules, Wi-Fi modules, sensors, and even other Arduinos. If you have ever used the Serial Monitor, you have already used serial communication - now you will understand how it really works. By the end of this guide, you will learn: What serial communication is What UART means How Arduino communicates with devices How to send and receive data How baud rate works Common mistakes beginners make What is Serial Communication? Serial communication is a method of sending data one bit at a time over a single wire. Instead of sending many bits simultaneously (parallel communication), serial sends bits sequentially: Example: The letter A in binary = 01000001 These bits are sent one after another very quickly. This method is: Simple Reliable Perfect for microcontrollers What is UART? UART stands for: Universal Asynchronous Receiver Transmitter It is the hardware ins...

How to Connect HC-06 Bluetooth Module with Arduino (Step-by-Step Beginner Guide)

Bluetooth communication is one of the easiest ways to make Arduino projects wireless. Once you understand how to use a Bluetooth module, you can build robots, home automation systems, and smartphone-controlled devices. In this tutorial, you will learn how to interface the HC-06 Bluetooth module with Arduino and send data wirelessly using your phone.    By the end of this guide, you will be able to: Understand how the HC-06 Bluetooth module works Configure the module using AT commands Safely connect it to an Arduino Send and receive serial data over Bluetooth Build the foundation for wireless Arduino projects Watch the Project Overview What is the HC-06 Bluetooth Module? The HC-06 is a Bluetooth-to-Serial module designed to add wireless communication to microcontrollers such as Arduino. It uses Bluetooth 2.0 (SPP - Serial Port Protocol), which means it behaves like a wireless serial cable. Whatever is sent from the phone appears in Arduino’s Serial Monitor and vice versa. ...