Welcome to MicroROS V2 Robot Car repository
19. ESP32 Visual Recognition Module
ESP32 Visual Recognition Module
Note: The camera comes from the factory with the factory firmware already flashed. If you have not flashed any other AI demo firmware, there is no need to flash the factory firmware again. The factory firmware of the camera is provided only as a bin file for flashing and does not include the program source code.
1. Connecting the ESP Camera to the Computer
Connect the computer and the ESP32 camera with a Type-C data cable,

2. Serial Port Configuration
Baud rate 115200, no parity, no hardware flow control, 1 stop bit
If you are using a serial assistant to configure, when sending commands, you should remove the auto-append newline (extra bit)
As shown in the figure: the display below indicates that the factory firmware has been flashed. If the following information does not appear, press the RESET button on the module.
Note: As shown in the figure, version V1.5.2 is the normal mode. If it is V1.5.1, it is the single-demo mode, which does not support all the commands in this tutorial. You can re-flash the V1.5.2 firmware.

2.1 Configuring WiFi Commands in STA Mode (LAN Connection Mode)
| Command | Description | Example | Remarks |
|---|---|---|---|
| sta_ssid: | WiFi name to connect to | sta_ssid:yahboom | yahboom: the WiFi to connect to |
| sta_pd: | WiFi password to connect to | sta_pd:12345678 | 12345678: the password of the WiFi to connect to |


Notes
- Whether it is sta_ssid or sta_pd, it must be followed by an English punctuation mark, such as comma (,), colon (:), period (.), etc.
- When the WiFi to connect to has no password, send sta_pd: once like this.
- The above commands will return OK on success. If OK is not returned, check: (1) Whether the module is in single-demo mode (YAHBOOM Board Ver:AI_V1.5.1). Version V1.5.1 is single-demo mode and has no network configuration function; you need to flash the factory firmware (V1.5.2 version) (2) Check the serial port wiring
- When sending the sta_ssid: command like this, it will return the string fail,ssid is null!, indicating that the WiFi name to connect to cannot be empty
- Commands can be sent entirely in uppercase or entirely in lowercase
- The WiFi name and password cannot exceed 30 characters in length, otherwise the configuration fails
- The WiFi name and password cannot contain Chinese characters
- Every time the WiFi password is changed, the module resets automatically. If only the WiFi name is changed, you need to manually power-cycle the module.
2.2 Configuring WiFi Commands in AP Mode (Module Self-Hosted Hotspot Mode)
| Command | Description | Example | Remarks |
|---|---|---|---|
| ap_ssid: | WiFi name to set | ap_ssid:my_wifi | my_wifi: the WiFi to set |
| ap_pd: | WiFi password to set | ap_pd:12345678 | 12345678: the password of the WiFi to set |
You can use the default hotspot name. The password can be left unset.
Notes
- Whether it is ap_ssid or ap_pd, it must be followed by an English punctuation mark, such as comma (,), colon (:), period (.), etc.
- When the WiFi to set has no password, send ap_pd: once like this.
- The above commands will return OK on success. If OK is not returned, check: (1) Whether the module is in single-demo mode (YAHBOOM Board Ver:AI_V1.5.1). Version V1.5.1 is single-demo mode and has no network configuration function; you need to flash the factory firmware (V1.5.2 version) (2) Check the serial port wiring
- When sending the ap_ssid: command like this, it will return the string fail,AP_Name is null!, indicating that the WiFi name to set cannot be empty
- Commands can be sent entirely in uppercase or entirely in lowercase
- The WiFi name and password cannot exceed 30 characters in length, otherwise the configuration fails
- The WiFi name and password cannot contain Chinese characters
- Every time the WiFi password is changed, the module resets automatically. If only the WiFi name is changed, you need to manually power-cycle the module.
2.3 Configuring the WiFi Mode
| Command | Description | Example | Remarks |
|---|---|---|---|
| wifi_mode: | Configure the WiFi mode | wifi_mode:2 | 0: AP mode 1: STA mode 2: AP+STA mode |

Notes
- wifi_mode must be followed by an English punctuation mark, such as comma (,), colon (:), period (.), etc.
- wifi_mode can only be set to 3 modes. If a negative number is passed, it defaults to AP mode; if a number greater than 2 is passed, it defaults to AP+STA mode
- The above command will return OK on success. If OK is not returned, check: (1) Whether the module is in single-demo mode (YAHBOOM Board Ver:AI_V1.5.1). Version V1.5.1 is single-demo mode and has no network configuration function; you need to flash the factory firmware (V1.5.2 version) (2) Check the serial port wiring
2.4 Setting the AI Mode
| Command | Description | Example | Remarks |
|---|---|---|---|
| ai_mode: | Configure the AI recognition mode | ai_mode:0 | 0: Normal mode 1: Cat/dog detection 2: Face detection 3: Color recognition 4: Face recognition 5: QR code recognition |

After modifying the ai_mode, the module resets.
Notes
- ai_mode must be followed by an English punctuation mark, such as comma (,), colon (:), period (.), etc.
- ai_mode can only be set to 5 modes. If an illegal number is passed, it defaults to the normal mode.
- Every time the mode is changed, the image transmission module restarts automatically. After the module restarts successfully, you need to refresh the webpage or re-enter the phone app
- ai_mode: can also be sent in all-uppercase English as AI_MODE:
- Factory firmware mode: the default is the normal mode.
- In face recognition mode, the Type-C serial port configuration and network transparent transmission functions become unavailable, mainly because there is not enough space to create the tasks. If you need these functions, do not use face recognition mode; face detection mode works normally.
2.5 Reading the IP Address
| sta_ip | Query the sta-mode IP address | sta_ip | Returns the IP address connected to the LAN (e.g., sta_ip:192.168.2.111) |
|---|---|---|---|
| ap_ip | Query the ap-mode IP address | ap_ip | Returns the IP address of the module's own WiFi hotspot (e.g., ap_ip:192.168.4.1) |


3. Viewing the Image in a Browser
3.1 Remote Viewing over the LAN
Now that we know the sta_ip (192.168.2.105) obtained by the module when it connects to the LAN, we can use this IP to view the real-time image on the network,

Click start stream to view the image,

Because the face detection mode (ai_mode:2) was just set, placing a face in front of the camera can be recognized normally,

3.2 Remote Viewing via the Module Hotspot
Connect the computer to the module's hotspot

Open a browser and enter the IP address 192.168.4.1. This address is the fixed address of the hotspot,

Click start stream to view the image,

Because the face detection mode (ai_mode:2) was just set, placing a face in front of the camera can be recognized normally, (other AI modes can be configured by yourself)
