Getting Started With the ESP8266 ESP-01

369,789

358

133

Introduction: Getting Started With the ESP8266 ESP-01

About: We bring hardware products to life, specializing in engineering, prototyping, and mass manufacturing. We've worked with over 20 Kickstarter projects.

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Materials

Step 2: 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

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

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

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'

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'

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'

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

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'

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

Step 17: 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'

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'

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!

6 People Made This Project!

Recommendations

  • Trash to Treasure Contest

    Trash to Treasure Contest
  • Raspberry Pi Contest 2020

    Raspberry Pi Contest 2020
  • Wearables Contest

    Wearables Contest

133 Discussions

Shouldn't the "bare minimum" not also contain a Serial.begin(9600) command?

I have the feeling this instructable in incomplete...

0
AndyN18
AndyN18

Reply 19 days ago

It's not necessary to begin serial. The connection is, effectively, direct to the ESP module, so you're not communicating with Arduino - Rx/Tx is between the serial console from eh Arduino IDE and the ESP module (we're just using the Ardunio's serial transceiver)

0
AndyN18
AndyN18

Tip 19 days ago

Communications tip: Things to check when it's not responding to "AT" as you expect.
1. Check you baud rate. The ESP units I got from Amazon default to 115200 baud (I tend to use 9600, so needed to change)
2. Line ending (options on bottom right of serial console). Ensure you set this to "Both NL & CR" (commonly called CR/LF). Other options will cause errors (or no response)
3. Watch out for tailing spaces. When pasting AT command, copied from this indestructable, you may inadvertently include trailing space(s) at teh end of the command - that will cause an "ERROR" response. Make sure you delete and trailing spaces before sending the command.

0
ghitalazar
ghitalazar

25 days ago

Hi, very useful instructions.
I used an USB-RS232 converter instead of Arduino, and it works perfectly.
Thank you for these instructions

0
iamnotarobot496913
iamnotarobot496913

Question 2 years ago on Step 7

When I tried to connect ESP01 to WiFi using AT+CWJAP= “ ”,“ ” command it kept returning error. How do I resolve this problem? Thanks.

Sample message pasted below:

AT+CWJAP= "Smile:)","123456"
ERROR

0
BrianW305
BrianW305

Answer 6 weeks ago

I know this is old but I'm answering for anyone trying to follow this instructable. The AT+CWJAP= "network","password" as written has a space between the = and " , it will not work with a space there try it without the space.

0
phi644
phi644

Question 3 months ago

#step4
Where can i find this third party software? Instructable available?

0
Marvelous69
Marvelous69

Answer 6 weeks ago

BareMinimum starts with File New and upload it.
You communicate with the ESP, the Arduino provides your physical interface.

0
look_itended
look_itended

Question 4 months ago on Step 3

Hi there,
I need to ask about step 3. My code is as below:

void setup() {
Serial.begin(9600);
Serial.println("Hello Computer");
}
void loop() {
}


I managed to run and upload the sketch but I was not able to let "OK" display after I input "AT" into the field and changed the baud rate 9600. There's no error or anything showed. Thanks!

3
fa.h2so4
fa.h2so4

7 months ago on Step 3

Somethings to note: You should set the baud rate 115200 and use Both NL & CR for the AT command to run.

1
tomusernamealreadyinuse
tomusernamealreadyinuse

Reply 5 months ago

Also, you cannot load the sketch while port 0 and 1 are connected to the ESP.

This instructable is missing quite a few of the basic steps....

Are you sure the ESP can be connected to the Arduino without a 5V-3,3V convertor between arduino's Tx and the ESP's RX? A mistake here could damage the ESP.

I have the feeling this instructable is incomplete... (and potentially hazardous for the elektronics)

0
VishnuS93
VishnuS93

Question 7 months ago

Step 3 is not working can anyone help ??

1
IanS240
IanS240

Answer 6 months ago

I assume when you try to load the BareMinimum program the IDE errors when uploading. If so I had the same issue. The connection between the UNO and the ESP are not correct, the author is missing a few. The missing connections are GPI01 to GND and UNO RST to GND. Hope that works for you.

0
DonaldM117
DonaldM117

9 months ago

Good morning. I followed you configuration plan, the ip address was assigned, downloaded BareMinimum and Blink several times and it works. Now, when I use the Arduino Serial Com window, AT does not return any info. I'm retired and decided to get into Home Automation. This is a road block to that dream. Suggestions? Thanks for the support.

0
oladunk321
oladunk321

Reply 7 months ago

If you want to go to Home Automation avoid this ESP-01 module. For a beginner this is the most complicated module to start with. So many quirks and issues.
Start with a Wemos D1 mini and save yourself lots of time. Small and relatively cheap on Ebay or Bangood. You can program in Arduino IDE or Micropython.
Well documented with many examples on the net.

0
sdingman
sdingman

Question 8 months ago

I am having an issue at the very start. When I make the basic connections as shown in my attached document, I cannot get a response to my AT commands. It seems as though there are many, many instruction that just assume that everyone is getting the response back from the ESP8266-01 as what is expected.

I'm using the Arduino IDE Serial Monitor, a USB to TTL serial converter, a Buck Converter supplying the 3.3 volt power to the ESP8266-01. The Tx from the USB to TTL Serial converter goes to the Rx of the ESP8266-01 via a 1 k ohm + 2 k ohm resistor voltage divider to cut the 5 volt TTL signal leval to 3.3 volt level. The Tx from the ESP8266-01 goes directly to the Rx of the USB to TTL Serial Converter. Reset from the ESP8266 is held to a 3.3 volt high through a 10 k ohm resister. The GPIO-0 is held at a 3.3 volt high through a 10 k ohm resistor and the GPIO-2 is left unconnected. The Ground of the USB to TTL Serial Converter is tied to the ESP8266-01 Ground and the Buck Converter Ground.

With the USB to TTL Serial Converter connected to my Com 5, whenever I apply power to the ESP8266-01 or press the Reset button I get a line of gibberish, then on the next line appears:
IA Thinker
followed by:
Ready
At this point it should respond to AT input with OK, but I get nothing. I have tried every baud rate setting, with exactly the same result. I have not Grounded GPIO-0 while power is being applied because I nevered wanted to update the firmware. I only ever intended to use the AT commands.

Can anyone point to a detailed trouble shooter for this problem.

0
AnirudhyaB
AnirudhyaB

Question 9 months ago on Step 3

I have made the connection as per the tutorial and then upload the code. The code is successfully uploaded. But in the serial monitor when I type "AT" I can't see the "OK". What is the problem?

0
yidnekkedir
yidnekkedir

Answer 8 months ago

you need to change and set the baudrate to the 115200 in arduino terminal

0
fatimahzaharah
fatimahzaharah

Question 9 months ago on Step 3

Hello. After I upload the code, in serial monitor when I type AT command I did not get an OK response. How can I fix this?