Arduino to ESP8266 By Serial Communication

Following on from my last 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

48 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.

    • Try different baud rates.

      A quick way to check to see if you have the correct baud rate is to cycle the power to the ESP8266 while it is connected to the Arduino. If you have the correct baud rate you will see the start up message.

  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!

Leave a Reply

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

six + 6 =

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>