Installing ESP32/Arduino libraries

From Hackers & Designers

Install libraries

Depending on the situation you may have to install additional libraries. In this specific example we are installing the ESPAsyncWebserver and AsyncTCP libraries that are used in the WifiZine Scavengerhuntworkshop. The process is the same for other libraries.

We assume you have already downloaded and setup the Arduino IDE for use with the ESP32 modules.

Both these libraries are not available to install through the Arduino IDE's manage libraries interface, so we have to install them manually:

ESPAsyncWebServer

  1. Download the code
  2. Unzip the downloaded file.
  3. Remove the "-master" part from the unzipped directory name, so ESPAsyncWebServer-master should now be called ESPAsyncWebServer
  4. Move the renamed directory to your library directory:
  • On Windows: My Documents\Arduino\libraries
  • On Linux: {sketchbook folder}/libraries. The sketchbook folder location can be found (or changed) at File > Preferences > Sketchbook location:. This is the location of libraries installed via Library Manager (Sketch > Include Library > Manage Libraries…) or Sketch > Include Library > Add .ZIP Library. You should also manually install libraries to that location.
  • On MacOS: ~/Documents/Arduino/libraries

AsyncTCP

Much the same as above:

  1. Download the code
  2. Unzip the downloaded file.
  3. Remove the "-master" part from the unzipped directory name, so AsyncTCP-master should now be called AsyncTCP
  4. Move the renamed directory to your library directory (See above).

Restart the IDE after installation.

Confirming code compilation

  • Restart the Arduino IDE (the Arduino software)
  • Create a new sketch.
  • Copy/paste the following code. This code does nothing, but if it compiles and upload without errors we know that everything is installed correctly.
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>

void setup() {
}

void loop() {
}
  • Select the ESP32 Dev Module board
Screenshot of Arduino menu open at > Tools > Board > ESP32 Dev Module
Screenshot of Arduino menu open at > Tools > Board > ESP32 Dev Module

Compile

Click on the compile button in the top left of the editor (see red arrow in pic beneath)

arduino window with red arrow pointing to the compile button on the top left
Arduino window with red arrow pointing to the compile button on the top left
  • If the compilation process is successful, it will say “DONE COMPILING” at the bottom
  • This means Arduino confirms it can find everything it needs to upload working code
  • Don’t upload the code to the board yet, first we need some more stuff
Screenshot of Arduino window with “done compiling” message in the bottom bar of the window
Screenshot of Arduino window with “done compiling” message in the bottom bar of the window
  • If the compilation process ends abnormally, it will give an orange error
  • If necessary, troubleshoot using the error messages (if you don’t get any, check that “verbose” is checked in settings of Arduino.
Arduino window with an orange error message
Arduino window with an orange error message

Upload to the Board

when the output window in Arduino says CONNECTING, push the boot button on the board
when the output window in Arduino says CONNECTING, push the boot button on the board
  • If the upload was successful, you will see this screen:
output window in Arduino stating Leaving...Hard resetting via RTS pin....
output window in Arduino stating Leaving...Hard resetting via RTS pin....
  • If the upload was unsuccessful, you will see this error
arduino window with an orange error message
arduino window with an orange error message

Troubleshooting tips for various problem factors here

For MacOS users we've collected some common troubleshooting steps here

If everything went well, you are now ready to upload your own code to the board!

Next steps:

You probably want to continue to Uploading a website to the ESP32 module.