Serial monitor only works after upload

I'm not sure if this is board specific but I am using IDE 2.3.3 on Linux using DFU to connect to a nano esp32. I have a very simple sketch which if I upload successfully runs and on opening the serial monitor I can see 'hello' appear. However, when I press reset or disconnect and reconnect the power nothing appears at all on the serial monitor but the LEDs are flashing to indicate the sketch is running.

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
  Serial.println("hello");
}

Please can someone help me work out why the serial monitor does not work after arduino power cycle ? I'm guessing it is something to do with this being USB-C

I had to add this to udev rules to get upload to work:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", MODE:="0666"

Maybe you need to add a while (! Serial); after initialising the Serial communication, also a small delay to give some time to the IDE at the end of the void setup will help

thank you @mario-r - adding the wait for serial and the delay works. For reference in case someone else finds this I also had to change my udev rule as per Upload on Linux fails: "No DFU capable USB device available"

2 Likes