My board won't run the code uploaded using PIO

So I tried using PIO for the first time, tried uploading my first code to my NodeMCU 0.9 ESP8266, but it just won’t run it. Arduino IDE works fine.

But the thing is, the uploading went fine!
Once I see this, I knew the uploading is successful.

Writing at 0x0002c000... (100 %)
Wrote 264560 bytes (195063 compressed) at 0x00000000 in 17.1 seconds (effective 123.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Also, the code is as simple as this!

#include <Arduino.h>

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    // Blink the built-in LED
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
} 

For the config(.ini) file, I leave it as stock.

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

Soooo, what did I do wrong?
Also, I’m very new to PIO and this forum, so feel free to ask for more info!

There is also board = nodemcuv2 available.

Did you try manually reset? Maybe just the reset mechanism doesn’t work and the ESP is still in download mode.

Tried that, doesn’t work.

Yep, tried resetting it too.

Please show a screenshot of your ArduinoIDE settings.

There are two main possibilities:

Easy: LED_BUILTIN has the wrong value. I think the Arduino IDE / ESP8266 core even has a menu to select what pin is “LED_BUILTIN”. There is no universally agreed on “LED_BUILTIN” pin for all ESP8266 board. You should try uploading

void setup() { Serial.begin(9600); }

void loop() { Serial.println("LED_BUILTIN is: " + String(LED_BUILTIN)); delay(1000); }

Upload that with the Arduino IDE. Then use that exact pin number instead of LED_BUILTIN.

Harder:

The ESP8266 won’t boot if you flash a firmware that assumes a wrong flash size. The bootloader will fail.

Tip:

  1. Add
monitor_speed = 74880

to the platformio.ini.
2. Use the project task “Monitor”
3. Press the reset button on your ESP8266 board
4. Post the output here

Still, the LED won’t turn on. Worked for Arduino IDE

 *  Executing task: platformio device monitor 

--- Terminal on /dev/ttyUSB0 | 74880 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00040970
~ld
rf cal sector: 1020
freq trace enable 0
rf[112] : 0

This?

So what number did it print in the Arduino IDE?

The bootloader messages look fine, they don’t indicate a failure.

It prints the number 2, so I used that, still won’t work.

Also, I unknowingly uploaded the code (you provided) earlier with the PIO, but I got no serial response. Could there be signs of problems with the IDE and not the board?

The serial monitor on PIO works fine when the code is uploaded using Arduino IDE.