Solved: Unwanted Output in Serial Monitor

Hi,

I am having unwanted output in serial monitor. My sample code should output "Hello" every 1 second in a new line.

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Hello");
  delay(100);
}

But serial monitor does not give an intended output. Even before the void loop runs, it seems as though garbage output comes out. I checked other posts and saw that baud rate must be same as the number in Serial.begin(). However, I have checked that both of them have the same number as 9600. I also found others do not have the same issue as mine. If there is any solution available to this, I will greatly appreciate the help!

try

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(100);
  Serial.println("Hello");
}

Hi,

I have tried it, but this is the output I see. As the image shows, there is "Hllo" on the top, which I believe I should not see. Do you think this could be an issue with my hardware?

Screen Shot 2021-01-29 at 5.10.27 AM.png

Screen Shot 2021-01-29 at 5.10.27 AM.png

Which Arduino do you have?

I used Arduino Uno.

What do you see when you press the Reset button?

If you meant "clear output" by saying "reset button", I see the intended outputs coming out normally. But, I want to do is to make sure there is no output before void loop() is run in arduino.

mj96:
If you meant "clear output" by saying "reset button", I see the intended outputs coming out normally. But, I want to do is to make sure there is no output before void loop() is run in arduino.

No, the red reset button on the Arduino UNO.

When I pressed the reset button, the Serial Output did not give the unwanted output and normally ran the code in an intended way.

I think it's related to this bug:

However, I would have expected the 100 ms delay to fix that.

mj96:
I am having unwanted output in serial monitor. My sample code should output "Hello" every 1 second in a new line.
...

  delay(100);

Note that delay(100) is 0.1 s.

It seems like there is no way I can resolve this issue right now. I am going to try older versions of Arduino software and buy a new board and see what the issue is. Thank you for all the help!

If it's really a problem for you, you should be able to avoid it by using Arduino IDE 1.8.12. You can download that here:
https://www.arduino.cc/en/Main/OldSoftwareReleases#previous

It did not work :frowning: . It's a dumb question, but if Arduino is partially fried, is this possible?

mj96:
It did not work :frowning: . It's a dumb question, but if Arduino is partially fried, is this possible?

Your Arduino is probably fine. Everything else is fine too. There is nothing intrinsically wrong with your code either. I submit that the only problem is that it is an essentially stupid and pointless exercise. If you added a zero to the delay it will probably be OK. This is the sort of problem that goes away once you start doing something useful. If the extra delay doesn't fix it, it is time for everyone to get worried.

The only way you will ever see output before the loop is when you put an output command in the setup - which you haven't.

If you press and hold the Arduino reset button and, while holding the button down, click the "Clear Output" button on the Serial Monitor, then release the reset button, what do you see?

What I am trying to do is to make a python user interface that allows logging some sensor data from arduino, but if the serial monitor is broken, the user interface will not work either.

When I hold the button down, click the clear output, and then release the reset button, serial monitor will give the desired output that I intended to output in my codes.

There is nothing to suggest that the above has anything to do with the original question. There is nothing to suggest that the serial monitor is broken either. One might say that you are trying to abuse it, but it will survive.
Maybe you are running two threads at once....

I think you should have some kind of session protocol anyway, when two machines are communicating. The Python side should be looking for some kind of valid message from the Arduino before initiating a session. Probably the reverse too. Then the startup garbage won't matter.

@OP,
In the setup() function, can you add:

While (!Serial) {
;
}

After the Serial.begin(...) you wrote

This will wait for the serial port to connect.

Thanks

Hello,

I am sorry if this post was bad since I am a beginner in python and arduino. What I decided to do was to have python codes that order not to read the values if invalid. I realized that it's important to try fixing problems myself before attributing the issues to the hardware.

Thank you so much for all the help that has helped me solve this problem and grow more.