Error message - Error opening serial port 'COM 3'

Hey there. I am trying to program GPS location tracking with ESP 32 and a NEO-6M GPS Module. When searching on the Internet, I saw a tutorial with ESP 8266 and I decided to use it as I couldn't find a clear tutorial for me for the ESP 32. After trying to upload the code to the ESP 32, an error message popped out. However, there was no problem at the verification stage.

Below is the error message copied.

Arduino: 1.8.20 Hourly Build 2022/04/25 09:33 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Executable segment sizes:

ICACHE : 32768           - flash instruction cache 

IROM   : 507180          - code in flash         (default or ICACHE_FLASH_ATTR) 

IRAM   : 29881   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 

DATA   : 1628  )         - initialized variables (global, static) in RAM/HEAP 

RODATA : 2364  ) / 81920 - constants             (global, static) in RAM/HEAP 

BSS    : 27376 )         - zeroed variables      (global, static) in RAM/HEAP 

Sketch uses 541053 bytes (56%) of program storage space. Maximum is 958448 bytes.

Global variables use 31368 bytes (38%) of dynamic memory, leaving 50552 bytes for local variables. Maximum is 81920 bytes.

esptool.py v3.0

Serial port COM3

Traceback (most recent call last):

  File "C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2/tools/upload.py", line 66, in <module>

    esptool.main(cmdline)

  File "C:/Users/User/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool\esptool.py", line 3551, in main

    esp = chip_class(each_port, initial_baud, args.trace)

  File "C:/Users/User/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool\esptool.py", line 271, in __init__

    self._port = serial.serial_for_url(port)

  File "C:/Users/User/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/pyserial\serial\__init__.py", line 90, in serial_for_url

    instance.open()

  File "C:/Users/User/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/pyserial\serial\serialwin32.py", line 64, in open

    raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))

serial.serialutil.SerialException: could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

serial.serialutil.SerialException: could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)



processing.app.SerialException: Error opening serial port 'COM3'.

	at processing.app.Serial.<init>(Serial.java:152)

	at processing.app.Serial.<init>(Serial.java:82)

	at processing.app.SerialMonitor$2.<init>(SerialMonitor.java:132)

	at processing.app.SerialMonitor.open(SerialMonitor.java:132)

	at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)

	at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2126)

	at processing.app.Editor.access$1300(Editor.java:116)

	at processing.app.Editor$UploadHandler.run(Editor.java:2095)

	at java.lang.Thread.run(Thread.java:748)

Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port not found.

	at jssc.SerialPort.openPort(SerialPort.java:167)

	at processing.app.Serial.<init>(Serial.java:141)

	... 8 more

Error opening serial port 'COM3'.



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


//FirebaseESP8266.h must be included before ESP8266WiFi.h
#include <FB_Const.h>
#include <FB_Error.h>
#include <FB_Network.h>
#include <FB_Utils.h>
#include <Firebase.h>
#include <FirebaseESP8266.h>
#include <FirebaseFS.h>
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>


#define FIREBASE_HOST "gps-esp32-37b60-default-rtdb.firebaseio.com"
#define FIREBASE_AUTH "KbCvKlqe7jo0s9cqvqUX6l1vF7O6GgoVSJ4ZHePt"
#define WIFI_SSID "NG_Family_2.4G@unifi"
#define WIFI_PASSWORD "pke5859@NG"


//Define FirebaseESP8266 data object
FirebaseData firebaseData;

FirebaseJson json;
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//GPS Module RX pin to NodeMCU D1
//GPS Module TX pin to NodeMCU D2
const int RXPin = 4, TXPin = 5;
SoftwareSerial neo6m(RXPin, TXPin);
TinyGPSPlus gps;


void setup()
{

  Serial.begin(115200);

  neo6m.begin(9600);
  
  wifiConnect();

  Serial.println("Connecting Firebase.....");
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);
  Serial.println("Firebase OK.");
}



void loop() {
  
  smartdelay_gps(1000);

  if(gps.location.isValid()) 
  {
    float latitude = gps.location.lat();
    float longitude = gps.location.lng();
    
      if(Firebase.setFloat(firebaseData, "/GPS/f_latitude", latitude))
      {print_ok();}
    else
      {print_fail();}
    
    if(Firebase.setFloat(firebaseData, "/GPS/f_longitude", longitude))
      {print_ok();}
    else
      {print_fail();}
     }
  else
  {
    Serial.println("No valid GPS data found.");
  }
  
  delay(5000);
}


static void smartdelay_gps(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (neo6m.available())
      gps.encode(neo6m.read());
  } while (millis() - start < ms);
}


void wifiConnect()
{
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();
}


void print_ok()
{
    Serial.println("------------------------------------");
    Serial.println("OK");
    Serial.println("PATH: " + firebaseData.dataPath());
    Serial.println("TYPE: " + firebaseData.dataType());
    Serial.println("ETag: " + firebaseData.ETag());
    Serial.println("------------------------------------");
    Serial.println();
}


void print_fail()
{
    Serial.println("------------------------------------");
    Serial.println("FAILED");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
}


void firebaseReconnect()
{
  Serial.println("Trying to reconnect");
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

Is this a problem with the difference of the board I declared and the board I actually use and if there is any solution to this problem?

Thank you.

That error is not with your code, but with the uploader trying to open COM3 to communicate with your ESP32. Is that the correct port? Did you set the correct port in the IDE (Tools->Port->...)

I suppose yes, it is the correct port as it is the only port available there.

On most PCs, there is always a COM3 - doesn't mean that is where your ESP32 is plugged in and recognized. What is the list of ports available when the ESP32 is not plugged in? What is the list of ports available when the ESP32 is plugged in?

On Windows PCs, a reboot is sometimes necessary if a COM port gets hung up.

I tried checking and found that when ESP32 is plugged in there will be a COM4 but for Arduino its a COM3.

There is no available port when the ESP32 is not plugged in.

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