Skip to content

Device Initialization

Warren Gay edited this page Nov 13, 2015 · 31 revisions

This is can be a bit of a thorny issue for embedded applications. The ESP8266 can be reset and come up with some saved settings. But perhaps your application wants to reset the device and initialize the settings each time for full control. Is the ESP reset procedure under your MCU's control?

If your MCU has full control, you can determine when the ESP8266 is released from it's reset state. At that point, you can wait for the "ready" message. This can be done using the "manual API":

ESP8266 esp(writeb,readb,rpoll,idle);

release_esp_from_reset();

esp.clear_flat_ready();
while ( !esp.get_flag_ready() )
    esp.receive();

Here we allow the ESP device to startup and then wait for the "ready" message (assuming baud rate and UART stuff is taken care of here). When we loop waiting for the flag, we must invoke esp.receive() so that it can perform any message receiving (and set our flag).

Initiating Reset

If you want to initiate a ESP reset by software, you can alter the above procedure slightly:

ESP8266 esp(writeb,readb,rpoll,idle);

esp.clear_flat_ready();     // Clear ready flat
esp.commandok("AT+RST");    // Issue ESP reset command

while ( !esp.get_flag_ready() )
    esp.receive();

Disabling Echo

ESP8266 echo mode must be disabled to be used with the ESP8266 class. To disable echo, use the manual API:

ok = esp.commandok("ATE0");

The returned boolean will indicate that an "OK" response was received.

void reset(bool wait_wifi);

This method takes care of issuing the reset request and waiting for the "ready" message. In addition it sets:

  1. ATE0 - Echo off
  2. AT+CIPMODE=0 (to allow AT+CPIMODE=1 next)
  3. AT+CIPMUX=1 (multiple TCP/UDP sessions)
Clone this wiki locally