Description
Describe the bug
🐛 Spurious data is sent by the Serial Monitor over the connected serial port.
To Reproduce
Equipment
- One of the following Arduino boards:
- Arduino Uno
- Arduino Mega
- Arduino Due
Steps
- Paste the following simple serial echo sketch into the Arduino IDE:
void setup() { Serial.begin(115200); } void loop() { if(Serial.available()){ Serial.println(Serial.read()); } }
- Upload to the Arduino board.
- Open Serial Monitor
- Set the baud rate menu to 115200.
🐛 The Serial Monitor's output field shows unexpected data is being received by the Arduino board and echoed back by the sketch. Something like this:
240
240
240
240
240
240
... and so on
Expected behavior
Data is only sent over the serial port by Serial Monitor when the user sends it via the input field.
Desktop
- OS: Windows 10
- Version: Version: 2.0.0-beta.6-nightly.20210515
Date: 2021-05-15T03:10:15.375Z
CLI Version: 0.18.2 alpha [7b5a22a4]
Additional context
I have only been able to reproduce this on my Arduino Mega, Arduino Uno, and Arduino Due (via Programming Port only). Based on the commonality of their ATmega16U2 USB chip, I expected to also be able to reproduce it on my Arduino Uno Mini LE, but I was not able to.
On my Leonardo and Micro boards, the RX LED flashes at 1 Hz while the Serial Monitor is connected, indicating unexpected data is being received, but I don't get any output from the echo sketch.
I notice that the ~1 Hz frequency of the spurious data appears to match the frequency of the notification displayed repeatedly after the board is disconnected while Serial Monitor is open (#314):
Reconnecting Arduino Mega or Mega 2560 to COM18 in 1 seconds...
This makes me wonder if already open ports are constantly being reopened at 1 Hz the whole time Serial Monitor is running. Further evidence supporting this is that I get the RX blink on the Leonardo whenever I do a manual StreamingOpen
gRPC request to the port.
It appears the data is sent at 115200 baud.
As reported at at #1297, changing the selection in the line ending menu triggers the immediate sending of additional spurious data in addition to the regular periodic data reported above.
I notice the same happens when you toggle the "Toggle Autoscroll" or "Toggle Timestamp" icons.
None of these should result in any data being sent to the board.
Originally reported at: https://forum.arduino.cc/t/serial-monitor-sends-random-f0/850819