[serial-port] How can I "reset" an Arduino board?

I've uploaded a sketch to an Arduino Uno whose loop is something like this:

void loop(){
    Serial.println("Hello, World!");
}

So, now, I can't upload anything anymore, because the IDE says "port already in use".

Is there a way to "reset" the Arduino without another programmer?

Nothing else is using the serial port, and everything went just fine until I uploaded the previous sketch.

I've found some interesting things:

This question is related to serial-port arduino reset

The answer is


The only way it worked for me for arduino nano 33 iot is via pressing the reset button on the board continuously many time then press uoplad!


Be sure you are not accessing the serial port from a terminal. That loop (or any code) should not prevent the Arduino from being programmed.


Here's what I did in Linux to be able to program my Arduino Micro which was stuck in a loop sending the 0 key when connected by USB;

# while true; do xinput float $(xinput --list | grep -i Arduino | awk '{print $7}' | cut -d'=' -f 2); done

Your output might be slightly different so just try running;

# watch xinput --list

then plug in the Arduino and see how the output is formatted.

This stopped X from accepting the keypresses and allowed the Arduino IDE to program finally!


I just spent the last five hours searching for a solution to this problem (serial port COM3 already in use and grayed out serial port)...I tried everything every forum and Q&A site I could find suggested, including this one...

What finally fixed it (got rid of the last code I'd input that got stuck and uploaded simple blink function)?

Follow this link -- http://arduino.cc/en/guide/windows and follow the instructions for installing the drivers. My driver was "already up to date", but following these steps fixed the glitch. I am now a happy camper once again.

Note: Resetting the board manually with the button on the chip, or digitally through miscellaneous codes on the Internet did not work to fix this problem, because the signal was somehow blocked/confused between my Arduino Uno and the port in my laptop. Updating the drivers is like a reset for the "serial port already in use" problem.

At least so far...


Based on my experience with the communication already in use or blocked, I would say that the program you are interfacing with still has the communication open.

I also found that if you disconnect the USB cable it will rest the communication. It is not the greatest solution, but it solves the problem.


I had the very same problem today. Here is a simple solution we found to solve this issue (thanks to Anghiara):

Instead of loading your new code to the Arduino using the "upload button" (the circle with the green arrow) in your screen, use your mouse to click "Sketch" and then "Upload".

Please remember to add a delay() line to your code when working with Serial.println() and loops. I learned my lesson the hard way.


I got a similar problem.

If I power on my Arduino, there is a delay before the uploaded program execute.

So I use that delay for uploading new program, or empty program:

void setup(){}

void loop(){}

So my problem was solved.

Unplug any connection to Arduino pins before upload.


Arduino Leonardo board:

  1. Unplug the USB cable
  2. Connect the RX Pin to ground
  3. Plug in the USB cable
  4. Upload a new program
  5. Remove the USB cable
  6. Remove the RX grounding

Try the following:

  1. Prepare the basic empty program (empty setup, loop, etc.)
  2. Compile it.
  3. Reset the Arduino using the hardware button on the chip
  4. Press Ctrl + U to upload your code.
  5. If unsuccessful - got to 3.

There is a delay before the boot loader starts the programs, just work on your timing. It worked for me when a bug in my Arduino's code was executing a soft reset every 500 ms.


I had the same problem on two Arduinos (one Uno, and one Modern Device Freeduino/USB Host board) and the window between reset and the beginning of serial port usage was so small that it was impossible to upload.

I finally fixed the problem by purchasing another Arduino Uno and building an ISP cable per these instructions, and using it to flash the Bare Bones app from the examples into each inaccessible board, using Arduino IDE version 0023, following these instructions to change preferences.txt. (Be sure to save the original file before editing it so you can replace it after you've rescued your Arduino.)

It took one quick upload to fix each board. Such a fast fix after so much grief. You might not want to purchase another Arduino, but consider these benefits:

  • You can overwrite the bootloader on your Arduino to gain more space.
  • Once the bootloader is overwritten, the board will boot faster.
  • Supposedly you can program raw AVRs for special projects, but I have not tried this: Google for ArduinoISP
  • It will quickly fix Arduinos that you block in the future.
  • You can now safely experiment to find ways to prevent serial port usage from locking up the device in the future.

  1. Unplug Tx from the microcontroller
  2. Insert USB cable
  3. Wait until full load
  4. Connect Rx with hardware
  5. Compile empty sketch in prosses and unconnect tx (don't worry about the error)
  6. Connect Rx with hardware
  7. Compile empty sketch
  8. Power off and connect Tx

I had this issue as well. I tried the above methods and none seemed to work, however something that did work (somehow, not sure if it was just a freak thing or it is actually a way to do it) was:

  1. Unplug USB from the Arduino
  2. Press and hold the reset button
  3. Plug in USB and power up
  4. Continue holding and upload the sketch. Once it's done uploading, release the reset button.

  1. First of all, connect your Arduino device.
  2. Then go to Device Manager and uninstall the driver.
  3. Now remove your Arduino device.
  4. Again connect you Arduino device to your system.
  5. Now install your driver (which you have uninstalled earlier).

It will free your port for sure.


After scratching my head about this problem, here is a very simple solution that works anytime:

  • Unplug your USB cable
  • Go in Device Manager
  • Click on Ports (COM & LPT)
  • Right click on Arduino....(COMx)
  • Properties
  • Port Settings
  • Put Flow Control to HARDWARE
  • Create an empty sketch (Optional)
  • Connect the USB cable
  • Upload (Ctrl + U)

// Empty sketch to fix the upload problem
// Created by Eric Phenix
// Nov 2014

void setup()
{
}

// The loop routine runs over and over again forever:
void loop()
{
    delay(1000);
}

Et voila!


I also had your problem,and I solved the problem using the following steps (though you may already finish the problem, it just shares for anyone who visit this page):

  1. Unplug your Arduino
  2. Prepare an empty setup and empty loop program
  3. Write a comment symbol '//' at the end of program
  4. Set your keyboard pointer next to the '//'symbol
  5. Plug your Arduino into the computer, wait until the Arduino is completely bootloaded and it will output 'Hello, World!'
  6. You will see the 'Hello, World!' outputting script will be shown as comment, so you can click Upload safely.

For Arduino Yún users, try uploading via Ethernet/Wi-Fi (menu ToolsPort).

I had exactly the same problem, and I tried pretty much everything (apart from burning a new bootloader). I am surprised it worked, but I've uploaded an empty sketch without any problem.


If the port says Already used, then you are probably using the wrong port.

Switch it to the port where you connected your Arduino and then try to re-upload, you will definitely see it work.


If nothing helped then you should arrange one more board and try to flash it through the Arduino as ISP option as shown in Arduino as ISP and Arduino Bootloaders or From Arduino to a Microcontroller on a Breadboard.

Instead of a boot loader, you can select your own programs to flash via ISP.


Here is the best way that works out if you are trying to program through the USB cable:

  1. Ground the Tx signal on the board (connect digital I/O #1 to GND)
  2. Plug the USB cable
  3. Upload a new program
  4. Remove the USB cable
  5. Remove Tx grounding

You are all set!


If you still have the serial console open, it will reserve the serial port. Close it, and try again.


Make sure you plug the Arduino directly into the computer and not through a hub. Using a hub will give you this error.


Examples related to serial-port

python to arduino serial read & write Reading serial data in realtime in Python Python: Writing to and Reading from serial port IOException: read failed, socket might closed - Bluetooth on Android 4.3 Reading and writing to serial port in C on Linux Python Serial: How to use the read or readline function to read more than 1 character at a time Serial Port (RS -232) Connection in C++ "The semaphore timeout period has expired" error for USB connection What is the correct way to read a serial port using .NET framework? Arduino COM port doesn't work

Examples related to arduino

Arduino Nano - "avrdude: ser_open():system can't open device "\\.\COM1": the system cannot find the file specified" python to arduino serial read & write how to stop a loop arduino Arduino Sketch upload issue - avrdude: stk500_recv(): programmer is not responding avrdude: stk500v2_ReceiveMessage(): timeout Arduino Tools > Serial Port greyed out Arduino error: does not name a type? Transform char array into String How do I remove a library from the arduino environment? Arduino COM port doesn't work

Examples related to reset

How to reset a form using jQuery with .reset() method Reset all the items in a form How to reset db in Django? I get a command 'reset' not found error How to git reset --hard a subdirectory? How do I revert back to an OpenWrt router configuration? Wipe data/Factory reset through ADB Fastest way to reset every value of std::vector<int> to 0 How do I reset the setInterval timer? How to reset par(mfrow) in R Reset auto increment counter in postgres