banner
News center
We implement a flawless quality system to ensure excellent product output.

Programming The ESP32 In C - Socket Web Client

Oct 23, 2024

The ESP32 S3 has WiFi but getting from a simple connection to a web client is a matter of using sockets. This is an extract from Harry Fairhead's latest book on programming the ESP32 using C and the IDF.

Available as a softback, hardback and kindle from Amazon

Preface

<ASIN:1871962919>

<ASIN:187196282X>

The ESP32 comes complete with a radio capable of 2.4GHz WiFi and Bluetooth. Most of the time you can ignore the technical details as there are easy-to-use functions which enable you to connect to a WiFi network and exchange data. In this chapter we look at the basics and how to create and use a WiFi connection. The libraries involved are many and extensive due to the need to cover a wide range of different protocols. A consequence is that there is no way to cover all of them in a reasonable space. This chapter is about getting started and understanding the basic structure of the WiFi and IP infrastructures. When you understand this the rest of the API becomes much easier to understand. The topic of Bluetooth is omitted as it is so varied that it deserves a book to itself.

Connecting to WiFi is a standard operation and it makes sense to package it in a function. The status of the WiFi connection is communicated to the calling program via a shared static variable.

To make the following examples easier to work with, it is reasonable to put the connect functions into a header file wificonnect.h:

PrefaceThe ESP32 – Before We BeginGetting Started Getting Started With The GPIO Simple OutputSome ElectronicsSimple InputAdvanced Input – InterruptsPulse Width ModulationControlling Motors And ServosGetting Started With The SPI BusUsing Analog SensorsUsing The I2C BusOne-Wire Protocols The Serial PortUsing WiFi ***NEW!Direct To The HardwareFree RTOS