I know this has come up before but this is different and all the threads are locked.
Here is my code,
//uint32_t var;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(500);
Serial.println ();
//var++;
Serial.print("Hello World! ,");
Serial.println(millis());
}
void loop() {
// put your main code here, to run repeatedly:
}
It runs on an Arduino Nano. Nothing connected, just the Nano.
I put the Serial.print in to try and figure out what is happening.
I clicked on the code tag but not sure if it worked.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial) {}
Serial.println ();
//var++;
Serial.print("Hello World! ,");
Serial.println(millis());
}
Serial takes time to initialize. Adding while (!Serial) {} stops the code until Serial is initialized.
This used to happen to me in IDE 1.x. Sugestion was a 10uf capacitor on reset pin/gnd. I did not use the suggestion because the IDE release solved my issue.
It worked. But you also placed your text inside the code tags
You're probably using the forum editor in "rich text editor" mode and you'll have to get out of the code "window" by using the arrow-down.
Alternatively, select the markdown mode by toggling the M+|A in the left top. The editor will then look like below; you type in the left and the right shows what it will look like.
In '21, it was explained to me; when the IDE started Serial Monitor, or recognised a USB connection, /RESET (I think "NOT"ed) line was effected, so I should tie /RESET with a capacitor to ground so the effect would be smoothed. I opted to watch it double-start until the next IDE release.
I strongly suspect buffering by the operating system.
After an upload the processor is reset and sends the data to the computer (PC). If you open serial monitor after that another reset occurs and data is again send to the computer.
You can upload while serial monitor is open (does not work in IDE 2.x with an original Nano that uses the FT232) or you can close and re-open serial monitor or (as mentioned in post #5 by @Deva_Rishi) give the board a manual reset.
All three scenarios should result in a single message.