The UNO, Nano, and several other Arduino boards will often reset when the serial port is opened. Depending on the board, IDE, and operating system, you may see one or even two resets. This behavior is related to the auto-reset circuitry and the USB interface.
My usual solution is to add a two-second delay immediately after Serial.begin(), which is typically the first line in setup(). In most cases, this allows the reset sequence to complete before the rest of the program starts.
Some users disable or modify the auto-reset circuit, often by adding a capacitor, but I generally just let the board reset. The two-second delay also makes it easier to recover if I accidentally flood the serial port with output.
Linux Mint 22.3
Arduino IDE 2.3.8
Arduino Uno clone
Serial Monitor already open, time stamps on.
After uploading I see this.
It does print almost twice!
One side effect is that opening the Serial Monitor may also reset the board. In my experience, this is not always true. Generally, the behavior is not caused by the IDE sending a special reset command. It is the result of opening the serial port and toggling DTR, which may also cause the computer to re-enumerate the USB device, sometimes resulting in a different port assignment.
The capacitor modification holds the reset line in a state that prevents the auto-reset pulse, so the host does not see the disconnect/reconnect sequence that triggers re-enumeration.
I have observed this behavior since Arduino IDE 1.0, around 2012, when I was using Linux Mint 12 Lisa with the Cinnamon 1.2 desktop.
the link i posted said on some boards the serial interface DTR (data terminal ready) pin causes a reset. There's not specific command from the IDE to reset the board.
there may be ways over a serial USB interface for a laptop to control individual serial interface pins, but it seems odd that it would do something > half sec after connecting to the board to reset it.
My apologies for not replying earlier, I had a computer problem. However, it looks like things have progressed (on here) and maybe my problem isn't just me. I'm currently installing the latest version of mint and will let you know if that fixes anything. It's a slow process. Time to reboot, wish me luck.
It appears to be fine however I now have a different problem I've downloaded the file arduino-ide_2.3.10_Linux_64bit.AppImage and run it but I don't have an item under the menu that is programming and the only way to get the program back is by running the AppImage file again. Is this an Arduino or Linux bug or me?