0% found this document useful (0 votes)
6 views

7.2 ESP32S3-Cam Library File Introduction

The document introduces the ESP32-S3 drive library, which facilitates data acquisition for face and color recognition using the ESP32-S3 module. It details the initialization of the I2C bus and various functions for data transmission and reception, including sending and reading multi-byte data. Additionally, it emphasizes the importance of calling specific initialization functions before using the library's features.

Uploaded by

Ywhite Eric
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

7.2 ESP32S3-Cam Library File Introduction

The document introduces the ESP32-S3 drive library, which facilitates data acquisition for face and color recognition using the ESP32-S3 module. It details the initialization of the I2C bus and various functions for data transmission and reception, including sending and reading multi-byte data. Additionally, it emphasizes the importance of calling specific initialization functions before using the library's features.

Uploaded by

Ywhite Eric
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ESP32-S3 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.

2) In the program, select “hw_esp32cam_ctl.cpp”.

2. Library File Instruction

2.1 Member Function (HW_ESP32S3CAM::Init)

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.

2.2 Underlying Function (Wire_Write_Data_Array)

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.

2.3 Underlying Function (Wire_Write_Byte)

Wire_Write_Byte()

Function Before reading data from the ESP32-S3 vision module,


Description confirm the address of the data register to be read.

False:transmission
Return failed;
Parameter List val
Value True:transmission
succeeded.

1) Call “HW_ESP32S3CAM::Init” before using this function.

Instructions for When transferring or writing data, it is necessary to

Use confirm the address of the data register to be written to the


slave. The same implementation statement of this function
can be found in “Wire_Write_Data_Array”.

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.

2.4 Underlying Function (Wire_Read_Data_Array)

Wire_Read_Data_Array()

Function Read multi-byte data from the esp32-S3 vision module


Description through the I2C bus.

-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”).

2.5 Member Function

(HW_ESP32S3CAM::Facedetection_Data_Receive)

HW_ESP32S3CAM::Facedetection_Data_Receive()

Function Read face recognition result from the ESP32-S3 vision


Description module.

Parameter List Reg, buf, and buf_len Return Value None

Essentially, it encapsulates the direct calling of the


Instructions for
“Wire_Read_Data_Array”. Its specific parameters’
Use
physical meanings are the same as the

5
“Wire_Read_Data_Array”.

The implementation of color recognition and line following is highly consistent


with that of face recognition. You can refer to the source code and the “Device
Master-Slave Communication Principle” discussed below to learn about the
physical meanings of the information stored in each address of the various
functional registers of the vision module.

3. Master-Slave Device Communication Principle (Module

I2C Register)
ESP32S3 vision module I2C slave data address: 0x53
Note: For more detailed information, please refer to the relevant tutorials.

You might also like