Blog Datasheets Home About me Clients My work Services Contact

G2Labs Grzegorz Grzęda

Overview of ESP32 Development Tools

September 2, 2024

Overview of ESP32 Development Tools

The ESP32 is a powerful and versatile microcontroller that is widely used in IoT and embedded systems development. In order to effectively develop applications for the ESP32, it is essential to have a good understanding of the development tools and resources available. In this blog post, we will provide an overview of the most commonly used ESP32 development tools, along with examples and explanations to help you get started with ESP32 development.

1. ESP-IDF (Espressif IoT Development Framework)

The ESP-IDF is the official development framework provided by Espressif for the ESP32 microcontroller. It includes a rich set of libraries and tools for building IoT applications. The ESP-IDF is based on FreeRTOS, a popular real-time operating system, and provides comprehensive APIs for tasks, queues, timers, and more. Additionally, the ESP-IDF provides tools for building, flashing, and monitoring applications on the ESP32.

Example: Blinking LED using ESP-IDF

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

void app_main()
{
    gpio_config_t io_config = {
        .pin_bit_mask = (1ULL << GPIO_NUM_2),
        .mode = GPIO_MODE_OUTPUT
    };
    gpio_config(&io_config);
    
    while(1) {
        gpio_set_level(GPIO_NUM_2, 1);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        gpio_set_level(GPIO_NUM_2, 0);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

In this example, we have used the ESP-IDF to blink an LED connected to GPIO pin 2 of the ESP32.

2. Arduino IDE with ESP32 Core

The Arduino IDE is a popular development environment for microcontrollers, and it can be extended to support the ESP32 through the installation of the ESP32 core. Once installed, the Arduino IDE provides a familiar and easy-to-use interface for developing applications for the ESP32. It also includes a rich set of libraries and examples that can be used to quickly prototype IoT applications.

Example: Temperature and Humidity Monitoring using Arduino IDE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" *C");

  delay(2000);
}

In this example, we have used the Arduino IDE and the DHT sensor library to monitor temperature and humidity using a DHT11 sensor connected to GPIO pin 2 of the ESP32.

3. PlatformIO

PlatformIO is an open-source ecosystem for IoT development that supports a wide range of microcontroller platforms, including the ESP32. It provides a unified development experience across different IDEs such as Visual Studio Code and Atom. PlatformIO includes a powerful build system, library manager, and integration with popular version control tools.

Example: Wi-Fi Web Server using PlatformIO

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <WiFi.h>
#include <WebServer.h>

const char* ssid = "your-ssid";
const char* password = "your-password";

WebServer server(80);

void handleRoot() {
  server.send(200, "text/plain", "Hello from ESP32!");
}

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");

  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();
}

In this example, we have used PlatformIO to create a simple web server that runs on the ESP32 and serves a “Hello from ESP32!” message to clients connected to its Wi-Fi network.

Conclusion

In this blog post, we have provided an overview of the most commonly used ESP32 development tools, including the ESP-IDF, Arduino IDE with ESP32 Core, and PlatformIO. We have also included examples and explanations to help you get started with ESP32 development. Whether you prefer a low-level approach with the ESP-IDF or a more user-friendly experience with the Arduino IDE or PlatformIO, there are plenty of resources available to support your ESP32 development journey. Happy coding!


⬅️ Advanced C Programming Techniques: Pointers to Functions


Go back to Posts.