ESP AT Networking

Flashing AT Firmware

To use the ESP8266 chip as a modem (Figure 1) we must first load the appropriate AT-command firmware.

Figure 1: ESP8266 as a modem.
Download Software
  1. Download the latest ESP Flash Download Tool (v3.6.4 at the time of writing) from [1].
  2. Download the latest AT release from [2] or [3].
Flashing Procedure
  • Detect ESP8266 module parameters. Start ESP Flash Download Tool (“ESPFlashDownloadTool_v3.6.4”), set the COM port corresponding to your programmer, then click the START button in order to detect the specs of the board. After detection, you should see something like this (Figure 2):
Figure 2: Programming ESP8266 – detected parameters.
  • Gather information. Make a note of the flash memory size. In this example, we have a 32 Mbit flash.
  • Load the correct size of combined AT binary firmware file (“.bin”) and set the offset as 0 × 0, you should see something like this (Figure 3):
Figure 3: Programming ESP8266 – setting proper image file.
  • Then, click the START button and wait until the flashing process is over.
Reflashing Procedure

If necessary, to restore the original firmware:

  • Detect ESP8266 module parameters. Start ESP Flash Download Tool (“ESPFlashDownloadTool_v3.6.4”), set the COM port corresponding to your programmer, then click the START button in order to detect the specs of the board. After detection, you should see something like this (Figure 4):
Figure 4: Programming ESP8266 – detected parameters.
  • From the downloaded AT firmware folder, open the “readme.txt” file containing the information for flashing the firmware. Inside the file, there should be a “BOOT MODE” section, as follows:
# 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
  • Indicate – correct for your ESP8266 flash size – firmware files & addresses. The firmware is broken down into several files. They need to be provided to the ESP Flash Download Tool, together with the corresponding addresses found in the readme.txt file above. For our ESP8266 example it should look like this (Figure 5)
Figure 5: Programming ESP8266 – reflashing settings.
  • Then, click the START button and wait until the flashing process is over.

Basic ESP8266 Networking

After uploading AT firmware and connecting module to PC, we can use ESP8266 as a modem with simple AT commands.

We can connect ESP8266 to PC with TTL-Serial-to-USB adapter, or we can use any microcontroller with a serial interface. The default baud rate settings are 115200,N,8,1. Next from any terminal type command:

AT

and press enter. If you get OK, the ESP8266 module is ready to use. Let’s try out some other commands. For example, let’s figure out exactly what firmware version we’re dealing with. To do that, we’ll use the following command:

AT+GMR

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

  • mode 1 – client mode – the ESP8266 connecting to an existing wireless network,
  • mode 2 – access point mode (AP) – other wireless network devices can be connected to the ESP8266,
  • mode 3 – dual mode (router) – the ESP8266 act as an access point and connect at the same time to an existing wireless network.

By default, the ESP8266’s stock firmware is set to AP mode. If you’d like to confirm that, send the following command:

AT+CWMODE?

You should get this response: +CWMODE:2, where 2 corresponds to AP mode. To switch ESP8266 to client device mode, we use the following command:

AT+CWMODE=1

Now we can scan the airwaves for all WiFi access points in range. To do that, we send:

AT+CWLAP

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

  • 0 – open,
  • 1 – WEP,
  • 2 – WPA_PSK,
  • 3 – WPA2_PSK,
  • 4 – WPA_WPA2_PSK.

Now we can connect to the available access point using proper “ssid_name” and “correct_password” with the command:

AT+CWJAP="ssid_name","corect_password"

If everything is OK, the ESP8266 will answer:

WIFI CONNECTED
WIFI GOT IP
OK

It means that ESP8266 is connected to the chosen AP and got a proper IP address. To check what the assigned address is we send the command:

AT+CIFSR

To set up ESp8266 to behave both as a WiFi client as well as a WiFi Access point.

AT+CWMODE=3
en/iot-open/getting_familiar_with_your_hardware_rtu_itmo_sut/esp/building_your_first_project.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0