An ESP32 + ESP32‐CAM + Python OCR system with Blynk integration for smart gate control and logging.
Python Arduino ESP32 Blynk License: MIT
Personal IoT project integrating ESP32, ESP32-CAM, and a Python OCR Flask server, connected to Blynk for control and telemetry. ESP32 detects a vehicle, triggers ESP32‐CAM to capture, ESP32‐CAM POSTs the image to Flask for OCR, results are logged to Google Sheets/Drive and sent back to ESP32 to drive the gate servo.
tanawa-demo.mp4
- ESP32 telemetry and control: Ultrasonic detection, buzzer/LED alerts, gate servo.
- ESP32‐CAM image capture: On-demand capture endpoint that forwards frames to the server.
- Python OCR server: Flask endpoint runs Tesseract OCR, uploads to Google Drive, logs to Google Sheets.
- Blynk integration: Virtual pins dashboard and notification on detection.
- Hardware: ESP32, ESP32‐CAM (AI Thinker)
- Cloud/App: Blynk (cloud + mobile app)
- Firmware: Arduino/PlatformIO (C/C++)
- Server: Python 3.x, Flask, Tesseract OCR, Google Sheets/Drive APIs
- ESP32: detects vehicle; on detection sends
GET /captureto ESP32‐CAM; receives OCR viaGET /receive_text?text=.... - ESP32‐CAM: handles
GET /capture, takes a snapshot and POSTs raw JPEG to FlaskPOST /capture. - Flask OCR server: saves image, runs OCR, overlays text, uploads to Google Drive, appends to Google Sheets, notifies ESP32.
- Blynk: dashboard via virtual pins and an optional
vehicle_detectedevent.
- ESP32‐CAM (port 80):
GET /capture - Flask (port 5000):
POST /capture,GET /uploads/latest_vehicle_annotated.jpg - ESP32 (port 80):
GET /receive_text?text=ABC123
firmware/
esp32/
main.ino
esp32-cam/
main.ino
camera_pins.h
scripts/
python/
main.py
requirements.txt
screenshots/
demo.gif
system-circuit-design.png
- Hardware: ESP32 dev board, ESP32‐CAM (OV2640), ultrasonic sensor, servo, buzzer/LED, USB‐TTL as needed.
- Software:
- Arduino IDE (or PlatformIO) with ESP32 board support
- Blynk account/app and device
BLYNK_AUTH_TOKEN - Python 3.9+ (recommended), Tesseract OCR installed
- Create a device in Blynk Cloud and get
BLYNK_AUTH_TOKEN. - Virtual pins used by the firmware:
V0: timestamp textV1: OCR plate textV2: servo mode switch (0°/90°)V3: manual capture trigger
- Optional event:
vehicle_detectedfor notifications.
- ESP32 (
firmware/esp32/main.ino): setssid,password, andBLYNK_AUTH_TOKEN. - ESP32‐CAM (
firmware/esp32-cam/main.ino): set Wi‐Fi creds andflaskServerUrl(host:port of Flask). - Build and upload each sketch using Arduino IDE or PlatformIO.
Install Tesseract OCR (update the path in scripts/python/main.py if different). Place your Google service account credentials.json in repo root.
python -m venv .venv .venv\Scripts\activate pip install -r scripts\python\requirements.txt python scripts\python\main.py
Do not commit secrets. Keep
credentials.json,.env, and Arduinosecrets.hout of git. Usescripts/python/example.envas a template for your local.envand createsecrets.h.examplefiles for Arduino credentials.
- Start the Flask OCR server on a reachable host (
POST /captureon port 5000). - Power the ESP32‐CAM; test
http://<esp32-cam-ip>/captureto verify capture + POST. - Power the ESP32; it will trigger capture on detection and receive OCR via
/receive_text. - Use the Blynk app to view time (
V0), plate text (V1), toggle servo (V2), trigger manual capture (V3).
- Match all IPs/ports across ESP32, ESP32‐CAM, and Flask server.
- Verify Blynk token, Wi‐Fi credentials, and virtual pin mapping.
- Confirm Tesseract installation path and Google API credentials/permissions.
- If capture fails, reduce ESP32‐CAM
frame_sizeor ensure PSRAM is available.
This project is licensed under the MIT License. See LICENSE for details.
Reno-03 and Aru (2025)