D0 and LED_BUILTIN are defined in the core support files for some (but not all) ESP8266 boards.
So make sure you have the correct board selected in the IDE's Tools menu.
If you still get the errors, then you need to work out yourself which GPIO number your LED is connected to, and put that number in the #define statement.
But if I try to load it I get:
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
If I try to load it while pressing the IO0. (Flash) button (Onboard LEDs? NodeMCU's got two! – Low voltage. Mostly harmless...) I get:
esptool.py v2.6
Serial port COM6
Connecting....
Chip is ESP32D0WDQ5 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: c8:2b:96:a1:3b:a0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 4369.0 kbit/s)...
Hash of data verified.
Compressed 15856 bytes to 10276...
Wrote 15856 bytes (10276 compressed) at 0x00001000 in 0.1 seconds (effective 968.3 kbit/s)...
Hash of data verified.
Compressed 207824 bytes to 105394...
Wrote 207824 bytes (105394 compressed) at 0x00010000 in 1.5 seconds (effective 1105.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1536.0 kbit/s)...
Hash of data verified.
well, sorry I'm working first time with microControlers.
I'am using a NodeMCU-32S-ESP32. My script above (Jul 06, 2020, 07:48 pm) did compile
but wouldn't load, producing the above posted error message.
But today, when I plugged in the microCotroler it executed the sketch blinking the inbuilt LED
respectively right away.
Upon opening the Arduino IDE I got a long message consisting mainly of file paths but with
one error message on last line:
<error downloading http://arduino.esp8266.com/stable/package_esp8266com_index.jso>
which most likely points to the problem: Download of wrong software, following a
tutorial which was based probably on a different microControler.
At present I just don't know from whre to get the appropriate s/w.
Can somebody tell me ?
thanks for your patience.
But I still don't get it:
My microController setup is now certainly correct.
If I try to compile the sketch posted on Jul 06, 2020, 09:30 am I still get an
error saying D0 is not in the scope.....
If I plug in my NodeMCU-32S-ESP32 the sketch posted on Jul 06, 2020, 07:48 pm
runs. If I change the delay times inmy sketch and upload it a change of the
blinking sequence occurs, but not as programmed until an error messenge
appears:
after which the blinking mode falls back to it's original sketch.
luemar:
If I try to compile the sketch posted on Jul 06, 2020, 09:30 am I still get an
error saying D0 is not in the scope.....
D0 is not a valid pin number on the ESP32 NodeMCU board you're using. I think we established you need to use pin 2 instead.
If I plug in my NodeMCU-32S-ESP32 the sketch posted on Jul 06, 2020, 07:48 pm
runs. If I change the delay times inmy sketch and upload it a change of the
blinking sequence occurs, but not as programmed until an error messenge
appears:
after which the blinking mode falls back to it's original sketch.
which intially executes, but no print statement appears on the serial monitor,
while in the appearing message (see below) the line <Connecting........______..... .....> runs.
Once tha last line appears < A fatal error ocurred....> the blinking mode changes to a regular
blinking according to the sketch I loaded the first time on the ESP32: