The selected serial port does not exist/your board is not connected

I wanted to upload a sketch from examples and it showed me this message:
Arduino: 1.8.15 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Daniela\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=1A86_7523 -ide-version=10815 -build-path C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718 -warnings=none -build-cache C:\Users\Daniela\AppData\Local\Temp\arduino_cache_19601 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Daniela\AppData\Local\Temp\arduino_modified_sketch_980716\DHT22Default.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Daniela\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=1A86_7523 -ide-version=10815 -build-path C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718 -warnings=none -build-cache C:\Users\Daniela\AppData\Local\Temp\arduino_cache_19601 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Daniela\AppData\Local\Temp\arduino_modified_sketch_980716\DHT22Default.ino

Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp" -o nul

Alternatives for SimpleDHT.h: [SimpleDHT@1.0.14]

ResolveLibrary(SimpleDHT.h)

-> candidates: [SimpleDHT@1.0.14]

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp" -o nul

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT" "C:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT\SimpleDHT.cpp" -o nul

Generating function prototypes...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp" -o "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\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\Daniela\AppData\Local\Temp\arduino_build_813718\preproc\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp" -o "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp.o"

Compiling libraries...

Compiling library "SimpleDHT"

"C:\Program Files (x86)\Arduino\hardware\tools\avr/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=atmega2560 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT" "C:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT\SimpleDHT.cpp" -o "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\libraries\SimpleDHT\SimpleDHT.cpp.o"

Compiling core...

Using precompiled core: C:\Users\Daniela\AppData\Local\Temp\arduino_cache_19601\core\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a

Linking everything together...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.elf" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\sketch\DHT22Default.ino.cpp.o" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718\libraries\SimpleDHT\SimpleDHT.cpp.o" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/..\arduino_cache_19601\core\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a" "-LC:\Users\Daniela\AppData\Local\Temp\arduino_build_813718" -lm

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.elf" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.eep"

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-objcopy" -O ihex -R .eeprom "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.elf" "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.hex"

Using library SimpleDHT at version 1.0.14 in folder: C:\Users\Daniela\Documents\Arduino\libraries\SimpleDHT

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-size" -A "C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.ino.elf"

Sketch uses 6746 bytes (2%) of program storage space. Maximum is 253952 bytes.

Global variables use 365 bytes (4%) of dynamic memory, leaving 7827 bytes for local variables. Maximum is 8192 bytes.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM3 -b115200 -D -Uflash:w:C:\Users\Daniela\AppData\Local\Temp\arduino_build_813718/DHT22Default.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 (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"



     Using Port                    : COM3

     Using Programmer              : wiring

     Overriding Baud Rate          : 115200

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

avrdude: ser_drain(): read error: The handle is invalid.

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: ser_send(): write error: sorry no info avail

avrdude: stk500_send(): failed to send command to serial port

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done. Thank you.

the selected serial port

does not exist or your board is not connected

What can I do?

What does Windows Device Manager say about your board? Is it still COM3?

It shows Arduino Mega (COM3), only after i installed the Arduino Mega driver

@daniela33 Try and install the core for your board via the IDE. See https://www.arduino.cc/en/Guide/Cores

That core is installed, else the OP should not be able to select the Mega.

  1. Did you select the board and the port it is connected to via the IDE's tools before uploading a sketch?
  2. Are you using an official Arduino or a clone?
  3. If your computer and IDE recorgnise the board and you are still having the issue, do the steps below:
    Put your board in bootloader mode by double tapping the rest button. While it is in this mode, upload an example sketch from the IDE, say BlinkLED into it, then tap the rest button once afterwards to exit the bootloader mode.
    Now upload the same sample code (sketch) normally to the board, if successful, your board can now be programed with your own code.
    Note: do not use your own code(sketch) when the board is in bootloader mode.

Double tapping is the solution for a board with native USB; a Mega is not such a board.

Press & hold the reset button, then upload a sample sketch from the IDE to it. Once upload is completed, try uploading normally again without holding the reset button. Remove anything wired to the board while doing this.

I think I tried everything above, apparently the issue was from my computer, I still don't know what the problem was, but the code worked perfectly on another computer.
Thank you all for your help.

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