Upload to Nano is blocked by serial monitor

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
Arduino:1.8.19 (Windows 10), Board:"Arduino Nano, ATmega328P (Old Bootloader)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\henkv\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\henkv\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\henkv\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328old -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\henkv\AppData\Local\Temp\arduino_build_849738 -warnings=none -build-cache C:\Users\henkv\AppData\Local\Temp\arduino_cache_804336 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\henkv\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\henkv\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\henkv\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328old -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\henkv\AppData\Local\Temp\arduino_build_849738 -warnings=none -build-cache C:\Users\henkv\AppData\Local\Temp\arduino_cache_804336 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avrdude.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

Using board 'nano' from platform in folder: C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Using core 'arduino' from platform in folder: C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\sketch\\Blink.ino.cpp" -o nul

Generating function prototypes...

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\sketch\\Blink.ino.cpp" -o "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Sketch aan het compileren...

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\sketch\\Blink.ino.cpp" -o "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\sketch\\Blink.ino.cpp.o"

Compiling libraries...

Compiling core...

Using precompiled core: C:\Users\henkv\AppData\Local\Temp\arduino_cache_804336\core\core_arduino_avr_nano_cpu_atmega328old_cb9b7c24fff112eff849a1c7b2d8b7cf.a

Linking everything together...

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.elf" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738\\sketch\\Blink.ino.cpp.o" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/..\\arduino_cache_804336\\core\\core_arduino_avr_nano_cpu_atmega328old_cb9b7c24fff112eff849a1c7b2d8b7cf.a" "-LC:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738" -lm

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.elf" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.eep"

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.elf" "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.hex"

"C:\\Users\\henkv\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\henkv\\AppData\\Local\\Temp\\arduino_build_849738/Blink.ino.elf"

De schets gebruikt 924 bytes (3%)  programma-opslagruimte. Maximum is 30720 bytes.

Globale variabelen gebruiken 9 bytes (0%) van het dynamisch geheugen. Resteren 2039 bytes voor lokale variabelen. Maximum is 2048 bytes.

C:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b57600 -D -Uflash:w:C:\Users\henkv\AppData\Local\Temp\arduino_build_849738/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\henkv\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : COM6

         Using Programmer              : arduino

         Overriding Baud Rate          : 57600

avrdude: ser_open(): can't set com-state for "\\.\COM6"



avrdude done.  Thank you.

Er trad een error op gedurende laden van de schets

Hi @zonnetje58 ,

something went wrong when you used the code tags ...

However the upload did not work due to this issue

avrdude: ser_open(): can't set com-state for ".\COM6"

You may have a look at this

https://support.arduino.cc/hc/en-us/articles/13148652511260-avrdude-ser-open-can-t-set-com-state-for-COMn

Good luck!
ec2021

1 Like

hello ec2021,
thank you for your answer, I am a novice user but the error message I keep getting is that the serial monitor is being used by another program, but I don't know by which program or how I can make that visible when I use the monitor If you open it and close it again, my sketches will be uploaded.
the nano has worked well for a year, I have not used it for the past 2 months until 4 days ago when this problem suddenly arose, the strange thing is that when I use an arduino uno this problem does not occur, tomorrow we will see if you have a possible solution that works, I have been looking for 4 days to find out what the problem is so i hope it works.
thank you
zonnetje58

Did you try the suggestions in the article linked by @ec2021 ?

I have seen that message several times. Each time I had the serial monitor worked in a different window. For grins restart the machine and try again.

I've fixed your code tags; [code] and [/code] need to be on their own line. You missed that for the closing code tag.

You can also use code tags for error messages (as demonstrated).

Are you saying that if you close the serial monitor you do not get the "com-state" error? Or do you get another error if the serial monitor is open?

The com-state error is associated with the CH340 chip (on the bottom of the Nano). Your Uno might not be using that chip or an earlier production release of that chip and hence you don't have the problem. There are also boards (possibly your one) with reject CH340 chips and to my knowledge the com-state issue only shows for those.

Because your board used to work, I suspect that a driver update by Windows is now causing the problems and the suggested rollback should solve that.

Question:
Does the chip on the bottom of the board have markings like below?

If not, it's a reject CH340.

Hi Sterretje,
correct, the nano is the same as in your photo,
When I want to upload the blink, the error message appears. If I open and close the serial monitor, I click upload again and the program is then transferred to the nano without any problems.
i am trying ec2021's solution to fix
I don't fully understand what you're saying, but I do understand that a Windows update causes this problem.
thank you for your thoughts

hi ec2021 and everyone else, the driver for the com port turned out to be wrong, via your link I was able to fix that, many thanks for that, I had not looked in that direction, it turns out that I do not yet have enough knowledge to do this kind of problems, the nano can now be used normally again with the Arduino IDE, I still have upload problems in mobaledlib, but I still have to find out what exactly goes wrong, I like that everyone is so involved and actively helping to to address such issues, thank you again.
Kind regards Zonnetje58

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.