Incorrect baudrate in Arduino IDE expected behaviour

Hi All,

I have an Arduino UNO running the following example sketch to test serial communications. I notice when testing that regardless of the baud rate I set within the Arduino IDE the serial monitor will display the message correctly.

void setup() {
  Serial.begin(921600); // open the serial port at 9600 bps:
}

void loop() {

  Serial.println("Hello World");        // carriage return after the last label
  delay(1000);
}

I would have expected the characters to be scrambled if the board rate of the serial monitor did not match that within the sketch. Would someone help me understand why this is not the case?

From the Serial reference page:

Notes and Warnings

For USB CDC serial ports (e.g. Serial on the Leonardo), Serial.begin() is irrelevant. You can use any baud rate and configuration for serial communication with these ports.

The R4 Minima is a USB CDC serial port. As such, the baud rate is irrelevant. You can verify this by looking in cores/arduino/usb/SerialUSB.cpp for yourself and seeing:

void _SerialUSB::begin(unsigned long baud) {
    (void) baud; //ignored

    if (_running) {
        return;
    }

    _running = true;
}

Thanks @van_der_decken! this make perfect sense now :slight_smile:

You might have one; but you're not compiling for it and probably it's not the board that you have connected :smiley:

In short, please be extremely accurate in the description of the board that you're using.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.