I have programmed ESP8266 to make it accessible over the network using below program.

First Program

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

//SSID and Password of your wifi router
const char* ssid = "Moto";
const char* password = "reset1234";

ESP8266WebServer server(80);

void setup() {

  WiFi.begin(ssid, password);     //Connect to your WiFi router

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {

  //If connection successful show IP address in serial monitor
  Serial.print("Connected to ");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP

  server.begin();                  //Start server
  Serial.println("HTTP server started");

void loop() {
  server.handleClient();          //Handle client requests

It is working fine, What is the way to reset it to run below program? I wanted to send AT commands on serial monitor using below program which has been uploaded successfully but not responding AT commands on Serial Monitor, as ESP8266 is running above program and showing output of above program on running below program on Serial Monitor.

I want to reset ESP8266 so it responds to below program. What is the way ?

Connected to Moto
IP address:
HTTP server started


#include "SoftwareSerial.h"

SoftwareSerial esp8266(2, 3); // RX, TX

void setup()
  Serial.begin(9600); // serial port used for debugging
  esp8266.begin(9600);  // your ESP's baud rate might be different

void loop()
  if(esp8266.available())  // check if the ESP is sending a message
      char c = esp8266.read();  // read the next character.

      Serial.write(c);  // writes data to the serial monitor

    delay(10);  // wait to let all the input command in the serial buffer
    // read the input command in a string
    String cmd = "";
      cmd += (char)Serial.read();
    // send to the esp8266

2 Answers 2


You need to reinstall the AI Thinker AT firmware.

Here's how you do it: How to flash ESP8266 firmware update ESP-01 AI thinker

Last time I did it I used the esptool.py program, and used the ai-thinker- firmware (there's two versions on there, the default 115200 baud, and a 9600 baud variant).

On Linux I then used the command:

foo@bar:~$ ./esptool.py --port /dev/ttyUSB0 --baud 57600 write_flash 0 ai-thinker-
Detecting chip type... ESP8266
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 512KB
Flash params set to 0x0000
Compressed 520192 bytes to 165297...
Wrote 520192 bytes (165297 compressed) at 0x00000000 in 29.0 seconds (effective 143.3 kbit/s)...
Hash of data verified.

Hard resetting...

This was, of course, with GPIO0 held LOW for programming mode (I actually use an adaptor with a programming switch that controls GPIO0), and for other operating systems you will need to change the port name to suit (COM3:, /dev/cu.usbmodem4873, etc).

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Nick Gammon
    May 12, 2017 at 21:55
  • Comments are ephemeral. Lengthy explanations should be merged into the answer (including graphics) rather than being in comments.
    – Nick Gammon
    May 12, 2017 at 21:56
//reset settings - in case of trouble just put in your code

That`s all you need

  • If you had formatted your code correctly, your answer may have made more sense. Jul 17, 2018 at 19:50
  • ESP.restart(); //done Jun 5, 2021 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.