Software Serial for ESP8266

Software serial uses timer, be careful when you are using software serial. Timer is also used for WiFi communication section if you don’t give enough time to WiFi routines it will create problem of stack error or misbehavior. It is better to use software serial only when you need two serial ports and also avoid use of software serial for data reception.

Software serial can be implemented on any GPIO pin of ESP8266.

For this you need SoftwareSerial Library for ESP.

Download from here Link

To add library in Arduino IDE, Library path is different for ESP8266

C:\Program Files\Arduino\portable\packages\esp8266\hardware\esp8266\2.1.0\libraries

Software serial library can be included in your program using below commands


#include <SoftwareSerial.h>

SoftwareSerial swSer(14, 12, false, 128);


Command format is SoftwareSerial(rxPin, txPin, inverse_logic, buffer size);

Program for software serial

We are using GPIO14 as Rx pin and GPIO15 as Tx pin


#include <SoftwareSerial.h>

SoftwareSerial swSer(14, 12, false, 128); //Define hardware connections

void setup() {
  Serial.begin(115200);   //Initialize hardware serial with baudrate of 115200
  swSer.begin(115200);    //Initialize software serial with baudrate of 115200

  Serial.println("\nSoftware serial test started");

  for (char ch = ' '; ch <= 'z'; ch++) {  //send serially a to z on software serial


void loop() {
  while (swSer.available() > 0) {	//wait for data at software serial
    Serial.write(;	//Send data recived from software serial to hardware serial    
  while (Serial.available() > 0) { //wait for data at hardware serial
    swSer.write(;     //send data recived from hardware serial to software serial




Observe both serials and send some data to both serial data, data send from hardware serial is sent out from software serial and vice versa.

I will not recommend use of software serial until it becomes must. It disturbs WiFi functionality.

Leave a Reply