I have this distilled to a simple program that echoes Serial port data back to the Serial Monitor (but as hex instead of ascii). It works just fine on the Uno:
unsigned char InpBuff[64];
void setup() {
Serial.begin(9600);
}
void loop(){
if(Serial.available()>0) {
InpBuff[0]=Serial.read();
Serial.print(InpBuff[0], HEX);
}
}
On the Due I get this:
But, strangely enough, each character comes about 1 second apart (not measured exactly). If you type some text and press ctrl-enter, that echoes just fine.
I no longer have IDE 1 to compare this to, but I am hypothesizing that IDE 2.0 is improperly "pinging" the Serial Port on the Due in a manner that causes this to happen, because this works perfectly on the Uno.
EDIT: I forgot to mention that it is the Programming port on the Due that I am using.
Thanks @weshowe . This bug is tracked by the IDE developers here:
opened 04:26AM - 16 May 21 UTC
closed 10:13AM - 01 Dec 22 UTC
conclusion: resolved
topic: code
type: imperfection
topic: serial monitor
## Describe the bug
🐛 Spurious data is sent by the Serial Monitor over the co… nnected serial port.
## To Reproduce
### Equipment
- One of the following Arduino boards:
- Arduino Uno
- Arduino Mega
- Arduino Due
### Steps
1. Paste the following simple serial echo sketch into the Arduino IDE:
```cpp
void setup() {
Serial.begin(115200);
}
void loop() {
if(Serial.available()){
Serial.println(Serial.read());
}
}
```
1. Upload to the Arduino board.
1. Open Serial Monitor
1. 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:
```text
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 (https://github.com/arduino/arduino-ide/issues/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](https://arduino.github.io/arduino-cli/latest/rpc/monitor/#cc.arduino.cli.monitor.v1.StreamingOpenRequest) to the port.
---
It appears the data is sent at 115200 baud.
---
As reported at at https://github.com/arduino/arduino-ide/issues/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
Thanks. I've only seen it on the Due, not the mega or others. I use a crude parser in my development code to tune values, but I "patched" around this by filtering out chars with 0x80 bit set.
Still, it's ugly.
system
Closed
November 9, 2022, 12:13pm
4
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.