- Mobile App / Website (Deployed Link): Crowd Watch Pro
- Jupyter Notebook (Google Colab Link): Notebook Link
- ESP32-CAM
- Charging Module
- Micro USB Cable
- Rechargeable Battery
This project turns an ESP32-CAM into an automated monitoring camera. It captures an image at a set interval and uploads it via Wi-Fi to a Python Flask server, which saves the image to a local directory. It's a great starting point for projects like remote stall monitoring, security cameras, or time-lapse photography.
- Automated Image Capture: Captures photos every few seconds (interval is configurable in the
index.htmlfile). - Wi-Fi Communication: The camera communicates with a local server over your Wi-Fi network.
- Image Server: A lightweight Python Flask server receives and stores images chronologically.
- Simple Web UI: A web-based user interface, served by the ESP32, displays the system status and the most recent capture.
The system consists of two main components that must be on the same Wi-Fi network:
- The ESP32-CAM: This device serves a webpage and acts as a client. The JavaScript on its webpage commands it to capture an image and then sends that image to the Python server's IP address.
- The Python Server: This application runs on a computer (e.g., a Mac, Windows PC, or Raspberry Pi). It listens for incoming image data at an
/uploadendpoint and saves the files to a localuploadsfolder.
- Arduino IDE
- ESP32 Board Support for Arduino IDE
- Python 3
- Flask (
pip install Flask)
Follow these steps in order to get the system running.
-
Install Flask: Open a terminal or command prompt and run:
pip3 install Flask
-
Find Your IP Address: Find your computer's local IP address.
- On Mac/Linux:
ipconfig getifaddr en0orhostname -I - On Windows:
ipconfig(Look for the "IPv4 Address" under your Wi-Fi adapter) - Take note of this IP address (e.g.,
192.168.1.10).
- On Mac/Linux:
-
Run the Server: In the terminal, navigate to the project directory and run the server:
python3 server.py
Leave this terminal window open. It will now listen for incoming images.
-
Configure the Sketch:
- Open the
CameraWebServer_.inofile in the Arduino IDE. - Update the file with your Wi-Fi network name and password:
const char* ssid = "YOUR_WIFI_NETWORK_NAME"; const char* password = "YOUR_WIFI_PASSWORD";
- Ensure the correct camera model is selected (e.g.,
#define CAMERA_MODEL_AI_THINKER).
- Open the
-
Update the Webpage IP Address:
- Open the
index.htmlfile in a text editor. - Find the
uploadUrlvariable and replace the placeholder with the IP address of your computer (from Part 1, Step 2). Remember to include the port number (:5001) and the/uploadpath.// Change this line to your computer's IP address const uploadUrl = '[http://192.168.1.10:5001/upload](http://192.168.1.10:5001/upload)';
- Open the
-
Convert the Webpage:
- After saving your changes to
index.html, you must convert it to a C++ header file. - In a terminal, navigate to the folder containing
index.htmland run:gzip -c index.html | xxd -i > camera_index.h
- After saving your changes to
-
Upload to ESP32:
- Move the newly generated
camera_index.hfile into your Arduino sketch folder, replacing the old one. - Connect the ESP32-CAM to your computer via the FTDI programmer.
- Select the correct board (AI-Thinker ESP32-CAM) and Port in the Arduino IDE.
- Click Upload.
- Move the newly generated
- Start the Python server on your computer.
- Power on the ESP32-CAM.
- The ESP32-CAM will automatically connect to your Wi-Fi and begin capturing and sending images.
- Check the
uploadsfolder on your computer to see the saved images appearing.
-
Q: The Python server won't start and says "Address already in use" or "Port 5000 is in use".
- A: On macOS, the AirPlay Receiver service often uses port 5000. You can either disable it in System Settings > General > AirDrop & Handoff, or change the port in
server.py(e.g., toport=5001) and make sure to update it inindex.htmlas well.
- A: On macOS, the AirPlay Receiver service often uses port 5000. You can either disable it in System Settings > General > AirDrop & Handoff, or change the port in
-
Q: The webpage shows a "Not Found" or "Failed to fetch" error.
- A: This usually means the IP address in
index.htmlis incorrect, the ESP32 is not on the same Wi-Fi network as the server, or your computer's firewall is blocking the connection. Double-check the IP and the firewall settings.
- A: This usually means the IP address in
This project is licensed under the MIT License. See the LICENSE file for details.
