After learning the basics of Wi-Fi connection, we may put it into practice based on ESP32-C3, and encapsulate the Wi-Fi features according to application requirements, so as to provide APIs for Wi-Fi initialisation and Wi-Fi connection initialisation.
This API specifies parameters for ESP32-C3, such as GPIO pins, fading time, breathing cycle, PWM frequency, clock source of the PWM controller, and PWM duty cycle resolution. For details, please refer to Chapter 5.
Before initialising Wi-Fi, it is necessary to initialise the NVS library as the Wi-Fi component needs to acquire and store certain parameters. The API is as follows:
This API handles LwIP and Wi-Fi events, and initialises Wi-Fi drivers.
This API implements Wi-Fi configuration, starts the Wi-Fi driver, and waits for Wi-Fi connection to complete.
📝 Source code
To code for Wi-Fi connection based on the LED dimming driver project, refer to
You may compile and run the code on the development board. The output is as follows:
I (397) wifi station: Application driver initialization I (397) gpio: GPIO| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (427) wifi station: NVS Flash initialization I (427) wifi station: Wi-Fi initialization I (547) wifi station: Wi-Fi Station initialization I (727) wifi station: wifi_station_initialize finished. I (6427) wifi station: connected to ap SSID:espressif password:espressif  Hello world!