Table of Contents

ESP AT Networking

 General audience classification icon  General audience classification icon
ESP8266 SoC can work as the WiFi communication module for other microcontrollers. To use the ESP8266 chip as a modem (figure 1), the module must be flashed with the appropriate AT-command firmware. Espressif and other developers prepared the ready-to-use firmware with the AT-command interpreter. This firmware can be downloaded from the web and flashed into ESP8266 memory with a flash tool.

 ESP8266 as a modem
Figure 1: ESP8266 as a modem
AT commands were developed to control telephony modems. They are often used to control modules connected via a serial port, including GPS receivers, GSM/LTE modems, network modules, and others.

Preparing an ESP8266 chip with AT commands firmware

Downloading Software

Other flashing tools like NodeMcu Flasher [2] exist. While using a single binary file, other flashing tools can be used like esp8266 flasher [3], Tasmotizer [4] or others.

The newest version of Espressif firmware is not compatible with ESP8266 SoCs. In the case of using ESP8266-based boards, download older AiThinker firmware available on GitHub [6]. The firmware can come in different versions. It can be a set of binary files that must be uploaded to specific memory addresses or as a combined single binary file. Note that a single file is prepared for a particular flash memory size.

Flashing Procedure with single binary file
 Programming ESP8266 - detected parameters
Figure 2: Programming ESP8266 - detected parameters
 Programming ESP8266 - setting proper image file
Figure 3: Programming ESP8266 - setting proper image file
Flashing Procedure with a set of separate files

To flash the firmware from a set of files or to restore the original firmware:

 Programming ESP8266 - detected parameters
Figure 4: Programming ESP8266 - detected parameters
# BOOT MODE
## download
### Flash size 8Mbit: 512KB+512KB
    boot_v1.2+.bin              0x00000
    user1.1024.new.2.bin        0x01000
    esp_init_data_default.bin   0xfc000 (optional)
    blank.bin                   0x7e000 & 0xfe000

### Flash size 16Mbit: 512KB+512KB
    boot_v1.5.bin               0x00000
    user1.1024.new.2.bin        0x01000
    esp_init_data_default.bin   0x1fc000 (optional)
    blank.bin                   0x7e000 & 0x1fe000

### Flash size 16Mbit-C1: 1024KB+1024KB
    boot_v1.2+.bin              0x00000
    user1.2048.new.5.bin        0x01000
    esp_init_data_default.bin   0x1fc000 (optional)
    blank.bin                   0xfe000 & 0x1fe000

### Flash size 32Mbit: 512KB+512KB
    boot_v1.2+.bin              0x00000
    user1.1024.new.2.bin        0x01000
    esp_init_data_default.bin   0x3fc000 (optional)
    blank.bin                   0x7e000 & 0x3fe000

### Flash size 32Mbit-C1: 1024KB+1024KB
    boot_v1.2+.bin              0x00000
    user1.2048.new.5.bin        0x01000
    esp_init_data_default.bin   0x3fc000 (optional)
    blank.bin                   0xfe000 & 0x3fe000
 Programming ESP8266 - reflashing settings
Figure 5: Programming ESP8266 - reflashing settings

Basic ESP8266 Networking

After uploading AT firmware and connecting the module to the PC, an ESP8266 can be used as a modem with simple AT commands.

It is possible to connect ESP8266 to a PC with a TTL-Serial-to-USB adapter. Connection to any microcontroller with a serial interface does not need an adapter. The default baud rate settings are 115200,N,8,1. To check if the module works properly, a simple “AT” command can be used:

AT

If the response is “OK”, the ESP8266 module is ready to use and accept other commands. For example, to figure out exactly what firmware version is installed, the following command can be used:

AT+GMR
The AT command interpreter requires full “Enter” code. Both “CR” and “LF” characters must be sent. Some popular terminal programs like Putty do not send both characters. Be sure that the serial terminal software sends “CRLF” at the end of the line.

As a WiFi device, ESP8266 can connect to the network in such modes:

By default, the ESP8266's stock firmware is set to AP mode. To confirm that, send the following command:

AT+CWMODE?

The response should look like +CWMODE:2, where 2 corresponds to AP mode. To switch ESP8266 to client device mode, the following command can be used:

AT+CWMODE=1

To scan the airwaves for all WiFi access points in range, the following command can be used:

AT+CWLAP

Then, the ESP8266 will return a list of all the access points in range. In each line will be an item consisting of the security level of the access point, the network name, the signal strength, the MAC address, and the wireless channel used. Possible security levels of the access point <0-4> mean:

The following command establishes the connection to the available access point with proper ssid_name and password:

AT+CWJAP=<ssid_name>,<password>

If everything is OK, the ESP8266 will answer:

WIFI CONNECTED
WIFI GOT IP
OK

ESP8266 is connected to the chosen AP and obtained a proper IP address. The following command checks what is the assigned IP address:

AT+CIFSR

To set up ESP8266 to behave both as a WiFi client and a WiFi Access point, the mode should be set to 3:

AT+CWMODE=3