An error occurred while uploading the sketch.

pranayar:
avrdude: ser_open(): can't open device "\.\COM4": The system cannot find the file specified.

Select the COM port of your Nano from the Arduino IDE's Tools > Port menu.

If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

Hi, guys, I have an error :Re: An error occurred while uploading the sketch. can you please help me!!!!
I tried opening IDE by itself but I get the same error! can you please help me!!!!

I've gotten error :Re: An error occurred while uploading the sketch.
here is my code:

#include <Servo.h>
int pot1 = A0;
Servo myservo;
void setup() {
// put your setup code here, to run once:
myservo.attach(0);
Serial.begin(6900);
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println(pot1);
myservo.write(90);
Serial.println(myservo.read());
delay(1000);
myservo.write(0);
Serial.println(myservo.read());
}

please help me!!

port: COM7
programmer: arduinoISP
board: uno
message: help!

ScienceMax:
I've gotten error :Re: An error occurred while uploading the sketch

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

hi pert. I think it worked! thank you!

My instructions above were only intended to get the necessary information to troubleshoot your problem. There is nothing about them that should have solved the problem. However, I'm glad to hear it's working now. Enjoy!
Per

thanks again!

Some one help me I have the same problem even though I used it many times but now I have that problem and it showing the message after a long time of uploading

Sriman_singaravelan:
Some one help me I have the same problem even though I used it many times but now I have that problem and it showing the message after a long time of uploading

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
1 Like

Hi,
I have the same problem. The output is the following:

Arduino: 1.6.11 (Windows 8.1), Board: "Arduino/Genuino Micro"

Sketch uses 4,136 bytes (14%) of program storage space. Maximum is 28,672 bytes.
Global variables use 148 bytes (5%) of dynamic memory, leaving 2,412 bytes for local variables. Maximum is 2,560 bytes.
Forcing reset using 1200bps open/close on port COM7
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
PORTS {COM1, COM7, } / {COM1, COM7, } => {}
Uploading using selected port: COM7
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM7 -b57600 -D -Uflash:w:C:\Users\CONSTA~1\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.hex:i

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM7
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Thanks.

ck81:
Hi,
I have the same problem. The output is the following:

Make sure you have the correct board selected from the Tools > Board menu.

Make sure you have selected the port of your Arduino board from the Tools > Port menu.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

My case may be interesting in that the error output is somewhat different.
I use an official AtMEGA 2560 board with IDE 1.8.9. Everything worked fine until yesterday ( meaning successful uploads for several days)

Of course I still use the good port : COM6 for me (the only one that appears when I connect the board !)

Now I get that same message with windows 10, Linux Debian, two different machines and two different cables :

C:\Users\JP\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\JP\AppData\Local

\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega2560 -cstk500v2 -Pusb -Uflash:w:C:\Users\JP\AppData

\Local\Temp\arduino_build_978917/Blink.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\JP\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-

arduino17/etc/avrdude.conf"

         Using Port     : usb              
An error occurred while uploading the sketch
 
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

I am trying with the blink sketch here. I must add that since yesterday I succeeded uploading twice but failed innunmerable times. May it have some connection with recent avrdude updates ?

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 930 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avrdude -CC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM9 -b115200 -D -Uflash:w:C:\Users\Robert\AppData\Local\Temp\arduino_build_615160/Blink.ino.hex:i

avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"

An error occurred while uploading the sketch
Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't open device "\.\COM9": The system cannot find the file specified.

avrdude done. Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ABRobert:

avrdude: ser_open(): can't open device "\\.\COM9": The system cannot find the file specified.

You need to select the port of your Arduino board from the Tools > Port menu. If you find multiple ports in the menu and don't know which is the Arduino, Try this:

  • With the Arduino board unplugged from the USB open the Tools > Port menu and note the listed ports. If the Port menu is gray and disabled then that means there are no ports available.
  • Close the Tools > Port menu.
  • Plug in the USB cable on the Arduino board
  • Wait a little while for the Arduino board to connect
  • Open Tools > Port, the new port on the list is your Arduino board. In some cases it will have the name of the board next to the port name but this doesn't happen with all boards. If the Port menu is gray and disabled then that means your Arduino board didn't install correctly. You may need to install a driver.
  • Select your Arduino's port from the menu.

Too bad that the only suggested solution is to select the right port. Obviously my problem is very different with my config :

avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

Maybe a faulty board ? Strange, since I get the informations from the board through the USB connection.

jptrol:
Too bad that the only suggested solution is to select the right port. Obviously my problem is very different with my config :

avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

Maybe a faulty board ? Strange, since I get the informations from the board through the USB connection.

Your problem is caused by holding the Shift key while you click the Upload button. That causes the Arduino IDE to do an "Upload Using Programmer" instead of a standard Upload. Since you don't have an ISP programmer connected, that won't work, thus the error.

pert:
Your problem is caused by holding the Shift key while you click the Upload button. That causes the Arduino IDE to do an "Upload Using Programmer" instead of a standard Upload. Since you don't have an ISP programmer connected, that won't work, thus the error.

Thank you for your help Pert. Though I can't remember hitting the shift key or clicking the programmer option , the fact is that when I carefully select upload or CTRL U I now succeed every time I try. May it go on !
Thank you again.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

Arduino: 1.8.10 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 936 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM16 -b115200 -D An error occurred while uploading the sketch-Uflash:w:C:\Users\dharani\AppData\Local\Temp\arduino_build_889315/sketch_oct08a.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM16
Using Programmer : arduino
Overriding Baud Rate : 115200

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

SIVAJEEVA:
Arduino: 1.8.10 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 936 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM16 -b115200 -D An error occurred while uploading the sketch-Uflash:w:C:\Users\dharani\AppData\Local\Temp\arduino_build_889315/sketch_oct08a.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM16
Using Programmer : arduino
Overriding Baud Rate : 115200

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

This one is really tricky because the output is not providing us with any useful information about the error. Please try restarting your computer. Maybe by some miracle that will fix the problem, or at least cause the output to show some more info.