Need help with ESP8266 ESP-01

I'm trying to upload a sketch to an ESP8266, but it won't work and I can't figure out why. (the esp8266 blink example)

I've got the ESP8266 hooked up to an FTDI232 which in turn is connected to my PC via usb. Like this:

In the Arduino IDE I've got Board set to Generic ESP8266 Module
Flash Mode: DIO (no idea what this means)
Flash Frequency: 40Mhz
Upload using: Serial
CPU Frequency: 80Mhz
Flash size: 512K (64K SPIFFS)
Upload Speed: 115200
Port: COM9 (the correct one)

If I just open the serial monitor, I can talk to the ESP8266 via AT commands and that works beautifully.

AT+GMR gives me this:
AT version:0.25.0.0(Jun 5 2015 16:27:16)
SDK version:1.1.1
Ai-Thinker Technology Co. Ltd.
Jun 5 2015 23:07:20

But if I try to upload the sketch I just get:

error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data

a bunch of times, then

warning: espcomm_sync failed
error: espcomm_open failed

What am I doing wrong? When do I really have to press the Reset and GPIO0 buttons I put in the breadboard? I'm confused. Any help is very much appreciated!

Hi!

To upload code to ESP8266 you need to pull GPIO 0 LOW and reset the board.
After the reset you can upload your code.

/Olof

ok. does GPIO 0 need to be low while I reset the board and while I upload my code? And do I need to have any special firmware installed to make this work? Do I need to get a new sdk from espressif or something?

You do not need any special firmware (or SDK).
GPIO 0 need to be low while you reset. It sets the MCU in "flash mode", you can now upload your program.
After the reset you don't need to pull GPIO 0 low anymore (it doesn't matter).

Pulling GPIO 0 high while resetting sets the MCU in normal mode (it will execute any uploaded program).

I have written up a short summary of the steps:
ESP8266 with the Arduino IDE

Ray

You need a proper 3.3v power source for the ESP that can supply ~250mA (100mA at a bare minimum even to boot the thing without using the radio)

The supply off of the FTDI or an Arduino won't do.

I recommend using nodemcu firmware. It is a lua interpeter and brings some interesting functions.

Thank you very much for your help, everyone!

Now I added a breadboard power supply to power the ESP8266 ESP-01 (I power it with a AC/DC adapter that can output 12v 4A) and connected GNDs together.

I hold down the button that connects GPIO to GND, then press the reset button and let go of both before I upload the sketch, but every time I get this: (sometimes the amount of ..... varies)

Uploading 205232 bytes from C:\Users\BLACKISH\AppData\Local\Temp\build961561883866399945.tmp/Blink.cpp.bin to flash at 0x00000000
...warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04

What am I doing wrong? Could it be that I hooked something up the wrong way?

Hmmm it should work, maybe a faulty wire or button?
Skip the buttons and use wires and resistors for pullup/pulldown (see Mrburnette guide).

/Olof

col000r:
press the reset button and let go of both
...
What am I doing wrong?

it is critical that gpio0 stay low for some time after reset high. releasing both at exactly the same time will guarantee failure. also generally a mistake to force hard low on any of these gpio pins because most become outputs under some conditions. best use 1k or so permanent pull down there.

Press and hold reset (low), wait a moment. Press and hold gpio0 (low), wait a moment.
Release reset(high), wait a moment
Release gpio0. The onboard LED should be brightly lit. If you still have trouble uploading after reset, you might try switching rx and TX lines: tx-tx and rx-rx.

ahhhh... one of the nice things about these forums is when helpers come along to elaborate on your suggestions. :slight_smile: however many think its a bad idea for pins that may be outputs to be shorted high or low w/o limiting.

red power led should always be solid but the blue serial led blinks twice briefly to indicate ready for serial download. if you dont see this probably no point in continuing. blinks once with factory firmware showing AT command mode. fully lit after reset happens when boot pins are incorrect resulting in sd boot, aka "zombie mode". for me the leds are a very important diagnostic tool.

john1993:
ahhhh... one of the nice things about these forums is when helpers come along to elaborate on your suggestions. :slight_smile: however many think its a bad idea for pins that may be outputs to be shorted high or low w/o limiting.
<...>

What is different here is that after reset, the bootloader initializes and the code ensures all ports are are in input mode. While in the bootloader, grounding any input pin that is interpreted by the bootloader is therefore not an issue.

The problem is having pins declared as output by the user code grounded... so, many professionals rely on resistors in series with the I/O pin to prevent a sink/source condition which would overload the CMOS drivers. Such things are critical for prototyping boards but are simply not utilized in production (rarely utilized) because the resistors take up space and add to the overall BOM costs.

Ray

iirc from threads on espressif forum both pd, io0, and others are briefly output after reset as part of "pre-boot" procedure. some involvement with coming out of sleep too which may explain some zombie troubles. i think reset pin itself also under some conditions. timing such that few problems normally occur and difficult to demonstrate but consensus was for max reliability and robustness do not directly short ANY pins. funny because that was (maybe still is) exactly whats recommended in many how-tos.

in the case of op a pulldown would eliminate the need for extra button and three hands. another reason it allows using the pin double duty as input or output for the application.