The
ESP32 is the ideal choice of device for IoT projects in which data needs to be shared. It has custom built-in
WiFi hardware which is supported by the
ESP-IDF (Espressif IoT Development Framework), its own development environment. The fact that the ESP32 uses
FreeRTOS as standard also makes WiFi use, and asynchronous tasks in general, much easier. It also means that we can use sockets to implement communications protocols. To make full use of it, however, you must also understand the underlying components: the Lightweight Internet Protocol (
lwIP) and Mbed Transport Layer Security (
mbedTLS).
We start out with an examination of using FreeRTOS beyond the simple single-task program: using cores, scheduling, locks, synchronization and interrupts. A complete chapter is dedicated to exploring the different data structures that FreeRTOS provides for inter-task communication. Having mastered FreeRTOS, we turn our attention to basic WiFi in station mode. Then on to using lwIP to implement TCP/IP and DHCP. Sockets are key to implementing almost any network communications and an HTTP client is used as an example. We also look at the HTTP client component provided by the IDF. After implementing a client the next challenge is how to implement a server and methods that can be used to make a client stand in for a server.
Modern communication is almost always encrypted and this can prove difficult for IoT devices with limited power and memory. Before looking at how to implement HTTPS, we take a hands-on look at practical cryptography. Next we implement an HTTPS client using the standard certificate bundle. Of course, after the client, comes the server and this is a matter of supporting the appropriate encryption suites and certificates.
Going beyond HTTP, the next four chapters introduce UDP, SNTP, SMTP and MQTT in turn. The final chapter deals with some advanced topics: an AP that can be used to configure hardware; an AP that can connect its clients to the Internet; promiscuous mode packet sniffing; long range mode; ESP Now and ESP Mesh.
Harry Fairhead and Mike James are the co-authors of Master the Raspberry Pi Pico in C as well as introductory IoT titles for the ESP32, the Raspberry Pi Pico and the Raspberry Pi family. Both have written books on C. Fundamental C: Getting Closer To The Machine and Applying C For The IoT With Linux are by Harry, while Mike is the author of Deep C Dives and Extending and Embedding Python Using C.