Introduction: ESP32 CAM Face Recognition With MQTT Support | AI-Thinker


I wanted to share my code for a project were I needed to have an ESP CAM with Face recognition, that could send out Data to MQTT. So well.. after maybe 7 Hours of looking trough multiple code examples and looking for what is what, I have finished the MQTT integration!


What you need:

Step 1: Setting Up the TTL Programmer (OPTIONAL)

If you are using a Computer, that has a newer version than Windows 7, you most likely need the supported drivers for the programmer.

If the device is not able to start, then I recommend you this easy tutorial to install the drivers manually

Step 2: Setting Up the Connection and Configuring in the IDE

You need to wire it like in the picture (It is better to use 5v instead of 3v!)

The grey cable is only needed to be connected if you want to program it!

I am assuming you already have the ESP32 package installed, if so you need to roll the version back, from whatever you are using currently to version 1.01 this step is necessary for the Face recognition, otherwise it will not work!

The next step is to go into TOOLS in your IDE and set Partition Scheme to Huge APP, and select ESP32 Wrover Module as the Board!

Step 3: Code and Libraries

You will only need the PubSubClient Library, all other libraries are automatically installed.

(Don´t forget to change your credentials before uploading)

Download the attachment and click upload don´t forget the grey Cable mentioned above!

After Upload open the Serial Monitor and select 115200 as baud rate.

You should see a IP address to connect to. NOTE: The face recognition is already enabled at start, so it will scan your face! EDIT: It will NOT automatically do that anymore!

On the MQTT part you should see an info tab and one face tab. EDIT: And id tab

Step 4: That´s It | EDIT

This is it for now, I think I will be updating it some time if I see bugs or any other thing.

I hope you enjoyed!


I have made some changes to the code!

It now saves your Face in internal memory, so when you start it up, it will load all previously saved faces from Flash!

It automatically saves enrolled faces to Flash.

I also removed the auto Enroll face on startup.

I have made a new MQTT Topic called "id", this is where it shows the last ID recognized!