Arduino to ESP8266 By Serial Communication

Following on from the FTDI + ESP8266 post, if you do not have a FTDI serial adaptor you can use an Arduino. Here is how to set up the Arduino to talk to the ESP8266.

Arduino to ESP8266

I an using a 5V Arduino Nano which of course is 5V. The Esp8266 is a 3.3v device and so I am using a voltage divider to bring the Arduinos 5V down to 3.3v. If you are using a 3.3v Arduino then you do not need the voltage divider.

The wiring is very similar to the FTDI.
Arduino pin 3 to voltage divider and then to ESP8266 RX
Arduino pin 2 to ESP8266 TX
Arduino GND to ESP8266 GND
Pull CH_PD HIGH with a 10K resistor to +3.3v
+3.3V to vcc

You only need the voltage divider on the Arduino TX pin. The 5V Arduino will read 3.3v as HIGH so you can connect the ESP8266 TX pin directly to the Arduino RX pin.

Make sure the ESP8266 has enough current. If it does not it may keep resetting and may not broadcast a signal.

Arduinos cannot supply enough current and you should use a separate power supply. While experimenting I use a bread board power supply.

I am using a simple serial in, serial out sketch.

// Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup() 
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
    // Start the software serial for communication with the ESP8266
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
void loop() 
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( );  }
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( );  }

Once everything is setup, open the serial monitor and cycle the power on the ESP8266 and you should receive the welcome message.
Arduino to ESP8266 - serial monitor

You can now interrogate the ESP8266 and change the settings. For more on talking to the ESP8266 see FTDI + ESP8266

65 thoughts on “Arduino to ESP8266 By Serial Communication

  1. Martyn,
    Thanks for your post, with the clear description and diagram. I have these components and want to repeat your example. The only thing I am not sure about is the 3.3v power supply. Are you providing that from the Arduino or do you have a separate supply, I have heard that the ESP8266 can draw up to 300mA?


  2. Hi Chris,

    You are correct, the ESP8266 can draw up to 300mA which is too much for the Arduino. My test projects were all done on a bread board and I used a bread board power supply which can be set to output either 5V or 3.3V. You can see the set up in the FTDI + ESP8266 post –

    For a permanent project I would use an external power supply (I have a lot of the 9V ones you get with many of the Arduinos). This would give power to the Arduino and also 3.3V, via a regulator, to the ESP8266.

    I have also started to use small buck convertor power supplies quite a lot. These handle a wide range of input voltages and a wide range of output voltages and can be bought very cheaply.

  3. Pingback: Getting started with the ESP8266 on a breadboard | Philipp's Blog

  4. Hi
    Thanks for the post. I have connected my ESP8266 module just like you said and put your program in too it but when I power up my ESP8266 module it start spitting out gibberish in the serial monitor. What could be the problem here?


  5. i have a problem when i used ESP8266 ,, one day it’s good respons and one day not ,, what must i do ?? i follow all step n do same like the tutorial.. but always have something problem ,, may you help me ?? i use battery AA as power ESP

  6. Can you give me details about the problems.

    In the meantime try to rule out things like the batteries. Use new batteries and also a regulated power supply if you can.

    • my problem like this :
      it’s my first time use this module ,when i try like your tutorial ,, need more than five time i tried ,, and i got same like that ,, the ESP respones and i can write the command ,, but when i try again tomorrow ,, ESP don’t respons again like yesterday,, and i must check wiring again and repair it and make sure if my wiring is same .. but i cann’t get same respons like yesterday ,, i cann’t write command ,, ESP just respons stranger word ,, i want to know what is the main problem ,, is it just about the power of battery ,, because every day it’s less and now not 3v again or what ?? and i never flash from first time i bought … and my battery now is just 2.78V

  7. Pingback: FTDI + ESP8266 | Martyn Currey

  8. I took me some time until I realized, that my china ESP8266 was working at 115200.

    The next problem I ran into was the missing new line setting in my serial monitor of the arduino application!

  9. Hello martyn
    i am following the above example but i didn’t get any ready message from esp8266 so please provide the the step by step process for interfacing esp 8266 with arduino uno r3

    Thanks in advance

  10. i have done like you, wiring and a arduino sketch, but when i send AT / AT+RST or another ATcommand, it’s just show yyyypyyya I don’t get like when i use RX(arduino)-RX(ESP8266) TX(arduino)-TX(ESP8266) i get AT — OK and then whats wrong ? what when i flash at firmware i must change baudrate to 9600 ?

  11. It is possible that the screen print on the board is wrong (TX and RX swapped) or that the firmware changed the pin configuration. Normally TX sends to RX and RX receives from TX.

    I haven’t used the ESP8266 modules for a while and not really in a position to offer help. If you have not already, I would suggest joining the forum at The forum includes lots of information on flashing new firmwares etc.

  12. My Arduino board (Teensy 3.2) is a 3v3 level logic board – am I correct in assuming that the voltage divider from Arduino Pin3 thus becomes redundant (if not downright problematic)? If so may be worth updating above that the need for a voltage divider depends on the logic level of the Arduino variant used (5v0 -v- 3v3) as these are starting to vary :/

  13. Pingback: ArduinoでUSBシリアル変換してESP-WROOM-02に書き込む | Mechanic Note

  14. Hi,
    I want to program my ESP8266 such that it can read a data variable which is residing on Arduino UNO. How should I do this? Please help…

  15. Hello guys . This article is very helpfull with the connection but i have a problem here.
    When i make the connections the esp8266 doesnt power up. The red light is always off. Can anyone help me?

    • How are you powering the ESP8266?

      The Esp8266 needs more power than the Arduino can deliver and when powered from an Arduino, at best the ESP8266 will keep reseting, at worst it will not power on. Use a separate power supply.
      If you are already using a separate power supply, take a step back, just add power connections (remove the serial connections) and see if you can get it to start.

      • Hello thank you very much for the answer. The problem solved. I change my esp8266 and with the new one and it worked. I have an other problem now. The problem is that when i upload the code to the arduino the usbserial goes busy so i do not have connection with the serial from arduino IDE and i cant send At Commands :/

        If anyone can help me i would be grateful.

          • In the above example I am using software serial to talk to the ESP8266 and this is separate to the usb so this will not be the problem.

            Are you using the hardware serial to connect to the ESP8266?

            Do you have any other USB connections to the Arduino?

            If you have the ESP8266 connected as per the above then I suspect the issue may be with the Arduino. Remove the ESP8266 and get the Arduino working on its own. Then work from there.

          • Hello again
            My connection is extacly the same with the one above. When i connect the esp8266 on the arduino with no code uploaded the tx,rx lamps of arduino blinks . It doesnt let me to upload the code. If i disconect the esp8266 then i can upload my code with no problems. But then i have the problem to see the monitor responce. :/
            I cant understand why is this happening

          • *I mean when i connect the esp8266 to execute the code i have problem with monitor responce .. I cant connect to the serial from arduino ide

  16. I have change the code and put some labels to print so i can understand whats the problem. it seems that some times i got results from the esp. But the things i sent to the esp does not arrive to it :/

  17. sorry for all those questions but it very important to resolve this issue . I think the problem i have here is that the serial monitor is “busy ” so i cant connect to it and send commands. I have written a code which continues print the point the arduino is. When i connect the esp then the serial stop responding . An ftdi will resovle this or there is some other way?

  18. hi martyn,
    i am a newbie for esp 8266. i use it with a arduino uno. but not with a ftdi converter. i take the 3.3v supply from uno itself. every time i send an at command to 8266 the only response i am getting is ‘-1′ (minus one). whats wrong here?.. is it the absence of ftdi? pls help me out

  19. Too bad, but my arduino does not seem wanting to read anything the ESP8266 sends. The UART TX status LED of the esp flashes when it should send something, but Arduino 2560 is not reading anything of it, no matter which power supply I provide or which baud rate I set in the sketch :C

  20. I want to interface Arduino Uno and ESP8266 for IoT project where i have to control the device from webpage,but before that i wanted to check the above code for Arduino to ESP8266 by Serial Communication.So interfaced Arduino Uno with ESP8266 and powered ESP8266 with External adapter with 3.3V, ESP8266 baud rate is 115200 and in the code i changed Serial.begin(115200) and ESPserial.begin(115200) . After i uploaded the above code in Arduino IDE and opened serial monitor ,made both NL and CR but i got the message saying ”
    Remember to set Both NL & CR in the serial monitor.

    After that no response.I tried with different baud rates and also typed AT ,but no response. Can you please suggest.

  21. Hello,

    While i am able to communicate with ESP with serial port and Arduino, i want to send the AT commands in the code itself. What i want to do is to hard code AT commands in my setup and loop sections. Is it possible? I am facing some problems with the same. Thanks a lot in advance!

  22. Hello All,
    I found my ESP8266 Working fine when connected to Arduino 3.3V pin. All AT Commands are working,. ESP is also transmitting signal which I am able to see in Wi-Fi list, But when I try to upload a sketch i.e. ESP8266 standalone it gives error as BlynkSimpleEsp8266.h file do not found …compiling terminated….
    Any solution for this.

  23. a weird issue am having with Arduino Pro mini 3.3v 8Mhz hookdup to ESP8266 (Wemos D1 Mini).

    Arduino(Tx)->ESP8266(Rx) is OK, i am able to send data and parse it
    ESP8266(Tx)->Arduino(Rx) is not always working, sometimes i receive a data sometimes it is garbage, sometimes a character in between the string is changed to something else, am guessing this has something to do with voltage levels ?

    • If using a 3.3v Arduino you connect direct. No need the voltage divider. I presume this is how you have it connected.

      It sounds like you may have the baud rate too high?
      If using software serial, try AltSoftSerial.
      If using a high baud rate bring it down a bit. Using Software Serial I have only ever obtained 100% accurate communication when using 9600.

      You can confirm if the software serials are the issue by setting up a test sketch that uses the hardware serial. If this works you know the software serial is the culprit. If hardware serial gives the same errors then the problem lies elsewhere.

  24. Hi Martyn,
    I did everything as your guide. But , I didn’t receive welcome message. I didn’t also receive any response when I sent “AT” to serial monitor.

  25. Sketch uses 3,282 bytes (10%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 361 bytes (17%) of dynamic memory, leaving 1,687 bytes for local variables. Maximum is 2,048 bytes.
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x65
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x65
    Problem uploading to board. See for suggestions.

    when i try your code in aurdino uno , i get this error

  26. Hi Martyn,
    I followed your connections where I am using arduino mega. 3.3V is supplied using 2x AAA batteries.
    Using your codes and other code using serial2, I am unable to get a response. However, when using FTDI cable, I receive a responds when sending AT command. Seems to me software and hardware serial is not working.
    Please advise.

  27. Hi Martyn,

    trying to use your code for the Arduino, I failed.
    The compiling of your code itself runs smooth.
    When uploading I get error messages.
    During upload the ESP8266 is disconnected from Arduino.
    The code is not transferred to the Arduino.
    Error messages after upload try:
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed
    Do you have any idea what this could come from ?
    Thank you in advance and regards

  28. I would suggest to update the guide with **two** things.
    1: RST (Reset) should be pulled straight to 3.3v.
    2: Default budrate on most chipsets are 115200, took me a good solid two ours to figure this out and then finally I read the comments and someone pointed it out (Didn’t know what I was looking for until I solved it myself).

    These two things can be found on the official – Especially the RST was tricky.
    All the rest matches up perfectly.

  29. Hi, nice code.

    I’m getting too much gibberish… I was able to make a connection to my AP, however when I type AT+CIFSR I don’t see the real IP the ESP is using!

    Do you know how to solve this gibberish issue?


  30. Great guide. I wired up an esp201 module that I had. It still actually an esp8266 but in a slightly different form factor. I ended having to use your guide along with another. When I go into the serial monitor in the Arduino IDE I get both the “Remember…” message and on the next line it returns “Ready”.

    While all of that is good and well I’m getting zero response from any AT commands. Perhaps it’s because I’m running the IDE on OS Xi though I’m not really sure why that would matter as it has always seen my ch340 serial to USB. I’m curious what settings are you using under tools? Is the nano is ESP selected? Are you using ArduinoISP or Arduino as ISP?

Leave a Reply

Your email address will not be published. Required fields are marked *

nine − = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>