Arduino - SoftwareSerial

This tutorial will guide you through the utilization of SoftwareSerial in Arduino. Specifically, we will cover the following aspects:

Arduino SoftwareSerial

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B
1×Jumper Wires
1×(Optional)TTL to RS232 Module
1×(Optional) RS232 Gender Changer
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Recommended) Breadboard Shield For Arduino Uno
1×(Recommended) Enclosure For Arduino Uno

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

About SoftwareSerial

Arduino boards have one or several hardware serial interfaces. One serial interface is usually used for debuging purpose. In many cases that Arduino needs to communicate with serial sensors/devices

How to use SoftwareSerial on Arduino

Create the wiring connection

  • Select any two Arduino pins: one for RX (e.g., D7), one for TX (e.g., D6)
  • Connect the Arduino pin (selected as RX) to the TX of the serial sensors/devices
  • Connect the Arduino pin (selected as TX) to the RX of the serial sensors/devices

Please note that, there is a special case. If you uses SoftwareSerial to connect to the RS232 to TTL Module, you need to:

  • Connect the Arduino pin (selected as RX) to the RX of the RS232 to TTL Module
  • Connect the Arduino pin (selected as TX) to the TX of the RS232 to TTL Module

Wiring Diagram

Examples of wiring:

  • Arduino pin D4 as RX, pin D3 as TX
Arduino GPS module Wiring Diagram

This image is created using Fritzing. Click to enlarge image

  • Arduino pin D7 as RX, pin D6 as TX
Arduino MP3 player module Wiring Diagram

This image is created using Fritzing. Click to enlarge image

Write Arduino code

  • Include the SoftwareSerial library
#include <SoftwareSerial.h>
  • Define the selected Arduino pins
#define RX_PIN 7 // Arduino Pin connected to the TX of the serial sensors/devices #define TX_PIN 6 // Arduino Pin connected to the RX of the serial sensors/devices
  • Create the SoftwareSerial object with paramaters are RX and TX pins
SoftwareSerial soft_serial(RX_PIN, TX_PIN);
  • Initialize the software serial
soft_serial.begin(9600);

And now you can use it as the hardware serial. For the list of functions you can use, please refer to Serial Reference

Examples of Use Cases for SoftwareSerial:

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

The Best Arduino Starter Kit

※ OUR MESSAGES