ESP8266-01 Will not run

Hey folks,

Very new to pio, just managed to install it today and have a successful build.

As I said, I managed to compile and upload my project on my ESP8266-01 module, all worked ok after a few retries and unplug/plug of the USD serials.

However, the 01 would not execute on the uploaded code.

I created a new project using the Blink example to eliminate any factors from my project and I got the same behaviour. I enriched the blink example with a few Serial.println() statements, however I could not see them on the monitor, neither the ESP would blink any LEDs.

I then used the Arduino IDE as a control, applied the same tweaks with a couple Serial.println() statements and it worked. I was able to view the serial commands on the serial monitor, both on the Arduino IDE as well on VSC’s PIO monitor.

Sooo, what am I doing wrong?

As I said, I am using the “blink” example, and from that, this platformio.ini config in particular:

[env:esp01]
platform = espressif8266
framework = arduino
board = esp01

On my project I’ve been using these settings:

[env:esp01_1m]
platform = espressif8266
board = esp01_1m
framework = arduino
lib_deps = adafruit/Adafruit NeoPixel@^1.10.6
lib_extra_dirs = /Users/thanpolas/Projects/Maker/polas-libs
monitor_speed = 9600

Here is the build output of the blynk project:

$ platformio run --target upload --target monitor --environment esp01 --verbose
Processing esp01 (platform: espressif8266; framework: arduino; board: esp01)
----------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp01.html
PLATFORM: Espressif 8266 (4.0.1) > Espressif Generic ESP8266 ESP-01 512k
HARDWARE: ESP8266 80MHz, 80KB RAM, 512KB Flash
PACKAGES: 
 - framework-arduinoespressif8266 @ 3.30002.0 (3.0.2) 
 - tool-esptool @ 1.413.0 (4.13) 
 - tool-esptoolpy @ 1.30000.201119 (3.0.0) 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 1.200.0 (2.0) 
 - toolchain-xtensa @ 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 35 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
<lambda>(["checkprogsize"], [".pio/build/esp01/firmware.elf"])
MethodWrapper(["checkprogsize"], [".pio/build/esp01/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  34.3% (used 28084 bytes from 81920 bytes)
Flash: [======    ]  61.2% (used 265765 bytes from 434160 bytes)
.pio/build/esp01/firmware.elf  :
section                                                                                                                                                                              size         addr
.data                                                                                                                                                                                1496   1073643520
.noinit                                                                                                                                                                                56   1073645016
.text                                                                                                                                                                                 240   1074790400
.irom0.text                                                                                                                                                                        236084   1075843088
.text1                                                                                                                                                                              27037   1074790640
.rodata                                                                                                                                                                               908   1073645072
.bss                                                                                                                                                                                25680   1073645984
.comment                                                                                                                                                                             5066            0
.xtensa.info                                                                                                                                                                           56            0
.xt.lit._ZN14HardwareSerial4readEPhj                                                                                                                                                    0            0
.xt.lit._ZN14HardwareSerialD0Ev                                                                                                                                                         0            0
.xt.lit._ZN14HardwareSerial11peekConsumeEj                                                                                                                                              0            0
.xt.lit._ZN14HardwareSerial10peekBufferEv                                                                                                                                               0            0
.xt.lit._ZN14HardwareSerial13peekAvailableEv                                                                                                                                            0            0
.xt.lit._ZN14HardwareSerial4peekEv                                                                                                                                                      0            0
.xt.lit._ZN14HardwareSerial4readEv                                                                                                                                                      0            0
.xt.lit._ZN14HardwareSerial17availableForWriteEv                                                                                                                                        0            0
.xt.lit._ZN14HardwareSerial5writeEPKhj                                                                                                                                                  0            0
.xt.lit._ZN14HardwareSerial5writeEh                                                                                                                                                     0            0
.xt.prop._ZN5Print16outputCanTimeoutEv                                                                                                                                                 36            0
.xt.prop._ZN6Stream15inputCanTimeoutEv                                                                                                                                                 36            0
.xt.prop._ZN6Stream15streamRemainingEv                                                                                                                                                 36            0
.xt.prop._ZN14HardwareSerialD2Ev                                                                                                                                                       36            0
.xt.prop._ZNK14HardwareSerial16hasPeekBufferAPIEv                                                                                                                                      36            0
.xt.prop._ZN14HardwareSerial9readBytesEPhj                                                                                                                                             36            0
.xt.prop._ZN14HardwareSerial4readEPhj                                                                                                                                                  48            0
.xt.prop._ZN14HardwareSerialD0Ev                                                                                                                                                       48            0
.xt.prop._ZN14HardwareSerial11peekConsumeEj                                                                                                                                            48            0
.xt.prop._ZN14HardwareSerial10peekBufferEv                                                                                                                                             48            0
.xt.prop._ZN14HardwareSerial13peekAvailableEv                                                                                                                                          48            0
.xt.prop._ZN14HardwareSerial4peekEv                                                                                                                                                    48            0
.xt.prop._ZN14HardwareSerial4readEv                                                                                                                                                    48            0
.xt.prop._ZN14HardwareSerial17availableForWriteEv                                                                                                                                      48            0
.xt.prop._ZN14HardwareSerial5writeEPKhj                                                                                                                                                48            0
.xt.prop._ZN14HardwareSerial5writeEh                                                                                                                                                   48            0
.xt.prop._ZNK7esp826613polledTimeout15timeoutTemplateILb0ENS0_11YieldPolicy9DoNothingENS0_10TimePolicy8TimeUnitINS4_16TimeSourceCyclesELy1000EEEE14expiredOneShotEv                    48            0
.xt.prop._ZTV14HardwareSerial                                                                                                                                                          12            0
.xt.lit._ZN5Print5writeEPKc                                                                                                                                                             0            0
.xt.prop._ZN5Print5writeEPKc                                                                                                                                                           60            0
.xt.prop._ZNK6String3lenEv                                                                                                                                                             60            0
.xt.prop._ZN6String6setLenEi                                                                                                                                                           60            0
.xt.lit.9                                                                                                                                                                               8            0
.xt.lit.uart_rx_available_unsafe                                                                                                                                                        8            0
.xt.lit.10                                                                                                                                                                              0            0
.xt.lit.uart_tx_fifo_available                                                                                                                                                          0            0
.xt.prop.9                                                                                                                                                                             48            0
.xt.prop.uart_rx_buffer_available_unsafe                                                                                                                                               48            0
.xt.prop.uart_rx_available_unsafe                                                                                                                                                      48            0
.xt.prop.10                                                                                                                                                                           120            0
.xt.prop.uart_tx_fifo_available                                                                                                                                                        48            0
.xt.prop._ZNSt14_Function_baseD2Ev                                                                                                                                                     48            0
.xt.prop._ZSt4swapISt9_Any_dataENSt9enable_ifIXsrSt6__and_IJSt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS5_ESt18is_move_assignableIS5_EEE5valueEvE4typeERS5_SF_        36            0
.xt.lit._ZNKSt8functionIFbvEEclEv                                                                                                                                                       8            0
.xt.lit._ZN7esp826613polledTimeout15timeoutTemplateILb1ENS0_11YieldPolicy9DoNothingENS0_10TimePolicy8TimeUnitINS4_16TimeSourceCyclesELy1000EEEE16expiredRetriggerEv                     0            0
.xt.prop._ZNKSt8functionIFbvEEclEv                                                                                                                                                     60            0
.xt.prop._ZN7esp826613polledTimeout15timeoutTemplateILb1ENS0_11YieldPolicy9DoNothingENS0_10TimePolicy8TimeUnitINS4_16TimeSourceCyclesELy1000EEEE16expiredRetriggerEv                   84            0
.irom.exceptiontext                                                                                                                                                                    18            0
.debug_frame                                                                                                                                                                        19444            0
.debug_info                                                                                                                                                                        262368            0
.debug_abbrev                                                                                                                                                                       48243            0
.debug_loc                                                                                                                                                                         142892            0
.debug_aranges                                                                                                                                                                       5496            0
.debug_ranges                                                                                                                                                                        8952            0
.debug_line                                                                                                                                                                        258110            0
.debug_str                                                                                                                                                                          34085            0
Total                                                                                                                                                                             1077731
<lambda>(["upload"], [".pio/build/esp01/firmware.bin"])
AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
MethodWrapper(["upload"], [".pio/build/esp01/firmware.bin"])
Auto-detected: /dev/cu.usbserial-0001
"/Users/thanpolas/.platformio/penv/bin/python" "/Users/thanpolas/.platformio/packages/tool-esptoolpy/esptool.py" --before no_reset --after soft_reset --chip esp8266 --port "/dev/cu.usbserial-0001" --baud 115200 write_flash 0x0 .pio/build/esp01/firmware.bin
esptool.py v3.0
Serial port /dev/cu.usbserial-0001
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: e8:db:84:db:22:d3
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 269920 bytes to 198144...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 269920 bytes (198144 compressed) at 0x00000000 in 17.5 seconds (effective 123.4 kbit/s)...
Hash of data verified.

Leaving...
Soft resetting...

Please advise.

After more extensive googling, I found the answer to part of my problem via this post: ESP01 code upload works with Arduino IDE but not with PIO? - #5 by romney.duy

tl;dr: I needed to add board_build.flash_mode = dout on my ini file, which now looks like this:

[env:esp01]
platform = espressif8266
framework = arduino
board = esp01
; change microcontroller
board_build.mcu = esp8266
; change MCU frequency
board_build.f_cpu = 26000000L
board_build.flash_mode = dout
monitor_speed = 9600

I can now see the built-in blue LED of my ESP8266-01 blink, so the program executes.

However, serial monitor will give me a weird “nul” character instead of the expected output:

Does this happen with the simplest possible sketch too?

#include <Arduino.h>
void setup() { Serial.begin(9600); }
void loop() { Serial.println("Test"); delay(1000); }

?

If yes, have you tried setting dtr/rts to 0/1 like Noob stuck on ESP32-CAM+MB with PIO/vscode - #5 by maxgerhardt shows?

2 Likes

My blink project was very close to that…

however, it appeared to be a transient issue that I now cannot replicate.

Should i come up with it again, I’ll come back and report.