Skip to main content
5 of 5
Added language specifier for syntax highlighting

Why does starting the serial monitor restart the sketch?

If I upload any sketch that sends serial data, I immediately see the TX/RX LEDs flash once the sketch is uploaded. If I then start the serial monitor, the sketch appears to restart.

A bare minimum sketch that shows this behaviour:

    void setup()
    {
        Serial.begin(9600);
        Serial.println("Setup");
    }
    
    void loop()
    {
      Serial.println("Loop");
      delay(1000);
    }

Tested with several boards and Mac and Windows versions of the IDE.

Example output - it goes back to "Setup" when I open the serial monitor:

Restart

Why is this?

Cybergibbons
  • 5.4k
  • 7
  • 33
  • 51