|| Back to Support & Help Documentation ||

WiFi & BLE

To load the program into the ESP32 you have to install the board. Go to File >  Preferences and into Additional Boards Manager URLs add the next URLhttps://dl.espressif.com/dl/package_esp32_index.json

*If you already have one URL put it next to the other separeted by coma, like in the image below. 

Now you are able to install the board. Go to Tools > Boards > Boards Manager and search by ESP32. Will appear the esp32 by Espressif Systems. Install it.  

Once it is installed go to Tools > Boards and choose DOIT ESP32 DEVKIT V1

Examples


WiFi


You will find some examples to test in File > Examples > Examples for ESP32 Dev Module. Let's take a look at the WiFi Scan example. 


Here you have the code with some additions and comments:


Wifi_Scan code:

#include "WiFi.h"

void setup()
{
    Serial2.begin(19200);
    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);
    
    Serial2.println("Setup done");
}

void loop()
{
    int start = millis(); // Capture start time 
    Serial2.println("scan start");

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

    // Wait a bit before scanning again
    delay(5000);
}

As you can see you have to go to www.uuidgenerator.net to generate a 128-bit number identifier UUID (universally unique identifier) that is used to ensure that the services and characteristics of your device are globally unique.  


After load the program in the Serial Monitor you will see 5 steps to follow:

  1. Download and install an BLE scanner app in your phone. For example BLE Scanner from Bluepixel Technologies.

  2. Scan for BLE devices in the app. 

  3. Connect to MyESP32. You won't see it until you run the program.  

  4. Go to CUSTOM CHARACTERISTIC in CUSTOM SERVICE and write something.

  5. See the magic =). Everything you write will be printed.  


Result


After uploading the previous program of BLE write you will see something like this in the Serial Monitor:

Hello? and It works :) are two messages sent from the phone.


1 Star 2 Star 3 Star 4 Star 5 Star