2

I have two esp-01 micro controllers that I'm trying to flash using the Arduino IDE but found some problems in the process. I followed step 1 of this tutorial to install all the dependencies to the IDE.

As for the code, it's one of the examples:

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain

 The blue LED on the ESP-01 module is connected to GPIO1 
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)

 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

I'm flashing it using the serial port communication, and the circuit is the following:

Circuit for flashing the ESP-01

Having an MB102 as the power supply and a FT232RL as FTDI. Obviously everything at 3.3V.

I can flash the device properly when using the Arduino IDE. This is the output:

C:\PATH\Arduino15\packages\esp8266\tools\esptool\0.4.9/esptool.exe -vv -cd ck -cb 115200 -cp COM3 -ca 0x00000 -cf 
C:\SOMEPATH\Temp\arduino_build_913175/Blink.ino.bin 
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to ck
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM3
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x00, expected 0x01 0x08
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
Uploading 226352 bytes from 
C:\SOMEPATH\Temp\arduino_build_913175/Blink.ino.bin to flash at 0x00000000
erasing flash
    size: 037430 address: 000000
    first_sector_index: 0
    total_sector_count: 56
    head_sector_count: 16
    adjusted_sector_count: 40
    erase_size: 028000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting serial port timeouts to 15000 ms
    setting serial port timeouts to 1000 ms
    espcomm_send_command: receiving 2 bytes of data
    writing flash
................................................................................ [ 36% ]
................................................................................ [ 72% ]
..............................................................                   [ 100% ]
starting app without reboot
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
closing bootloader
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete

So everything looks fine, but after rebooting the device (by turning on and off the power supply) and removing the GPIO0 connection to the ground to avoid the flash mode, nothing happens. Looks like the program is not executing successfuly and the LED doesn't blink or anything.

Does anyone know if I'm doing something wrong? Should I connect GPIO0 to the power supply to get a high voltage after flashing the device, to make sure the GPIO0 doesn't stay at low at boot time and it enters flash mode?

Note that I tried with both ESP-01 to make sure it wasn't a deffective one, and also note that the LED of the mcu is ON, so it is obviously powered on.

migrated from electronics.stackexchange.com Dec 14 '17 at 22:32

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • 3
    Try explicitly setting the pin for GPIO1 instead of using LED_BUILTIN, i.e.: pinMode(1, OUTPUT); and then digitalWrite(1, LOW); and digitalWrite(1, HIGH);. It could be that the header you use for the ESP8266 has a different pin set for the built-in LED. – Ron Beyer Dec 14 '17 at 15:23
  • I'll try, but still I belive it's something related to how I flash it or how it runs the firmware since even uploading a program with basic serial communication (a print saying "HELLO") won't work. – lpares12 Dec 14 '17 at 16:18
  • @lpares12 I found on my devices that the usual definitions for the pins simply weren't right (the usual Arduino assignments were ignored in the design.) I also found that the LEDs weren't even close to the same number, either. I don't recall, but it was like I had to hard-code a 6 to get to the LED that would otherwise have been 1. Like that. Later... much later... I found some docs that helped. I still have no idea why the designers went the way they did. But everything worked once I pinned down the numbers. – jonk Dec 14 '17 at 17:12
  • @jonk but still it doesn't explain why other example codes which do not use the LED don't work. For example, only using the serial communication to print "hello" every second doesn't work either, just outputs random symbols in the serial console (even changing the baud rate in both the code and the serial connection, being always the same of course) – lpares12 Dec 14 '17 at 17:18
  • @lpares12 I only used the LED and also the WiFi library with the device. So I can't really add anything to your troubles about the serial console part. I wish I could. If I had to guess (and I do), I'd imagine that it was (1) incorrect library code being used, despite the docs you found; or (2) my own misuse of them, somehow. I tend to assume that the hardware works okay (never been wrong about that assumption.) So it is always "my problem" in having the right device info or the right library code or the right compiler setup. I wish I knew more about that particular issue. But I don't. – jonk Dec 14 '17 at 17:23

Your Answer

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