ESP32 program compiles but won't load

I finally found a LoRa Gateway that compiles. 2 RPis, 1 PC, all running IDE 1.8.13 libraries and board managers updated today. all return the same result.

TTGO V2.16 OLED LoRa SD et cetera. It’s preloaded with a demo program

When I try to upload, it compiles, then throws a long error message and halts. the informative part of the error message:

 SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

Device or resource busy: - Is there a reset required, or procedure you have to perform to wake up the ESP32 serial port?

Entire error message:

Arduino: 1.8.13 (Linux), Board: "TTGO LoRa32-OLED V1, 80MHz, 921600, None"

Invalid library found in /home/pi/Arduino/Sketchbook/libraries/ZIPPED: no headers files (.h) found in /home/pi/Arduino/Sketchbook/libraries/ZIPPED
Sketch uses 654078 bytes (49%) of program storage space. Maximum is 1310720 bytes.
Global variables use 38164 bytes (12%) of dynamic memory, leaving 256748 bytes for local variables. Maximum is 294912 bytes.
Traceback (most recent call last): v3.0-dev
  File "/home/pi/.arduino15/packages/esp32/tools/esptool_py/3.0.0/", line 3682, in <module>
An error occurred while uploading the sketch
  File "/home/pi/.arduino15/packages/esp32/tools/esptool_py/3.0.0/", line 3675, in _main
Serial port /dev/ttyUSB0
  File "/home/pi/.arduino15/packages/esp32/tools/esptool_py/3.0.0/", line 3329, in main
    esp = chip_class(each_port, initial_baud, args.trace)
  File "/home/pi/.arduino15/packages/esp32/tools/esptool_py/3.0.0/", line 263, in __init__
    self._port = serial.serial_for_url(port)
  File "/usr/lib/python2.7/dist-packages/serial/", line 88, in serial_for_url
  File "/usr/lib/python2.7/dist-packages/serial/", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'
Invalid library found in /home/pi/Arduino/Sketchbook/libraries/ZIPPED: no headers files (.h) found in /home/pi/Arduino/Sketchbook/libraries/ZIPPED

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

The LoRa Gateway:

// Import Wi-Fi library
#include <WiFi.h>

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//define the pins used by the LoRa transceiver module
#define ss 18
#define rst 23
#define dio0 26

#define BAND 915E6    //433E6 for Asia, 866E6 for Europe, 915E6 for North America

// Replace with your network credentials
String apiKey = "14K8UL2QEK8BTHN6"; // Enter your Write API key from ThingSpeak
const char *ssid = "DILLBURT"; // your wifi ssid and wpa2 key
const char *password = "R3$!t4nnc3";
const char* server = "";

WiFiClient client;

// Initialize variables to get and save LoRa data
int rssi;
String loRaMessage;
String temperature;
String humidity;
String readingID;

// Replaces placeholder with DHT values
String processor(const String& var)
  if (var == "TEMPERATURE")
    return temperature;
  else if (var == "HUMIDITY")
    return humidity;
  else if (var == "RRSI")
    return String(rssi);
  return String();

void setup()
  int counter;

  //setup LoRa transceiver module
  LoRa.setPins(ss, rst, dio0); //setup LoRa transceiver module

  while (!LoRa.begin(BAND) && counter < 10)
  if (counter == 10)
    // Increment readingID on every new reading
    Serial.println("Starting LoRa failed!");
  Serial.println("LoRa Initialization OK!");

  // Connect to Wi-Fi network with SSID and password
  Serial.print("Connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  // Print local IP address and start web server
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");

// Read LoRa packet and get the sensor readings
void loop()
  int packetSize = LoRa.parsePacket();
  if (packetSize)
    Serial.print("Lora packet received: ");
    while (LoRa.available())    // Read packet
      String LoRaData = LoRa.readString();

      int pos1 = LoRaData.indexOf('/');
      int pos2 = LoRaData.indexOf('&');
      readingID = LoRaData.substring(0, pos1);                    // Get readingID
      temperature = LoRaData.substring(pos1 + 1, pos2);           // Get temperature
      humidity = LoRaData.substring(pos2 + 1, LoRaData.length()); // Get humidity

    rssi = LoRa.packetRssi();       // Get RSSI
    Serial.print(" with RSSI ");

  if (client.connect(server, 80)) // "" or
    String postStr = apiKey;
    postStr += "&field1=";
    postStr += String(readingID);
    postStr += "&field2=";
    postStr += String(temperature);
    postStr += "&field3=";
    postStr += String(humidity);
    postStr += "&field4=";
    postStr += String(rssi);
    postStr += "\r\n\r\n\r\n\r\n";

    client.print("POST /update HTTP/1.1\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");


Did you mean to post your WiFi and apiKey information or was that by accident?

You assume that:
This is my information
I am the one who left it there

running your life on assumptions leads to a difficult life

I did not assume anything. Another user was happy when I pointed that out and he removed the information.

Good luck with your project.

1 Like

the answer to my question is: yes, but…

many ESP32 boards have a button marked EN, BOOT, or GPIO. mine does not. this button shorts GPI0 to ground. you have to short GPI0 to ground to enable boot mode, then hit reset, then upload. how I could miss such an intuitive thing is a mystery to me.

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