arduino / arduino/ArduinoCore-renesas

[Uno R4 WiFi] `while (!Serial);` not working on Uno R4 WiFi

Open
#487 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

## Summary:

On Arduino Uno R4 WiFi, `while (!Serial);` does not block the program until the Serial Monitor is connected. This may result in serial data output produced at the start of the sketch program execution (e.g., in the `setup` function) not being displayed in Serial Monitor.

This behavior differs from most other Arduino boards (including Uno R3 and Uno R4 Minima), breaking a large amount of existing example code and tutorials.

## Steps to Reproduce:

1. Upload this sketch to an Arduino Uno R4 WiFi:

```cpp
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Hello World");
}
void loop() {}
```

2. Open Serial Monitor immediately after upload finishes.

3. Observe that no output appears unless the reset button is pressed.

## Expected Behavior:

`while (!Serial);` should block the program until the USB–Serial connection is established, ensuring prints in setup() are visible right after upload, without requiring a manual reset.

## Actual Behavior:

`while (!Serial);` returns immediately. Output sent before Serial Monitor connection is lost and manual reset is required to see the message.

## Impact:

Breaks compatibility with most Arduino examples and learning materials.

Confuses new users, who expect immediate output after upload.

Makes debugging output in setup() unreliable without additional delay hacks.

### Additional context

#### Additional reports

- https://forum.arduino.cc/t/while-serial-not-sufficient-on-upload-or-usb-plugin/1168429

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided Uno R4 WiFi sketch and tracing the implementation of Serial.begin() and the Serial connection check behind while (!Serial). Compare the Uno R4 WiFi behavior with the stated Uno R3 and Uno R4 Minima behavior; done means the sketch waits for the USB–Serial connection and prints Hello World without a manual reset.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.