Book Image

Internet of Things Projects with ESP32

By : Agus Kurniawan
Book Image

Internet of Things Projects with ESP32

By: Agus Kurniawan

Overview of this book

ESP32 is a low-cost MCU with integrated Wi-Fi and BLE. Various modules and development boards-based on ESP32 are available for building IoT applications easily. Wi-Fi and BLE are a common network stack in the Internet of Things application. These network modules can leverage your business and projects needs for cost-effective benefits. This book will serve as a fundamental guide for developing an ESP32 program. We will start with GPIO programming involving some sensor devices. Then we will study ESP32 development by building a number of IoT projects, such as weather stations, sensor loggers, smart homes, Wi-Fi cams and Wi-Fi wardriving. Lastly, we will enable ESP32 boards to execute interactions with mobile applications and cloud servers such as AWS. By the end of this book, you will be up and running with various IoT project-based ESP32 chip.
Table of Contents (12 chapters)

Connecting to an existing Wi-Fi network

In this section, we will be connecting to an existing Wi-Fi network. You should prepare a Wi-Fi hotspot for demo purposes. For Wi-Fi security, we will use WPA/WPA2 on an existing Wi-Fi network. Since we are using WPA/WPA2 authentication mode, we need the SSID name and SSID key from your Wi-Fi hotspot in order to join this Wi-Fi network.

We can now start to create a project called wificonnect. In the main entry, the app_main() function, we call the connect_to_wifi() function. The connect_to_wifi() function is the function that connects to existing Wi-Fi networks:

void app_main()
//Initialize NVS
esp_err_t ret = nvs_flash_init();
ret = nvs_flash_init();