The ESP32 is a versatile board with on-board Wifi and Bluetooth. It can do all the basic Arduino functionalities and more. One beautiful thing is that you don’t need a separate environment to program this board. It can work with your existing Arduino IDE. This post goes over the set up of this board and how you can run a webhook ping program using it’s on-board Wifi.

Purchasing the Board

You can purchase the board from maker stores or from Amazon. There are typically two forms of the board available in the market:

  1. The original board from Espressif Systems original board

  2. The boards from third-party companies like Adafruit and Wemos that incorporate this chip third party board

  3. The clone boards from no-name companies clone board

Setting up the board

You can follow the set up instructions on the Espressif Systems website. The basic thing you need to do is add the board to your IDE, then select the ESP32 DevModule and your board for flashing. If you don’t find the right port automatically selected, ensure your USB cable can read and write data. Also, you might need to give your system permission to use this port.

Select board and port

If you get any error regarding serial or esptool not found, install them using the following command:

pip install pySerial esptool

Ensure you change pip to pip3 if you don’t have pip pointing to pip3 on your path.

Running the Wifi Test example

You can test the Wifi functionality of your board using the program below. This program sends HTTP POST requests every 30 seconds to the configured endpoint endpoint. You can use Webhook.site for quick testing. Simply replace the content of endpoint with the endpoint that Webhook.site gives to you. Also, replace the <YOUR_WIFI_SSID> and <YOUR_WIFI_PASSWORD> with your Wifi’s SSID and password.

#include <WiFi.h>
#include <HTTPClient.h>
#include <Arduino.h>

const char* ssid = "<YOUR_WIFI_SSID>";
const char* password = "<YOUR_WIFI_PASSWORD>";
const char* endpoint = "https://webhook.site/<WEBHOOK_ID>";

void setup() {
  Serial.begin(115200);
  delay(1000);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("\nConnecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Connected to WiFi");
}

void loop() {
  HTTPClient http;
  http.begin(endpoint);
  http.addHeader("Content-Type", "application/json");

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Error in WiFi connection");
  }

  String jsonPayload = "{\"status\":\"success\",\"message\":\"ping\"}";
  Serial.println(jsonPayload);
  int httpResponseCode = http.POST(jsonPayload);
  if (httpResponseCode > 0) {
    Serial.print("HTTP Response code: ");
    Serial.println(httpResponseCode);
    String response = http.getString();
    Serial.println(response);
  } else {
    Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpResponseCode).c_str());
  }
  http.end();
  delay(30000);
}

Conclusion

In this post, you learnt how to set up and test an ESP32 Wroom32 board. You learnt about board types, where to purchase boards, how to select the board on your Arduino IDE, and how to solve issues that may arise. Finally, and most importantly, you learnt how to set up a simple demo for immediately testing the Wifi functionality of your board.