7

Setting up ESP8266 WiFi Module Using AT Commands Set

ESP8266 Introduction

The ESP8266 WiFi Module is a self contained system on chip with integrated TCP/IP protocol stack that can give any micro controller access to a WiFi network. Each ESP8266 module comes programmed with an AT command set firmware, which means, you can simply hook this up to your PC, Arduino or any other micro controller device having UART and get about as much WiFi capability as a WiFi Shield offers. The ESP8266 module is an extremely cost effective board with a huge, and ever growing, community.

 

Important Note: ESP8266 Module does not include 3.3V regulator which means that it will require an external regulator to convert 5V into 3.3V for operations. Remember, do not power it directly from 5V source or it will eventually get damaged.

If you are not sure how to setup ESP8266 then check out the 3.3v connection diagrams or 5v connection diagram before you continue.

Check out this article if you want to connect your PC / laptop with ESP8266.

Check out following links of you are interested in purchasing ESP8266 at low cost online

ESP-01 ESP8266 2.4GHz Wireless Module – BLACK $2.69

Upgraded Version 1M Flash ESP8266 ESP-01 WIFI Transceiver Wireless Module $3.19

Check out variety of ESP8266 WiFi Module at Amazon

Note: By default ESP8266 communicates at BAUD rate of 115200 bit/sec if required it can be changed using AT Commands.

 

AT Command set for ESP8266

Setting up a ESP8266 can be a problem if you are not familiar with AT Command set for ESP module. AT Commands can be used for (but are not limited to) performing following operations on the module

  1.  Test if the module is working properly
  2. Reset the WiFi Module
  3. Check version
  4. Set operation mode: Station Mode, AP Mode or hybrid mode
  5. Connect to an Access Point
  6. Search WiFi Access Points (Routers)
  7. Disconnect from an Access Point
  8. Configure ESP8266 AP settings
  9. Get connection status
  10. Get Local IP Address
  11. Setup TCP/IP Server
  12. Sends data over network
  13. Read incoming data
  14. Setup ESP8266 Station mode
  15. Configure station mode
  16. and much more…

Following are the AT Commands and the response received from ESP8266
IF you want to know about some AT Command not listed below then feel free comment about it in the comments section at the end of this page and we will get back to you with a solution to your problem.

Checking Communication

AT
OK

Reset WiFi Module

AT+RST

OK
WIFI DISCONNECT

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 1856, room 16
tail 0
chksum 0x63
load 0x3ffe8000, len 776, room 8
tail 0
chksum 0x02
load 0x3ffe8310, len 552, room 8
tail 0
chksum 0x79
csum 0x79

2nd boot version : 1.5
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

??r?l?l? ?l`??r?l?l? l`??r?l ??rl??rl????b l?br| ?bp??bbb??n??nn? ll??l??? l??ll????l??l?n?WIFI CONNECTED
WIFI GOT IP

Check Version

AT+GMR
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK

Set Station Mode

AT+CWMODE=1

OK

Set AP Mode (Access Point Mode OR Router Mode)

AT+CWMODE=2

OK

Set Hybrid Mode (Station + AP) Mode

AT+CWMODE=3

OK

Get IP Address of both Station + AP Mode

AT+CIFSR
+CIFSR:APIP,”192.168.4.1″
+CIFSR:APMAC,”62:01:94:18:5d:90″
+CIFSR:STAIP,”192.168.1.123″
+CIFSR:STAMAC,”60:01:94:18:5d:90″

OK

Search Acess Points (WiFi Routers)

AT+CWLAP
+CWLAP:(3,”PTCL-BB”,-71,”c8:3a:35:75:ab:21″,2,-21,0)
+CWLAP:(3,”AKHAWALA”,-84,”2c:ab:25:4f:07:35″,6,-64,0)
+CWLAP:(3,”SSID”,-40,”c8:3a:35:95:53:69″,9,-21,0)
+CWLAP:(3,”ZONG MBB-E5573-43B6″,-89,”1c:67:58:da:43:b6″,9,-9,0)

OK

Connect to AP (WiFi Router)

AT+CWJAP_DEF=”SSID”,”PASSWORD”
WIFI CONNECTED
WIFI GOT IP

OK

 Disconnect from AP (WiFi Router)

AT+CWQAP

OK
WIFI DISCONNECT

 Get IP Address of ESP8266 Station

AT+CIPSTA?
+CIPSTA:ip:”192.168.1.123″
+CIPSTA:gateway:”192.168.1.1″
+CIPSTA:netmask:”255.255.255.0″

OK

 Set IP Address of ESP8266 Station

AT+CIPSTA=”192.168.1.123″

OK

Set IP Address,  Gateway and Subnet Mask of ESP8266 Station

AT+CIPSTA=”192.168.1.123″,”192.168.1.1″,”255.255.255.0″

OK

 Get IP Address of ESP8266 Access Point

AT+CIPAP?
+CIPAP:ip:”192.168.4.1″
+CIPAP:gateway:”192.168.4.1″
+CIPAP:netmask:”255.255.255.0″

OK

 Set IP Address of ESP8266 Access Point

AT+CIPAP=”192.168.4.1″

OK

Set IP Address,  Gateway and Subnet Mask of ESP8266 Access Point

AT+CIPSTA=”192.168.4.1″,”192.168.4.1″,”255.255.255.0″

OK

Get Configuration of ESP8266 Access Point

AT+CWSAP_DEF?
+CWSAP_DEF:”MY_ESP8266″,”password”,1,3,4,0

OK

Note: where 1=channel, 3=WPA2_PSK, 4=Max Connections, 0=SSID is broadcasted
for more details check out the AT Command Set documentation.

Set Configuration of ESP8266 Access Point

AT+CWSAP_DEF=”MY_ESP8266″,”password”,1,3,4,0

OK

Note: where 1=channel, 3=WPA2_PSK, 4=Max Connections, 0=SSID is broadcasted
for more details check out the AT Command Set documentation.

Creating a TCP/IP Server

AT+CIPMUX=1

OK
AT+CIPSERVER=1,8080

OK

Note: TCP/IP Server created on port 8080, now clients can connect to ESP module on specified port.

Deleting a TCP/IP Server

AT+CIPSERVER=0

OK

 

Complete AT Instruction Set PDF can be downloaded from here

Absar A. Ansari

7 Comments

  1. Hi Absar,
    So nice to read about your ESP8266 engagement – thanks a lot. It it very helpfull.
    I have a problem – I need to run 38400 baud. Here is my setup:
    AT+GMR
    AT version:1.3.0.0(Jul 14 2016 18:54:01)
    SDK version:2.0.0(656edbf)
    compile time:Jul 19 2016 18:44:44
    OK

    AT+UART_CUR? (Trying to see current status)
    AT+UART_CUR? (I have echo ON)
    ERROR
    AT+UART_CUR=38400, 8, 1, 0, 3
    AT+UART_CUR=38400, 8, 1, 0, 3
    ERROR
    AT+UART_CUR=38400, 8, 1, 0
    AT+UART_CUR=38400, 8, 1, 0
    ERROR
    AT+UART_DEF=38400, 8, 1, 0
    AT+UART_DEF=38400, 8, 1, 0
    ERROR
    AT+UART_DEF=38400, 8, 1, 0,3
    AT+UART_DEF=38400, 8, 1, 0,3
    ERROR
    No matter what I try – I get an error.
    Have I missed something – a prereq or other stuff?
    Hope you will find the time to help – thanks. It will be greatly appreciated.

    • I have checked and you are right, I was unable to get AT+UART_DEF and AT+UART_CUR work myself along with other commands like AT+SYSRAM? and AT+SYSADC? which checks for remaining system RAM and system ADC. I will look into it closely once I get time but for now all I can do is recommend you use the default baud rate of 115200 and program your controller accordingly.
      If you find out how to get these commands to work then do share..
      Thanks,

  2. Thanks Absara for the trying out.
    Suddenly it works – some sort of reset? Or take care not to include spaces at the end of command string (copy/paste error?).
    My next issue is that I cannot set the IP-adress:
    AT
    OK
    AT+CIPSTA_DEF:?192.168.1.123?,?192.168.1.1?,?255.255.255.0?
    ERROR
    I’m lost – why must it always be like this. Every little step costs.

  3. I needed to post you that little observation in order to thank you very much the moment again about the pleasing principles you have provided above. It has been so extremely open-handed of you to deliver openly just what most people could have advertised as an e book to help with making some dough on their own, particularly given that you might well have tried it if you desired. The secrets also worked to become great way to fully grasp that most people have the same keenness the same as my own to grasp much more when it comes to this condition. I believe there are thousands of more pleasant occasions up front for people who looked at your website.

Leave a Reply

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