Skip to content

Instantly share code, notes, and snippets.

@XaviTorello
Forked from spacehuhn/arduino_flash_esp8266.md
Created December 30, 2017 19:34
Show Gist options
  • Save XaviTorello/7b6df19dce01abb2f662504c640a7d38 to your computer and use it in GitHub Desktop.
Save XaviTorello/7b6df19dce01abb2f662504c640a7d38 to your computer and use it in GitHub Desktop.
Flash ESP8266 over an Arduino

How to flash your ESP8266 without a USB-Serial adapter but with an Arduino.

First be sure everything is connected correcly:

Arduino ESP82666
TX RX
RX TX
GND GND
GND GPIO-15
VCC (3.3V) VCC (3.3V)
12 GPIO 0
13 CH_PD (EN)

The last 2 pins can be changed in the code.

Or set them manually:

PIN Mode
CH_PD (EN) HIGH (3.3V)
GPIO-0 LOW (GND)

Then upload this to your Arduino:

int program_pin = 12;
int enable_pin = 13;

void setup()
{
  Serial1.begin(115200);
  Serial.begin(115200);
  pinMode(enable_pin, OUTPUT);
  pinMode(program_pin, OUTPUT);
  digitalWrite(program_pin, LOW);
  digitalWrite(enable_pin,HIGH);
}

void loop()
{
  while(Serial1.available()){
    Serial.write((uint8_t)Serial1.read());
  }

  if(Serial.available()){
    while(Serial.available()){
      Serial1.write((uint8_t)Serial.read());
    }
  }
}

This code will let the Arduino send every byte it gets from the PC over Serial to the ESP8266 and back.

So now you can flash your ESP with the esptool or the nodemcu-flasher over the COM-port of the Arduino.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment