I need to see some feedback in my setup() code within Arduino framework, and am using a simple Serial.println(), but it never appears unless I add a delay. Sometimes even the Serial.println() in loop() misses the first few loops.
#include <Arduino.h>
int loopCount = 0;
void setup() {
Serial.begin(460800);
// delay(3500);
while(!Serial) {}
Serial.println("setup");
}
void loop() {
Serial.println(String(++loopCount) + " " + String(millis()));
delay(1000);
}
If I run this on a plain ESP32 (eg esp32doit-devkit-v1), and comment out the fixed delay and the while loop, I get
setup
1 28
2 1029
3 2028
which is what I need and expect – serial printing starts straight away.
On the ESP32-S3 (eg esp32-s3-devkitc-1) without delay or while, I get
4 3098
5 4098
6 5098
so the setup printing is missed, as well as the first 3 times through the loop.
If I use the while(!Serial) {} line, I get
5 4098
6 5098
7 6098
8 7098
which is even worse, so I mainly use the fixed delay(3500).
But I really need immediate feedback within the code I am debugging, just like the plain ESP32.
I am using a Mac and PlatformIO to define the boards
[platformio]
default_envs = esp32
src_dir = src
include_dir = include
[env:esp32]
platform = espressif32
; board = esp32doit-devkit-v1
board = esp32-s3-devkitc-1
framework = arduino
upload_port = /dev/cu.usb*
; Serial Monitor options
monitor_speed = 460800
monitor_filters = colorize
monitor_echo = yes
What can I do?
3