WiFi networking

1. Experimental purpose

Use the ESP32S3 core module of the microROS control board to learn the function of ESP32 connecting to WiFi.

 

2. Hardware connection

As shown in the figure below, the microROS control board integrates the ESP32-S3-WROOM core module, which has its own wireless WiFi function. The ESP32-S3 core module needs to be connected to an antenna, and a type-C data cable needs to be connected to the computer and the microROS control board as Burn firmware function.

image-20240112174901940

 

3. Core code analysis

The virtual machine path corresponding to the program source code is as follows

First, get the WiFi name and password to connect from the IDF configuration tool.

Initialize WiFi to STA mode, and configure the WiFi hotspot name, password, etc. to be connected.

Try to connect to the WiFi hotspot. If the connection is successful, go to the next step. If the connection is not successful after exceeding the number of times, it will automatically exit.

Initialize the WiFi network connection in the app_main function and enable the function of connecting to WiFi.

 

4. Compile, download and flash firmware

Use a Type-C data cable to connect the virtual machine/computer and the microROS control board. If the system pops up, choose to connect to the virtual machine.

Activate the ESP-IDF development environment. Note that every time you open a new terminal, you need to activate the ESP-IDF development environment before compiling the firmware.

Enter the project directory

Open the ESP-IDF configuration tool.

Open Example Configuration and fill in your WiFi name and password in the WiFi SSID and WiFi Password fields.

image-20240115162027559

After modification, press S to save, and then press Q to exit the configuration tool.

Compile, flash, and open the serial port simulator

If you need to exit the serial port simulator, press Ctrl+].

 

5. Experimental results

The serial port simulator prints the "hello yahboom" greeting and tries to connect to the WiFi hotspot. As shown in the figure below, if the connection is successful, the name and password of the hotspot with successful connection will be printed.

image-20240115161717576

If the connection attempt fails more than a certain number of times, a failure will be reported and the connection will be terminated.

image-20240115164120570