7.2 ESP32S3-Cam Library File Introduction
7.2 ESP32S3-Cam Library File Introduction
This section explains the analysis for the drive library of the ESP32-S3 module.
This library is used to obtain data on recognized face or color from the
ESP32-S3. It includes two files “hw_esp32S3cam_ctl.h” and
“hw_esp32S3cam_ctl.cpp”.
1. Getting Ready
1) Open any program in the path of the “1.Tutorial\5.AI Vision Games Lesson”.
Take “5.4 Color Recognition” as an example.
The function initializes the configuration of the I2C bus. This allows that
commands can be sent and data can be received from the vision module
1
through the bus in the following steps.
Wire_Write_Data_Array()
Function Send data to the ESP32-S3 vision module register
Description through the I2C bus.
False:write failed;
Parameter List Addr, reg, val, and len Return Value True:write
succeeded.
Call “HW_ESP32S3CAM::Init” before using this function.
Instructions for
This function is not used in the subsequent development.
Use
You can just know it.
Parameters:
addr: esp32-S3 device address(0x53)
reg: save the address within esp32-S3 written target
*val: send-needing data address
2
len: send-needing word length
The Arduino master sends the device address via I2C first and the target
memory address to ESP32-S3. Then it sends the data by bytes according to
the data length. Next, it checks if the data has been successfully transmitted
using “endTransmission()”. If the return value is 0, it indicates successful data
transmission; otherwise, it is fail to send.
Wire_Write_Byte()
False:transmission
Return failed;
Parameter List val
Value True:transmission
succeeded.
3
Parameter:
val: content of the sent data
The Arduino master directly sends the device address and the data content of
the 1 byte to ESP32-S3. The “endTransmission()” checks the data sent
successfully or not. If the return value is 0, the data is sent successfully.
Otherwise it is sent unsuccessfully.
Wire_Read_Data_Array()
-1 : read failed;
Other: the length
Parameter List Reg, val, and len Return Value
of the data
successfully read.
Instructions for
Call “HW_ESP32S3CAM::Init” before using this function.
Use
4
Call “Wire_Write_Byte” to confirm the address of the
register to be read before using this function.
Parameters:
val: the address used for saving the data in Arduino master
len: Length of data to be read
The Arduino master first sends the address of the data to be read to ESP32-S3.
If there is no response, it returns -1, indicating a failed connection. Then, it
sends the length of data to esp32-S3, and reads the data in bytes via the
“while” loop and the “i” variables to store in the “val[ ]” array. During the reading
process, if the actual read length exceeds the needed length, it returns to -1,
indicating a reading failure. Finally, upon successful reading, it returns “i”,
which represents the actual length of data read (where “i” may be less than or
equal to “len”).
(HW_ESP32S3CAM::Facedetection_Data_Receive)
HW_ESP32S3CAM::Facedetection_Data_Receive()
5
“Wire_Read_Data_Array”.
I2C Register)
ESP32S3 vision module I2C slave data address: 0x53
Note: For more detailed information, please refer to the relevant tutorials.