From Arduino UNO, send AT commands to ESP8266 via a SoftwareSerial port and receive results.


I either send AT commands and get nothing back (wiring scheme 1) or I send AT commands and get garbage back (wiring scheme 2).

Using the Arduino as a pass through (as explained in the tutorial listed in the resources section), I can send AT commands. I have found that I can communicate with the ESP8266 at 115200 baud.

This is the results of running AT+GMR:

AT version:  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build: Sep 11 2015 11:48:04


!! I have the green wire attached to pin 3 on the Arduino Uno and the yellow wire attached to pin 2; not 1 and 0 as the picture suggests !!

enter image description here


Same wiring as above, but I have RX and TX reversed. The green wire is attached to pin 2 and the yellow wire is attached to pin 3.


This is running on Arduino Uno

#include <SoftwareSerial.h>

SoftwareSerial esp8266(2, 3);

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only


  // set the data rate for the SoftwareSerial port

void loop() {
  if (esp8266.available()) {
  if (Serial.available()) {


Wiring Scheme 1


Wiring Scheme 2


I have tested the ESP8266 via the instructions listed in the tutorial in the Resources I've Used section below. The ESP8266 works just fine when sending it instructions via the Serial Prompt.

RESOURCES I'VE USED http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf


Does anyone know if what I am trying to do is possible? And if it is, what am I doing wrong?

  • Try as sugested in the PDF to use arduino as a bypass to the serial (use the connections as in image). After try set baud at 115200 and test it using serial monitor. You need to send \r\n as line ends also. If esp doesn't respond try 9600 baudrate. If you get good output then move to software serial with the working baudrate. You can also try to update the firmware of esp to the latest version if you haven't already.
    – brtiberio
    Commented Dec 10, 2015 at 5:57
  • Can you post the software serial code? Commented Dec 10, 2015 at 7:21
  • @Personagem, Thanks. I have done that troubleshooting (ie. checking that I can send AT commands by using Arduino as a bypass). I have found that I can communicate with the esp at 115200. I'll try updating the firmware as you suggested.
    – Paul
    Commented Dec 10, 2015 at 16:22
  • @Magic-Mouse SoftwareSerial is a library provided by, I believe, Arduino. Thanks for you help on the question but I don't think posting the library here would be helpful.
    – Paul
    Commented Dec 10, 2015 at 16:23
  • I know what the software serial library is, i want to se the code where you use the software serial. Commented Dec 11, 2015 at 13:57

6 Answers 6


Does anyone know if what I am trying to do is possible?

Absolutely possible :)

And if it is, what am I doing wrong?

SoftwareSerial isn't capable of 115200 baud rate (despite "allowing" this as a setting). Some reports suggest as high as 57600 is workable, though in my experience 9600 is best for reliability. How to change the baud rate on the ESP8266 will depend on the firmware version. I've had success with AT+IPR=9600. You only need to run this command once (it's a persistent setting). I'd suggest, based on your description, that this is the most likely culprit that's causing the "garbage" output you describe.

A couple of other notes:

  • The ESP8266 runs on 3v3, not 5v, so you shouldn't have it directly connected to the digital pins—you need to run through a logic level converter. Running 5v can fry your ESP8266.
  • The Arduino's 3v3 output has insufficient current to support the ESP8266 reliably (50mA Arduino vs up to 300mA for the ESP8266 by some accounts)—try running the ESP8266 off a separate supply. It probably won't affect simple commands like AT but when you try to connect to a network etc. it may cause unexpected device resets.
  • As noted by others, you need to send \r\n — so make sure your Serial window is set to send both (this is a drop-down in the serial window)

Well you may try this:

Start by uploading blink sketch to your Arduino then connect it to your ESP8266 like this: TX-TX and RX-RX.

Now open Serial Monitor and send AT command and see if it responds. If so then you can control it using your Arduino by wiring it back to TX-RX and RX-TX.

PS: Don't forget to set the line ending in the Serial Monitor to Newline or Carriage Return.

Use this code to connect to ESP8266:

#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);

void setup() {
  ESP8266.begin(115200); // Change this to the baudrate used by ESP8266
  delay(1000); // Let the module self-initialize

void loop() {
  Serial.println("Sending an AT command...");
  while (ESP8266.available()){
     String inData = ESP8266.readStringUntil('\n');
     Serial.println("Got reponse from ESP8266: " + inData);

Since the Hardware Serial interface will be busy when connected to Computer, then you have to use another Serial interface to communicate with your ESP8266. In this case, Software Serial comes handy.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Ricardo
    Commented Dec 14, 2015 at 10:46
  • 1
    Yes, I guess you're right. I edited my answer.
    – Ikbel
    Commented Dec 14, 2015 at 12:43
  • @KiraSan why delay(30) is required? Commented Feb 25, 2017 at 16:44
  • @RahulRastogi just for this example, you can use delay to allow the ESP to respond, 30ms is only a random value but in a real life program, you should avoid that and use another mechanism to check for the response.
    – Ikbel
    Commented Feb 25, 2017 at 20:37

Does anyone know if what I am trying to do is possible? It is possible, i've done it with 2 arduinos where one was simulating ESP8266 (waiting for ebay order).

And if it is, what am I doing wrong?

What you are doing is wrong on most levels, but i think you got most sorted out.

An idea is to implement this little fella: Logic level shifter it will save you many troubles later.

On your "WIRING SCHEME 1" you are using the arduino's Hardware serial port to talk directly to the device as if it was connected through a TTL cable or FTDI cable.

This means that the arduino device would in theory read from the hardware when talking too the ESP8266, if you have another arduino or a TTL cable, try and connect it to gate 2 and 3 on the "main" arduino and you should get a similar result as for your example result 2. Since you would that way proxy through the arduino. If not that would be a place to start debugging.

Beside that i could only recommend you in investing in either a TTL 3,3v or a logic level converter. When i got my cable everything worked out of the box.


I had lot of problems as well. In my case problems are almost solved by switching from SoftwareSerial to AltSoftSerial. It seemed that on the Uno the standard software serial library was not working for me. After switching I started to get results back for the first time. (I also used level shifting and external power supply for 3.3V)

And by almost solved I mean - I still get, from time to time, gibberish on the terminal. So even AltSoftSerial isn't a perfect solution. I was using the ESP-07 with a 115200 bps data rate.

  • Can you add to your description? It would be helpful to know how you wired the connection between the Uno and the ESP. Thanks!
    – dlu
    Commented Dec 31, 2015 at 16:58

We found that many of the problems with the ESP - Arduino Uno serial software integration had to do with incompatible baudrate. We created this short tutorial (including a Github library) which you are welcome to test and see if it solves these issues. http://www.instructables.com/id/Simple-ESP8266-Arduino-Uno-Software-Serial-Integra/


Here are a few tips when using ESP8266 Module.

  1. Don't use software serial as it's unreliable especially at higher baud rates.

  2. Always connect ESP module to computer and test all AT commands before interacing with Arduino to ensure that you are working in right direction

  3. Make a power adaptor board to make ESP module compatible with Arduino 5v supply

Also check out this link for more details

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