I'm trying to operate the esp8266. When I connect RX+TX pins to pins 1+2 on the Arduino, everything works fine. but when I'm trying to use software serial all hell breaks loose and the recieved data is garbadeged (It seems like everything is ok but I can't read the output data... more interesting, the output is not consistent!


#include <SoftwareSerial.h>
SoftwareSerial esp8266(11, 10); // RX, TX
void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200 );

void loop() {
    String buffer;
    Serial.print("SENDING AT...");
    for(uint64_t time = millis();(time+1000) > millis();)
    buffer.replace("\r\n"," ");
    Serial.println("RESPONSE:" + buffer);

And the output: enter image description here

I've tried changing the SerialMonitor baud rate, the input pins, but results are all the same.

I've recently changed the MCU(uno) to a different and even a different esp module from a different supplier, I am still getting the same results! I can't be the first one to encounter such phenomena...

  • softwareserial obviously has troubles working at 115kbps, It helped me to pause between the espSerial.read(); with a delay of 50 to 100...
    – mischka
    Oct 2, 2018 at 16:34

3 Answers 3


Try dropping the SoftwareSerial connection speed to 19200. Ie, esp8266.begin(19200). 115200 it is the absolute max the SoftwareSerial can theoretically handle. Also if you are not using all the change interrupt pins on your MCU (Uno/Nano?) then use any 2 pins from 10, 11, 12 or 13 rather than 3, 2 // RX, TX. Not sure about sendCommand function. If you just want to test the connection then it should be as simple as:

SoftwareSerial esp8266(10, 11); // RX, TX

void setup() {
    Serial.begin(115200 );

    char buffer[50];
    esp8266.readBytes(buffer, sizeof(buffer));


Obviously once you need to open web pages and recieve responses then you will need a libary to handle IDP+ data. With a bit of coercion I got Adafruit_ESP8266.h working with SoftwareSerial.

  • This is a good idea. Try using those interrupt pins
    – cortices
    Oct 31, 2015 at 12:30
  • Tried all the above, still getting same garbage...
    – Mercury
    Oct 31, 2015 at 19:20
  • 2
    I suspect you may need to change the baud rate of the ESP-8266. It usually defaults to 115200. I used neilkolban.com/tech/wiring-up-esp8266s to get started with a terminal emulator and then flashed the latest AT firmware and changed the baud rate to 19200 using AT+UART_DEF=19200,8,1,0,0. Also the update via cloud seemed to work ok for me once I set the AP ssid & pwd. Note it takes a while when using AT+CIUPDATE.
    – chris
    Nov 2, 2015 at 9:32

A quick thing to try out.

Try changing Serial.begin(115200); to Serial.begin(9600); and leave esp8266.begin(115200);.

I'm also completely new to Arduino, but I remember seeing the junk values when the serial monitor baud rate is set to a different value than the Arduino's Baud rate.

I was using Arduino Uno and if I set the baud rate to a value other 9600 in the serial window, I was seeing junk values in println function calls.

i.e Set Serial.Begin(9600); and the Serial Montior baud rate also 9600.


From my experience, if you want to have a consistent data transfer over the softserial, you must disable (in Arduino) the global interrupts for the time of transmission. To disable global interrupts use cli() command, to enable it again use sei() command.

  • I tried this and didn't improve. No sending worked anymore then...
    – mischka
    Oct 2, 2018 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.