Arduino Software Serial”SoftwareSerial” Multiple Serial Ports

(Last Updated On: February 13, 2020)

SoftwareSerial

Description:

Arduino Software Serial” SoftwareSerial” Multiple Serial Ports- This article is all about the SoftwareSerial library which is most frequently used in the Arduino Uno programming. Why is it used in the Arduino Uno or Arduino Nano programming? How do we know when to use this library? You will get answers to these questions. I will explain this with the help of a Proteus simulation and will share with you some advanced level projects in which the SoftwareSerial library is used.

Without any further delay, let’s get started!!!

The Amazon Purchase links of the most commonly used Electronics components:

Arduino Uno: https://amzn.to/37oaksm
Mega 2560: https://amzn.to/2ze1kdu
DHT11 Temperature and Humidity sensor: https://amzn.to/2KxfifT
LM7805 Voltage Regulator: https://amzn.to/2IZEl5x
Potentiometer: https://amzn.to/2JSLbfg
330 ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
LDR pack: https://amzn.to/2m2khGR
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

SofwareSerial:

The SoftwareSerial is basically a library that enables the Serial Communication on digital pins other than the Serial Port. Using the SoftwareSerial library we can create multiple software serial ports with speeds up to 115200bps.


When and why we need the SoftwareSerial?

It’s based on your choice, if you want to use Arduino Mega then I don’t think so you will need the SoftwareSerial library, as in Arduino Mega we have a total of 4 hardware serial ports that can communicate with different serial communication supported devices.

SoftwareSerial

So using the Arduino Mega you can communicate with 4 serial devices at the same time.

In the case of Arduino Uno, we have only one serial port which is available on Pin0 and Pin1.

SoftwareSerial

Pin0 = RX

Pin1 = TX

Using the Arduino’s default Serial Port we can connect only one serial communication supported device. But when it comes to the multiple Serial devices then the Arduino default serial port becomes insufficient.

Let’s for example you are working on a project in which you are required to connect two serial devices GSM Sim900A and a Bluetooth module HC-05 or HC-06, or any other serial device. You can connect any of the two devices with the Arduino’s default serial port, but, what about the other serial device?

At this point you will need the SoftwareSerial library which can be used to create multiple serial ports. While using the Arduino Uno or Arduino Nano even if you are using one serial device never use the Arduino’s default serial port for the communication with other devices. The Arduino’s default serial port should only be used for the debugging purposes.


Multiple Serial Ports Proteus Simulation:

For the best understanding I am going to explain this with the help of a Proteus simulation.

SoftwareSerial

Download the Proteus Simulation: SoftwareSerial

As you can see I have connected a Bluetooth module and a GSM module with the Arduino’s pins 2, 3, 7, and 8. Bluetooth module is connected with pin number2 and pin number3 while the GSM module is connected with pin number 7 and pin number 8. While, the Arduino default serial port is going to be used for the debugging purposes. Now I will write a simple program to send some text messages to these terminals.

Multiple Serial Ports Arduino Programming using SoftwareSerial Library:


Multiple Serial Ports Arduino Program explanation:

I started off by adding the SoftwareSerial library.

#include “SoftwareSerial.h”

SoftwareSerial blue(2,3) ; // rx , tx

SoftwareSerial gsm(7,8); // rx , tx

Defined two Serial ports for the Bluetooth Module and GSM module with names blue and gsm.

void setup()

{

Serial.begin(9600); // activated the serial communication

blue.begin(9600);  // activated the serial communication for Bluetooth

gsm.begin(9600); // activated the serial communication for GSM

you can use different baud rates as per your requirement.

}

void loop()

{

The following instructions are used to send messages using the Serial.println().

Serial.println(” message from Computer”);

blue.println(” message from bluetooth”);

gsm.println(” message from gsm module”);

delay(1000);

}

After compiling the code I copied the hex file link and pasted it in the Proteus simulation. Double click on the Arduino in the Proteus simulation and paste the link in the program file text box. Then click on the play button.

SoftwareSerial

As you can see we send data serially to multiple serial communication supported devices. Some advanced level projects in which the SoftwareSerial library is used are given below.


SoftwareSerial Related Projects:

How to use GSM and Bluetooth Together To monitor Any Sensors wirelessly using Arduino

How to use GSM and Bluetooth Together To monitor Any Sensors wirelessly using Arduino

DIY IoT Weighing Scale using HX711 Load Cell, Nodemcu ESP8266, & Arduino

DIY IoT Weighing Scale using HX711 Load Cell, Nodemcu ESP8266, & Arduino

Flood Monitoring System with SMS Alert using Arduino and GSM

Flood Monitoring System with SMS Alert using Arduino and GSM

Arduino Gas leakage detection and SMS alert MQ-2 sensor

Arduino Gas leakage detection and SMS alert MQ-2 sensor

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply