Internet of Things Projects with ESP32
Build exciting and powerful IoT projects using the all-new Espressif ESP32
- 252 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Internet of Things Projects with ESP32
Build exciting and powerful IoT projects using the all-new Espressif ESP32
About This Book
Create and program Internet of Things projects using the Espressif ESP32.
Key Features
- Getting to know the all new powerful EPS32 boards and build interesting Internet of Things projects
- Configure your ESP32 to the cloud technologies and explore the networkable modules that will be utilised in your IoT projects
- A step-by-step guide that teaches you the basic to advanced IoT concepts with ESP32
Book Description
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.
What you will learn
- Understand how to build a sensor monitoring logger
- Create a weather station to sense temperature and humidity using ESP32
- Build your own W-iFi wardriving with ESP32. Use BLE to make interactions between ESP32 and Android
- Understand how to create connections to interact between ESP32 and mobile applications
- Learn how to interact between ESP32 boards and cloud servers
- Build an IoT Application-based ESP32 board
Who this book is for
This book is for those who want to build a powerful and inexpensive IoT projects using the ESP32.Also for those who are new to IoT, or those who already have experience with other platforms such as Arduino, ESP8266, and Raspberry Pi.
Frequently asked questions
Information
Controlling IoT Devices over the Internet
- Connecting to an internet network via ESP32
- Accessing data from a web server
- Building a web server inside ESP32
- Making a smart home application
Technical requirements
- A computer with an OS installed, such as Windows, Linux, or macOS.
- An ESP32 development board. We recommend the ESP-WROVER-KIT v4 board from Espressif.
- A Wi-Fi network with internet access capability.
Introducing ESP32 Wi-Fi development
#include "esp_wifi.h"
Scanning Wi-Fi hotspot
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
wifi_scan_config_t scanConf = {
.ssid = NULL,
.bssid = NULL,
.channel = 0,
.show_hidden = true
};
while(true){
ESP_ERROR_CHECK(esp_wifi_scan_start(&scanConf, true));
vTaskDelay(3000 / portTICK_PERIOD_MS);
}
esp_err_t event_handler(void *ctx, system_event_t *event)
{
if (event->event_id == SYSTEM_EVENT_SCAN_DONE) {
uint16_t apCount = 0;
esp_wifi_scan_get_ap_num(&apCount);
printf("Wi-Fi found: %d\n",event->event_info.scan_done.number);
if (apCount == 0) {
return ESP_OK;
}
wifi_ap_record_t *wifi = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, wifi));
....
}
for (int i=0; i<apCount; i++) {
char *authmode;
switch(wifi[i].authmode) {
case WIFI_AUTH_OPEN:
authmode = "NO AUTH";
break;
case WIFI_AUTH_WEP:
authmode = "WEP";
break;
case WIFI_AUTH_WPA_PSK:
authmode = "WPA PSK";
break;
case WIFI_AUTH_WPA2_PSK:
authmode = "WPA2 PSK";
break;
case WIFI_AUTH_WPA_WPA2_PSK:
authm...
Table of contents
- Title Page
- Copyright and Credits
- About Packt
- Contributors
- Preface
- Getting Started with ESP32
- Making Visual Data and Animation on an LCD
- Building a Simple Game with an Embedded ESP32 Board
- Building a Sensor Monitoring Logger
- Controlling IoT Devices over the Internet
- Building an IoT Weather Station
- Making Your Own Wi-Fi Wardriving
- Building Your Own Wi-Fi Cam
- Making IoT Devices Interact with Mobile Applications
- Building IoT Monitoring with Cloud Technology
- Other Books You May Enjoy