A face recognition check-in module based on AI-Thinker's ESP32-CAM
This project combines the functionalities of ESP32-CAM with Python's face-recognition library for detecting and identifying faces in real time.
- 🛠 ESP32 Board Setup
- 🔌 Hardware Setup
- 💻 ESP32-CAM Programming
- 📥 Installation
- 🚀 Usage
- 🤝 Contributing
- 📄 License
Before proceeding with the hardware connection, ensure your Arduino IDE is properly configured for ESP32 development:
-
Configure Additional Board Manager URL:
- Navigate to "File" > "Preferences" (on macOS, "Arduino" > "Preferences").
- Locate the "Additional Boards Manager URLs" field.
- Click the icon next to the field to open the input window.
- Add the following URL on a new line:
https://dl.espressif.com/dl/package_esp32_index.json
- Click "OK" to save the changes and close the Preferences window.
-
Install ESP32 Board Support:
- Open the Boards Manager by selecting "Tools" > "Board" > "Boards Manager".
- In the search bar, type "esp32".
- Locate "esp32 by Espressif Systems" and click "Install".
- After installation, close the Boards Manager.
-
Select ESP32 Board:
- Go to "Tools" > "Board" and select your specific ESP32 board model from the list.
After completing these steps, your Arduino IDE will be ready for ESP32 development.
Before programming, connect your ESP32-CAM to an FTDI programmer as follows:
ESP32-CAM | FTDI Programmer |
---|---|
GND | GND |
5V | VCC |
U0R | TX |
U0T | RX |
GPIO0 | GND |
⚠️ Important: Short GPIO0 to GND to enter programming mode. Remove this connection after programming.
We have used OLED SSD1306 128x64 to display various statuses.
After uploading the code to ESP32-CAM:
- Remove the GPIO0 to GND connection.
- Connect OLED GND to ESP32-CAM GND.
- Connect OLED VCC to ESP32-CAM 3V.
- Press the reset button on ESP32-CAM.
The OLED should display "ESP32 Started!" 🎉
- Navigate to the
aithinker/src/
folder. - Open
esp32cam.ino
in Arduino IDE. - Add your Wi-Fi credentials:
static const char* WIFI_SSID = "your_wifi_name";
static const char* WIFI_PASS = "your_wifi_password";
- Upload the code to ESP32-CAM (ensure GPIO0 is connected to GND).
- After uploading, disconnect GPIO0 from GND and reset the board.
- Open the Serial Monitor to get the generated link.
- Clone this repository:
git clone https://github.com/ryukaizen/facelogger.git
cd facelogger
- Set up the ESP32-CAM as described in the Hardware Setup section.
- Install Python dependencies:
pip install -r requirements.txt
Before running the project, you need to set up some key variables in the main.py
file:
# In main.py
# Replace this with your own ESP32-CAM generated link (check aithinker folder)
ESP32_CAM_URL = 'http://192.168.52.160/640x480.jpg'
# Replace this with your own Google Form URL
GOOGLE_FORM_URL = "https://docs.google.com/forms/d/e/AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz/formResponse"
# Replace this with your own MongoDB URL
MONGODB_URL = 'mongodb://localhost:27017/'
# Inspect element on the Google Form and find the entry name ID and entry time ID
ENTRY_NAME_ID = 'entry.123456789'
ENTRY_TIME_ID = 'entry.987654321'
Ensure you replace these placeholder values with your actual URLs and IDs:
-
ESP32_CAM_URL
: The URL generated by your ESP32-CAM. You can find this in the Serial Monitor after uploading the code to your ESP32-CAM. -
GOOGLE_FORM_URL
: The URL of your Google Form where names and timestamps will be logged. -
MONGODB_URL
: The URL of your MongoDB instance. -
ENTRY_NAME_ID
andENTRY_TIME_ID
: These are specific to your Google Form. To find these:- Open your Google Form in a web browser
- Right-click and select "Inspect" or "Inspect Element"
- Look for input fields with names like "entry.123456789"
- The number after "entry." is your ID
⚠️ Note: Keep your Google Form URL and entry IDs private to prevent unauthorized access to your logging data.
- Program the ESP32-CAM and note the generated URL.
- Add face images into the
training_data
folder. Make sure those are in.jpeg
format and are of good quality. - Run the Python script:
python3 main.py
The system will now detect and recognize faces using the ESP32-CAM feed.
⚠️ Note: For the system to work properly, both the ESP32-CAM and the computer running the Python script must be on the same local network.
As always, contributions are welcome! Feel free to submit a PR. You can reach out to me on Telegram.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by ryukaizen