WiFi using the ESP32

Another popular and more powerful IOT WiFi module is the ESP32. The ESP32 is a system on a chip (SOC) with duel high-performance Xtensa 32-bit LX6 CPU cores, WiFi (2.4GHz band), Bluetooth, ultra low power co-processor and multiple peripherals. In this project, you'll learn how to work with the ESP32 WiFi module using the Arduino IDE.

The main documentation on using the ESP32 and all the functions available on the chip are found here.

Parts needed: ESP32 D1 mini ESP32
1 To program the ESP8266 WiFi module, you first need to add the ESP32 Board definition to the Arduino IDE program. You only need to do this once so if it has already been done then skip this step and go to step 2.
  • Start the Arduino program (must use version 1.6.7 or greater).
  • From the Arduino menu, select File | Preferences
  • In the Additional Boards Manager URLs field, copy and paste the following:

  • If you already have the ESP8266 boards URL listed, you can separate the two URLs with a comma.
  • Click OK
Adding ESP32 board
  • From the Arduino menu, select Tools | Board | Boards Manager
  • Type esp32 in the search bar to find the ESP32 Dev module by Espressif Systems, and click on it to select it.
  • Select the version you want from the drop-down box. Normally, you'll want the newest version.
  • Click the Install button.
  • After installation, exit and re-launch the Arduino IDE program.
Adding ESP32 board
2 Plug in the micro USB cable between the ESP32 development board and your computer.
3 Select from the menu Tools | Board | ESP32 Arduino | ESP Dev Module. Selecting the ESP32 development board
4 Select from the menu File | Examples. Under the Examples for ESP32 Dev Module section, select WiFI | WiFiScan Selecting the ESP32 development board
5 You should see this program listed.
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is almost the same as with the WiFi Shield library,
 *  the most obvious difference being the different file you need to include:
#include "WiFi.h"

void setup()

    // Set WiFi to station mode and disconnect from an AP if it was previously connected

    Serial.println("Setup done");

void loop()
    Serial.println("scan start");

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();
    Serial.println("scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            Serial.print(i + 1);
            Serial.print(": ");
            Serial.print(" (");
            Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");

    // Wait a bit before scanning again
6 Select the correct COM port (under Tools | Port) that your module is connected to.
7 Upload and run the program. After you click on the Upload button, you need to press and hold down the Boot button on the development board until it starts uploading. You can then release the button.

If you are using the WeMos D1 mini board, you might need to use this USB driver in order to upload the code successfully.
Upload program
8 Open up the serial monitor and set the baud rate (bottom right corner) to 115200.
9 You should see a similar output in the serial monitor with a list of all the WiFi networks available near you. Sample run
10 Here are the pinouts for the ESP32 Development Board.
ESP32 Development Board Pins ESP32 Development Board Pins