Introduction: Getting Started With the ESP8266 ESP-01

Picture of Getting Started With the ESP8266 ESP-01

The ESP8266 ESP-01 is a Wi-Fi module that allows microcontrollers access to a Wi-Fi network. This module is a self-contained SOC (System On a Chip) that doesn’t necessarily need a microcontroller to manipulate inputs and outputs as you would normally do with an Arduino, for example, because the ESP-01 acts as a small computer. Depending on the version of the ESP8266, it is possible to have up to 9 GPIOs (General Purpose Input Output). Thus, we can give a microcontroller internet access like the Wi-Fi shield does to the Arduino, or we can simply program the ESP8266 to not only have access to a Wi-Fi network, but to act as a microcontroller as well. This makes the ESP8266 very versatile, and it can save you some money and space in your projects.

In this tutorial we are going to show you how to set up the ESP-01 Wi-Fi module, configure it, and verify that there is communication established between the module and another device.

Step 1: Materials

Step 2: ESP-01 Setup

Picture of ESP-01 Setup

When you buy the ESP8266 ESP-01, it comes with a pre-installed AT firmware. It is possible to program the chip with another firmware such as NodeMCU, for example. However, AT firmware is compatible with the Arduino IDE, so we are going to use this firmware for this tutorial. If you want to know how to install a different firmware, then read the Miscellaneous section in this tutorial.

First use the jumper wires to connect the Wi-Fi module to the Arduino as shown in these images.

Step 3: ESP-01 Setup Continued

Upload the BareMinimum example to ensure that no previous programs are running and using the serial communication channel. Next, open the serial monitor and type the following command:

AT

You should get an “OK” response. This means that the module is working and that you are good to go. Now we are ready to test a two way communication between the module and another device.

Step 4: Basic AT Commands

The ESP8266 ESP-01 module has three operation modes:

  1. Access Point (AP)
  2. Station (STA)
  3. Both

In AP the Wi-Fi module acts as a Wi-Fi network, or access point (hence the name), allowing other devices to connect to it. This does not mean that you will be able to check your Facebook from your device while the ESP-01 module is operating in the AP mode. It simply establishes a two way communication between the ESP8266 and the device that is connected to it via Wi-Fi.

In STA mode, the ESP-01 can connect to an AP such as the Wi-Fi network from your house. This allows any device connected to that network to communicate with the module.

The third mode of operation permits the module to act as both an AP and a STA.

Step 5: Basic AT Commands - STA Mode

In this tutorial, we are going to set the module to operate in STA mode by typing the following command:

AT+CWMODE=1 

The corresponding number for each mode of operation is as follows:

  • STA = 1
  • AP = 2
  • Both = 3

Step 6: Basic AT Commands - Check Mode

If you want to check what mode your Wi-Fi module is in, you can simply type the following command:

AT+CWMODE? 

This will display a number (1, 2, or 3) associated with the corresponding mode of operation.

Step 7: Basic AT Commands - Connecting Wi-Fi Network

Once we have the ESP-01 operating in STA mode, we need to connect to a Wi-Fi network. First we can check if we are already connected to one by sending the command:

AT+CIFSR 

This will display the station IP address of our ESP-01 module. If you don’t get an IP address after entering the previous command, use the following command to connect to your network:

AT+CWJAP= “Wi-FiNetwork”,“Password” 

Type the name of your Wi-Fi network and the password to connect to it. Make sure you include the quotation marks. After a couple of seconds, you should get an "OK" response. You can check again to see if you have an IP address using the AT+CIFSR command.

Step 8: Basic AT Commands - Enable Connections

Then we need to enable multiple connections before we can configure the ESP8266 ESP-01 module as a server. Type the next command:

AT+CIPMUX=1 

Once again, each number is associated with a type of connection:

  • Single = 0
  • Multiple = 1

The following step is to start the server at port 80:

AT+CIPSERVER=1,80 

The first number is used to indicate whether we want to close server mode (0), or open server mode (1). The second number indicates the port that the client uses to connect to a server. We chose port 80 because this is the default port for HTTP protocol.

Step 9: Basic at Commands - Response

Picture of Basic at Commands - Response

Now, when we open a web browser and type the IP address of our ESP module we get the following response as shown in the image above.

This is the HTTP request that our computer sends to the server to fetch a file. It contains some interesting information such as what file you want to retrieve, name of the browser and version, what operating system you are using, what language you prefer to receive the file in, and more.

Step 10: Basic AT Commands - Send and Display Data

Picture of Basic AT Commands - Send and Display Data

We can now use the following commands to send some data and display it in our web browser’s window:

AT+CIPSEND=0,5 

The “0” indicates the channel through which the data is going to be transferred; while “5” represents the number of characters that are going to be sent.

When we hit enter, the symbol “>” appears. This indicates that we can now type the characters that we want to send to the browser. In this example we chose “hello.”

After a couple of seconds we get the response "SEND OK." This means that the data has been transmitted successfully to the client. However, nothing appears on the web browser’s window yet. This is because it is required to close the channel first in order to display the characters. We use the following command to close the channel:

AT+CIPCLOSE=0 

“0” indicates the channel that is being closed.

Once we hit enter, our message is displayed on the web browser’s window as shown in the image above.

You can refer to the following site to see the ESP8266 AT Command Set:
http://www.pridopia.co.uk/pi-doc/ESP8266ATCommands...

Step 11: Check That Our ESP-01 Receives Data - Mobile Telnet

Picture of Check That Our ESP-01 Receives Data - Mobile Telnet

Now we want to check that our ESP-01 module receives data. We will use the Android application “Mobile Telnet” to test this.

  1. Open the Android application and from the menu select “Telnet Settings."

Step 12: Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

Picture of Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

Type in the IP address and the port number.

Click “OK” and from the menu select “Connect.”

Step 13: Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

Picture of Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

Type the characters that you want to send and then click the “Send” button.

Step 14: Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

Picture of Check That Our ESP-01 Receives Data - Mobile Telnet Con.t'

We get the following response as shown in the image above on the serial monitor.

The message is successfully received and displayed.

Step 15: Check That Our ESP-01 Receives Data - PuTTY

Picture of Check That Our ESP-01 Receives Data - PuTTY

Instead of Mobile Telnet, you can also use PuTTY to check that the ESP-01 is receiving data correctly. You can download PuTTY here.

If you decide to use PuTTY follow these steps:

  1. Open the program
  2. Select “Telnet” as the connection type
  3. Type the IP address and the port number
  4. Click on “Open"

Step 16: Check That Our ESP-01 Receives Data - PuTTY Con.t'

Picture of Check That Our ESP-01 Receives Data - PuTTY Con.t'

5. Type the characters that you want to send and hit “Enter.”

Step 17: Check That Our ESP-01 Receives Data - PuTTY Con.t'

Picture of Check That Our ESP-01 Receives Data - PuTTY Con.t'

We get the same response as before.

Step 18: Miscellaneous - Different Firmware

If you want to use a different firmware such as NodeMCU, you need to download an ESP8266 flasher such as this one. Then you need to download the binary file. You can use the following site to do it. Make sure you download just the integer type.

https://github.com/nodemcu/nodemcu-firmware/releases

Step 19: Different Firmware Set-up Con.t'

Picture of Different Firmware Set-up Con.t'

Open the ESP8266 flasher and select the bin that you just downloaded. Select the serial port and type 0x40000080. Before you click on “Download,” make sure you ground GPIO0. This is required every time a new firmware is being flashed.

When you click on “Download” the flasher will delete the current firmware and start installing the new one.

Step 20: Different Firmware Set-up Con.t'

Picture of Different Firmware Set-up Con.t'

Once the firmware has been installed, you can disconnect GPIO0 and use it normal.

We hope you enjoyed this Instructable, and you can find more tutorials about the ESP8266 and more on Jaycon System's website.

If you have any questions about this tutorial, do not hesitate to post a comment, shoot us an email, or post it in our forum.

Thanks for reading!

Comments

marwan 2017 (author)2018-01-21

thank you your tutorial is very helpful

hazwanhaikal1997 (author)2018-01-19

Thanks for that tutorial really help me out!

PieterT12 (author)2018-01-04

Also couldn't send AT commands, fixed it by removing the <SPACE> at the end of the example. So All goes well if you just type the example AT command, but if you use copy/paste remove the <space>

riker65 (author)2017-12-08

Hi

I am trying to get the ESP01 running on top of a arduino Uno.

Wont Work.

Did same wiring as descripted.

Tried the LED example, won't work.

No AT response from Serial Monitor.

how can i identify the root cause of the problem?

What can I check?

Thanks a lot.

T

RandyH80 (author)riker652017-12-23

What exactly do you mean by "On Top of a Arduino"? The ESP8266 can be programmed to fully function on it's own, with no Arduino connected.....or it can be connected so that communications are handled by the Arduino and passed through to the ESP8266.

First and most importantly.....

If you uploaded ANY sketches from Arduino to the ESP8266, (often you do this by setting the board in the Arduino interface to ESP8266 and then upload a sketch that goes into the ESP8266. Another way is to "flash" the ESP8266. If you did either, you likely overwrote the firmware that handles AT commands and you will ned to re-flash your ESP8266 with firmware usually from Expressif to regain the ability to use AT commands on the ESP8266.

If you are certain you did neither and the ESP8266 is still in factory condition, you should be able to perform a simple test using the Arduino. Simply connect as follows....

ESP8266------------------------------Arduino

VCC------------------------------------- 3.3v

TX----------------------------------------RX

RX----------------------------------------TX (try switching these is no response)

GND--------------------------------------GND

That's all you need to connect. Just be sure to upload a blank sketch into the Arduino before you begin. Next, (assuming Windows), using the Control Panel on your computer, go into the device manager and make sure the port for the Arduino shows up when you power the Arduino from the USB port.

A new entry should pop up after a few seconds. That is the port number for your Arduino. Go into the Properties and make sure it is set to 115200 baud.

Now in the Arduino Interface, make sure the Baud rate and ports match what you saw in the Device Manager in Windows. If they do, open the Serial Monitor and make sure at the bottom you have it set to 115200 baud and that Both NL and CR is selected in the first drop down box.

Now at the top in the input box, enter capital AT and click send. If you do not receive OK you either accidentally flashed your ESP8266 and over wrote the factory firmware, your serial connection is bad (change USB cables and try again), or you received an ESP8266 that did not come with the AT firmware or is defective. In which case you should try a different one.

RandyH80 (author)RandyH802017-12-23

PS...you can also try 9600 baud but as far as I know, ALL ESP8266's can operate at speeds between 300 baud and 115200 baud now. They usually come programmed to operate at 115200. 9600 was was when they first came out. Another "potential" problem is that the ESP8266 may not be getting enough power depending on your particular Arduino. If you're like me and have a drawer full of Arduinos, try another. You really should have no trouble powering just the ESP8266 from the Arduino for this simple test.

JayconSystems (author)riker652017-12-21

Try using a baud rate of 9600 or 115200, and make sure you have NL & CR enabled in the Serial Monitor. Once the Serial monitor is opened, you can add a wire to the RST pin and carefully short it to ground (just a quick tap). See if you get any response from the module.

riker65 (author)JayconSystems2017-12-22

ok thanks, will check.

DavidP821 (author)2017-10-03

I would definitely like to have more explanation, such as power, IDE setup, BareMinimum, etc.

That Instructable is not targetted to someone that want to get started with the ESP8266.

JayconSystems (author)DavidP8212017-12-21

Power:

The ESP usually draws a lot of current (~70mA with peaks that could reach 175mA !). For stability purposes it is preferred to use an external power supply such as a Lipo battery with enough capacity to handle these spikes.

IDE Setup:

No special setup is required for the IDE. Just make sure you use a baud rate of 9600 or 115200, and that NL & CR are enabled. You can even use any other Serial Terminal like Putty to send AT commands to the module

na_esso (author)2017-10-13

Hello , Thank you for this tutorial .

How can i upload the nodemcu firmware , should i connect it to the laptop direct or i can upload it throw the arduino ? and what are the commands for nodemcu firmware

JayconSystems (author)na_esso2017-12-21

Please refer to Steps 18-20. You can upload it through Arduino or with a 3.3V FTDI. If you decide to use the FTDI connect Arduino_TX to FTDI_RX, and Arduino_RX to FTDI_TX.

AneeqK (author)2017-12-17

I tried uploading the AT Commands using serial port ....

ESP rx,tx to ardunio tx,rx...

gnd to gnd

vcc to 3.3v

by entering AT commands in Serial monitor

they shows some random values like 56,10..

JayconSystems (author)AneeqK2017-12-21

Try using a baud rate of 9600 or 115200, and make sure you have NL & CR enabled in the Serial Monitor.

nicobrix (author)2017-12-09

Very good! I like it very much! Thank you for this!

nicobrix (author)2017-12-09

Good job! I like it very much!

LucasG12 (author)2017-11-08

I solved getting IP using AT+CWJAP_DEF="my wifi","password" then you send AT comands, and check your IP.

but when I put the IP adress in the web browser, it does not send the http request to the module. Also by using telnet mobile does not work, it can´t conect to the ip asigned, port 80, gets stucked trying to conecting.

by the way, always use an external power, stable, over 250 mA (3.3V).

quanticchaos (author)2017-11-03

This is very interesting, I'm new to arduino and one of my goals is WIFI communication for sensors and control. At the beginning it was a little frustrating because I only received weird characters in my monitor but with a little research I found that for some firmwares you have to set another baud (It was 115200 for mine). I also found that you have to select "NL & CR" in the serial monitor for the commands to work (I guess this is something normal but for a newbie like me it was not obvious). Thanks a lot, hope you keep sharing your knowledge with us.

minh nhatN1 (author)2017-09-11

Hello there, thanks a lot for your great help

But i messed up at the last step. I tried to install a new firmware, but at 99% it failed to close flashing since the I have not been able to use AT command via arduino serial port any more

what's the new firmware???.....only AT firmware responds with AT commands other firmwares like nodemcu doesnt work that way.....Isthe last error message u received while flashing is that something like "Failed to leave flash mode"? if that so then there is no problem in ur flashing because esp8266 can't get out of flashing mode automatically.

raybuss (author)2017-09-04

Spot on! Thank you!

windhoarfrost (author)2017-09-03

Great tutorial sir. Thanks.

Ahmedqatar (author)2017-08-26

Thank you so much!

EdwinM73 (author)2017-08-15

Woo i got it working the code above is fine, the only important thing is to make sure you have enough power to the vcc " 3.3v @ 200Ma +" and connect the ground of said power supply to the arduino's ground too. I have it working without an LLC but it should also be used on the rx and tx lines.

StephenF72 (author)2017-01-28

Hello guys,

Everything works fine with the AT commands, but the browser doesn't connect to the IP address. I tried both the IPs, 'APIP' and 'STAIP' but no luck. The telnet thing says 'connection refused'.

What should I do??

BushraH6 (author)StephenF722017-07-21

same problem
Did you solve it ?

my computer and ESP module is connected to same WIFI

DAEHWANL made it! (author)2017-07-02

My first link with ESP-01

I used following AT command.

AT+CIPMUX=1

AT+CIPSERVER=1,80

Nice tutorial!

Gtmize (author)2016-11-17

Nice tutorial, thanks. I've tried two different Uno boards with two different 8266 boards (Makerfire) and end up at the same place ... when I type AT ... nothing.

I've checked voltages & wiring multiple times. Reading the thread here has helped ( baud rate etc) but can't seem to isolate the problem. So . I'll go try a different experiment & come back to this one. I'm sure its something basic but doubt you can offer more than is already here.

Anyway these things are like puzzles ... keeps it interesting.

IshtiaqA6 (author)Gtmize2017-05-29

sir can you help me i want to communicat two arduino uno with two 8266 please sir help me if you can

shigmas (author)Gtmize2017-03-11

It's been a while, but I was using thing guide and saw this comment. I was having trouble, too. One amazon review of the Makerfire chip said that they had to reflash the firmware. And, I also wired GPIO0 to the 3.3V (along with VCC and CH_PD).

I'm getting the "OK" response now.

JDP5 (author)Gtmize2016-11-28

Have you tried changing the baud rate to "115200" and select "Both NL & CR" in the serial monitor, as wklin pointed out earlier? I was in the same position and that solved my problem.

RaviK302 (author)2017-05-02

It is taking too long like 5 to 10 min to connect to the IP which was generated, is there any solution to it??

keaaw (author)2017-03-18

I'm a complete newbie at this stuff so forgive me if I'm confused, but I noticed a few things in these instructions that may explain why people are having problems. If I'm off-base, please correct me so I can learn something :).

1) In everything I've read about asynchronous serial communication, the Rx, Tx of one side should be wired to the Tx, Rx of the other side. You show Rx -> Rx and Tx -> Tx...why is that?

2) The arduino Tx line will be driven at 5V and the ESP-01 Rx line should (I've read) only be exposed to 3.3V, so most guides show a level converter between them. (Maybe the same applies to the arduino Rx line)

3) The 3.3V output of the arduino may not supply the peak current that the ESP-01 may need at times.

Psalm51 (author)keaaw2017-04-21

You're right on all three. Rx should go to Tx, and Tx to Rx. This is likely why so many comments are about being unable to get a response, saying they wired exactly as it says. ESP Tx should be on Uno Pin 0, and ESP Rx should be Uno Pin 1

A logic level converter is needed so the esp8266 isn't damaged from the 5V. But if you supply the arduino from a 3.3-3.7V source you don't need it. Powering from USB or a wall plug you need logic level shifting or it will eventually damage the ESP-01. May work for a little while anyways, but why risk it.

And the Arduino 3.3V current supplies up to 200mA per the specs, and Esp8266 can draw up to 250mA. It's likely it will still work and never reach 250mA, but there is still potential for communication errors and unstable operation.

jilvir made it! (author)2017-03-24

My ESP-01 now is working and responding to commands, but I can connect to the network... somebody can help?

jilvir (author)2017-03-20

When I do the AT commands it give me a response of unreadable its like encrypted character. somebody can help?

AndriusM9 (author)jilvir2017-03-21

Bottom right side select cl & rf or something like that and choose correct baud rate. Most likely 9600

jilvir (author)AndriusM92017-03-21

may I know which bottom? is it in serial monitor?

Gtmize (author)2016-11-18

Success! ... did two things ... 1) added batteries to power ESP ( common grnd), and 2) switched Tx Rx lines in my frustration .. lables on Uno are confusing ..

Anyway as soon as I did it responded to AT and serveral other commands including

AT+GMR

AT version:0.25.0.0(Jun 5 2015 16:27:16)

SDK version:1.1.1

Ai-Thinker Technology Co. Ltd.

Jun 5 2015 23:07:

2015 ... I would assume I need firmware update ... it was not responding to some of the AT commands .. ( AT+CLOMODE=1 ..

Also .... it did respond with an IP Address ( AT+CIFSR)

AT+CIFSR

+CIFSR:APIP,"192.168.4.1"

+CIFSR:APMAC,"5e:cf:7f:84:ba:ed"

.. but Chrome could connect to it

I was unable to log in using AT+CWJAP="Name","PW" .. go ERROR

Also on my IPhone I can see a device AI-Thinker_9 but not showing an IP Address ...

Anyway having a blast ... baby steps

G

keaaw (author)Gtmize2017-03-18

Yes, in async serial communications the connections are Rx -> Tx and Tx -> Rx, this looks like a mistake in the instructions. I've also read that the 3.3v output of the arduino may not provide enough current to the ESP-01, your message seems to validate these points. Did you put a level converter on the arduino Rx, Tx so that the ESP-01 isn't subjected to 5V (outside its operating range?)

Gtmize (author)keaaw2017-03-19

Yes I did use level converter

HudF (author)Gtmize2016-11-26

i did the connections same as above but i got this error every time i upload a program. no response to AT commands..and please help me with this confusion .... while checking AT commands should we remove arduino IC or do simply as it is?

warning: espcomm_sync failed

error: espcomm_open failed

error: espcomm_upload_mem failed

error: espcomm_upload_mem failed

relative_frequency (author)2017-01-28

UPDATE: AT Commands are working fine, I can connect to my home network but the second I want to check the IP address (AT+CWJAP?), I get "busy p..." then a FAIL message and +CWJAP:3. If you have a dual band router, you need to connect to the 2.4GHz network.

relative_frequency (author)2017-01-28

For those of you using the ESP8266 ESP-01S (S Series) will realise that VCC and CH_PD is not listed on the afore mentioned module. I have inserted jumper wires into the "3V3" (which replaces the VCC) and the "EN" (which replaces the CH_PD). I then ran the BareMinimum Sketch, opened the serial monitor, changing settings to "Both NL & CR" and "115200 baud rate". This worked for me. However, I do notice that the module is getting slightly warm.

GeeksTipsDotCom (author)2016-12-11

Excellent article! You should approach tips like the DEEP SLEEP workaround for ESP-01 . Many people are buying ESP 12 version just because they don't know that ESP01 can handle DEEP SLEEP mode too by just soldering a little wire to the MCU.

sanderdb01 (author)2016-11-30

Awesome tutorial. Grade A stuff

HudF (author)2016-11-26

i did the connections same as above but i got this error every time i upload a program. no response to AT commands..and please help me with this confusion .... while checking AT commands should we remove arduino IC or do simply as it is?

warning: espcomm_sync failed

error: espcomm_open failed

error: espcomm_upload_mem failed

error: espcomm_upload_mem failed

calibrearun (author)2016-03-08

Hi Thanks for this stuff ...I had did the exact connection between arduino and ESP8266 as in instructable. While giving the AT cmd i am not getting any response from ESP. Please give the solution for this, if it available

Hi! Thanks for reading! Double check your connection from the ESP to the Arduino as shown in the four diagrams in Step 2. If that doesn't work, then you may need to update your firmware. Arduino IDE Version 1.6.5 works best with ESP8266. If you are using an earlier version of Arduino IDE, then that may be the problem. If that is not the problem, then reply back or make another comment, and we'll try and find the solution for you. Best wishes!

Thanks for the reply geek, My connection between ESP and Arduino is perfect.
Is there anyway to find the current working Firmware version of ESP8266, If in this case how it is, or
kindly provide me how i can update my new firmware version which is best suitable for this ESP, then please mention the version .
Provide me if there is any instructable or link for perfect firmware update.

About This Instructable

199,313views

269favorites

License:

Bio: We bring hardware products to life, specializing in engineering, prototyping, and mass manufacturing. We've worked with over 20 Kickstarter projects.
More by JayconSystems:How to Measure a Corner's Radius Using a 3D Printed ToolSending Commands Via the LCD BackpackProgramming a Single 7 Segment Display
Add instructable to: