if I try to put an Serial-Output inside the setup, it's not working.
#include <WiFi.h>
void setup() {
Serial.begin(115200); // Set up Serial Monitor
WiFi.mode(WIFI_STA); // Set ESP32 as a Wi-Fi Station
Serial.print("MAC-Address: ");
Serial.println(WiFi.macAddress()); // Show MAC-Address
}
void loop() {/*...*/}
Or, rather than an arbitrary delay, wait until it is ready:
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
}
That board has native USB as far as I know; so try the suggestion in post #3.
There are ways around that. One also has to be careful when it's first connected to external power and USB and later USB is disconnected; on at least the 32U4 based boards, that can bring your board to a near grinding halt if one keeps on printing to Serial. OP needs to test that if it's a requirement.
I know, but don't let's make things any more complicated than it needs to be. Adding a delay() after the begin() is a quick and dirty way of identifying the problem before deciding the the most appropriate solution based on requirements