Is there a way for the ESP32 (S3) to wait until a serial port/monitor has been started? I’m using the Arduino IDE. On non-ESP32 boards, I’ve used something like this:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("*****************************************************");
Serial.println(" Com port is open");
This code doesn’t work with the ESP32. Any other suggestions? I need to print out a message to the serial port, but need to wait until the serial port and terminal/console are open/ready. Since the code currently isn’t able to wait, I lose the first few serial port prints as it takes a few seconds to manually open up the serial monitor program.
waiting for serial port to open; Arduino IDE
Re: waiting for serial port to open; Arduino IDE
Why not just have it wait until it receives serial input?
Re: waiting for serial port to open; Arduino IDE
I need to output to the serial monitor first before receiving input. I have a while(serial.available) in the code which works fine, but the Serial.println prior to that is dropped, because the connection isn't open at that point.
Re: waiting for serial port to open; Arduino IDE
I don't know of any way to do this on ESP32.
Why do you need to output data to the serial line before it receives input? Just curious. And why not just have the serial line connected when it boots, so you can see all output?
At any rate, what you seek might be possible on the new chips with built-in USB UART, but I haven't tested this.
Why do you need to output data to the serial line before it receives input? Just curious. And why not just have the serial line connected when it boots, so you can see all output?
At any rate, what you seek might be possible on the new chips with built-in USB UART, but I haven't tested this.
Re: waiting for serial port to open; Arduino IDE
My resolution was to wait for 5 seconds as I couldn't find another way
void setup() {
Serial.begin(115200);
delay(5000);
Serial.println("Ready.");
...
}
void setup() {
Serial.begin(115200);
delay(5000);
Serial.println("Ready.");
...
}
Who is online
Users browsing this forum: Majestic-12 [Bot] and 75 guests