Software serial esp8266

Hello,
I am trying to use software serial port using esp8266. I try to send message from pin 5 same message read pin 16 and show in my pc port monitor, but program is not working. Maybe somebody have suggest why it is not working My program:

#include <SoftwareSerial.h>
#define rxPin 16
#define txPin 5
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
void setup() {
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   mySerial.begin(115200);    
   Serial.begin(115200); 
   mySerial.setTimeout(1000);
}

void loop(){
 mySerial.println("dragunai");
 String c =  mySerial.readString();
 Serial.print(c);
 delay(2000);
  }

have a look at software-serial-esp8266

Or reduce the software serial ports down to 9600.

I try reduce baudrate to 9600 but result is same

As far as I know and as I tried, the software UART Port does not work in loop back connection. Try between two ESP8266 and an UNO.

the following code using the default softwareSerial library using pins D5 and D6

// ESP8266 SoftwareSerial test

#include <SoftwareSerial.h>

#define baudrate 115200//57600//38400//9600//115200

// pins Rx D5 (14) and Tx D6(12)
//SoftwareSerial mySerial(14, 12); // RX, TX
SoftwareSerial mySerial(D5, D6); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {  }
  Serial.println();
  Serial.println("ESP SoftwareSerial  test!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(baudrate);//9600);
  Serial.print("Serial test - Serial 1 at  baudrate ");
  Serial.println(baudrate);
  //while(1) mySerial.write('X');  // send continuous test
}

void loop() {
  if (mySerial.available())
    Serial.write(mySerial.read());
  while (Serial.available())
    mySerial.write(Serial.read());
}

works OK to an arduino Due - I would still tend to reduce the baudrate to say 38400
Note: loopback - connecting D5 to D6 does not work

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.