Inspiration The idea came from wanting to create a comprehensive IoT access control system that goes beyond simple door locks. I wanted to integrate multiple safety features: automated obstacle detection for preventing accidents, environmental monitoring for fire/humidity alerts, IR remote and emergency button access, AI-powered chatbot assistance, and seamless remote management with web dashboard—all on a single microcontroller platform.

What it does The ESP32 Smart Door Control System is a multi-functional access control solution featuring:

  • IR remote control for door unlock (OK button), LED toggle (* button), and fan toggle (# button)
  • Emergency exit button that opens the door for a configurable duration (default 10 seconds)
  • Automated servo lock mechanism (configurable angles: default 0° closed, 90° open)
  • Ultrasonic obstacle detection that auto-activates lighting when someone approaches (threshold configurable, default 10 cm)
  • Real-time temperature & humidity monitoring with configurable alert thresholds (default 30°C temp, 70% humidity; auto-opens door at 85°C or 85%)
  • WiFi-enabled web dashboard with real-time WebSocket updates, controls, settings, AI chat, about, and contact tabs
  • AI chatbot assistant using Google Gemini for natural language queries and commands (e.g., /open, /led on)
  • Voice input support for chatbot via browser speech recognition
  • Visual feedback via 20x4 I2C LCD display showing system status, sensor data, alerts, countdown timer, LED/fan status
  • Audio alerts through active buzzer for access events, door open, and temp/humidity alerts with different beep patterns
  • Relay-controlled lighting (auto-on with obstacle)
  • Status LED with blinking patterns (rapid flash when door open)
  • Toggle LED and PWM-controlled DC fan with physical buttons and remote/web control
  • Data logging (up to 100 entries) with CSV export via web
  • Email alerts via Formspree for temp/humidity thresholds (with 5-minute cooldown)

How we built it Hardware Integration:

  • ESP32-WROOM-32 as the central controller (dual-core Tensilica LX6 @ 240MHz)
  • HC-SR04 ultrasonic sensor for distance detection (trig GPIO19, echo GPIO18)
  • DHT22 sensor for precise temperature (±0.5°C) and humidity (±2% RH) measurements (data GPIO25 with 4.7kΩ-10kΩ pull-up)
  • SG90 servo motor controlled via PWM for lock mechanism (GPIO26)
  • 5V relay module for automated lighting control (GPIO27)
  • IR receiver for remote control (GPIO14)
  • Emergency exit button (GPIO34, active LOW with pull-up)
  • Active buzzer for alerts (GPIO15)
  • Status LED (GPIO5)
  • 20x4 I2C LCD for real-time status display (address 0x27, SDA GPIO21, SCL GPIO22)
  • Toggle LED (GPIO13) with button (GPIO35, pull-up)
  • DC fan motor with PWM (GPIO32, channel 8, 25kHz freq)
  • Fan button (GPIO23, pull-up)

Software Architecture:

  • Developed in Arduino C++ using ESP32 core libraries
  • AsyncWebServer and AsyncTCP for non-blocking web interface with WebSocket (/ws)
  • IRremote library for IR decoding (updated to new version)
  • DHT library for sensor reading with rate limiting (every 2 seconds)
  • ESP32Servo for servo control
  • LiquidCrystal_I2C (ESP32-compatible) for LCD
  • Preferences for persistent storage of configurable settings (thresholds, angles, timing, API keys)
  • HTTPClient for Formspree email alerts
  • Multi-threading utilizing FreeRTOS tasks on both ESP32 cores
  • State machine for door control (manual, auto-ventilation modes)
  • Debouncing for buttons (50ms delay)
  • Data logging in circular buffer with CSV generation
  • AI integration via Gemini API in web client (generateContent endpoint)
  • Voice recognition using Web Speech API in browser
  • WiFi AP mode (SSID: ESP32SEG, password: letmeinplease)

Key Technical Implementations:

  • Custom handling for DHT22 with timestamp-based interval checks
  • Proper pull-up configurations (e.g., 4.7kΩ on DHT data, external 10kΩ on buttons)
  • Power budgeting to avoid brownouts (separate power for actuators)
  • Ultrasonic pulse timing with timeout (30ms) and distance calculation (temperature-compensated implicitly via stable readings)
  • Responsive HTML/CSS/JS web dashboard with tabs, real-time updates via WebSocket, AJAX, toast notifications
  • Command parsing in chatbot for system control (e.g., regex matching for /open, /fan on)
  • Different buzzer patterns: fast for door open, slow for alerts, rapid for multiple, continuous for manual
  • LCD optimization: update only changed lines, periodic backlight refresh
  • Settings persistence and API key management (Gemini, Formspree)

Challenges we ran into

  1. Voltage level compatibility: HC-SR04 outputs 5V ECHO signal, but ESP32 GPIO is only 3.3V tolerant. Solved with precision voltage divider (1kΩ + 2kΩ resistors).

  2. Power consumption: Initial design tried powering servo and relay from ESP32's 3.3V rail, causing brownouts. Redesigned power distribution using VIN (5V USB) rail with proper current budgeting.

  3. DHT22 timing sensitivity: Sensor requires minimum 2-second intervals between reads. Implemented timestamp-based rate limiting to prevent corrupt readings.

  4. Ultrasonic noise: Raw HC-SR04 readings showed spurious spikes. Implemented timeout and default to 999cm on failure (median filter from original retained conceptually).

  5. Web server blocking: Initial synchronous web server caused main loop delays. Switched to AsyncWebServer for true non-blocking operation.

  6. Memory constraints: ESP32's 520KB SRAM filled quickly with large web pages and data log. Optimized HTML/CSS, used PROGMEM for static strings, implemented chunked HTTP responses, and limited log to 100 entries.

  7. IR library compatibility: Updated to new IRremote.hpp for better decoding and repeat flag handling.

  8. PWM channel conflicts: Servo and fan PWM conflicted; reassigned fan to channel 8.

  9. Browser voice recognition: Handled browser support checks and error states for Web Speech API.

  10. Alert spam prevention: Added 5-minute cooldown for email alerts and edge detection for state changes.

Accomplishments that we're proud of

  • Successfully integrated over 10 different components (sensors, actuators, displays, buttons, remote) on a single microcontroller
  • Achieved robust door control with multiple modes: manual (button/IR/web/AI), auto-ventilation with no timer
  • Designed a professional-grade web dashboard with tabbed interface, real-time updates, voice-enabled AI chatbot, and CSV export
  • Implemented AI assistance with natural language and command parsing, integrated with system status
  • Created configurable system with web-based settings for thresholds, angles, timing, and API keys
  • Added voice control and email notifications for enhanced usability
  • Implemented data logging and export for analysis
  • Maintained modular code architecture for easy feature additions, with comprehensive debugging via Serial
  • Optimized for stability: debouncing, rate limiting, I2C traffic reduction

What we learned

  • Deep understanding of ESP32 architecture: dual-core processing, FreeRTOS, peripheral buses (I2C, PWM channels), power distribution, pin constraints (e.g., input-only pins, strapping pins)
  • Hands-on experience with multiple communication protocols: I2C (LCD), 1-Wire (DHT22), PWM (servo/fan), GPIO (matrix scanning, interrupts implicitly via polling)
  • Importance of electrical safety: voltage level translation, current limiting, proper grounding, pull-ups
  • Web development for embedded systems: asynchronous JavaScript, WebSocket, AJAX polling, responsive design, client-side API calls (Gemini, speech)
  • Signal processing: debouncing, edge detection, pulse timing, noise handling
  • Power management and current budgeting for battery-powered applications
  • API integration: Google Gemini for AI, Formspree for emails, persistent storage with Preferences
  • Browser features: Web Speech API for voice, toast notifications, dynamic UI updates
  • System design: State tracking (e.g., auto vs manual open), alert patterns, data logging structures

Built With

  • 1-wire
  • 1-wire-(for-dht22-sensor)
  • 1k?
  • 2k?
  • 4x4-matrix-keypad
  • 5v-relay-module
  • 802.11
  • active-buzzer
  • ap
  • arduino
  • asynctcp
  • asyncwebserver
  • breadboad
  • c++
  • core
  • cp210x
  • css3
  • dht22-sensor
  • electronic
  • embedded
  • esp32
  • esp32-wroom-32
  • espasyncwebserver-(for-non-blocking-web-server)
  • espressif
  • firebase
  • formspree
  • formspree-(for-contact-form-integration)
  • freertos
  • gemini
  • google
  • google-gemini-(for-ai-chatbot-integration)-databases:-preferences-(for-storing-system-configurations-locally-on-the-esp32)-apis:-google-gemini-api-(for-ai-powered-chatbot)
  • gpio
  • hc-sr04-ultrasonic-sensor
  • html5
  • httpclient
  • httpclient-(for-sending-email-alerts)-other-technologies:-i2c-(for-lcd-communication)
  • i2c
  • i2c-lcd-(20x4)
  • ieee
  • if-applicable)
  • irremote.hpp-(for-ir-remote-control)-platforms:-esp32-wroom-32-(microcontroller-platform)-cloud-services:-firebase-(for-hosting-and-database
  • javascript
  • javascript-(for-web-interface)-frameworks:-freertos-(for-multi-core-task-handling)
  • lcd
  • libraries
  • microcontroller
  • progmem
  • pwm
  • pwm-(for-servo-motor-control)
  • resistor
  • sg90-servo-motor
  • usb
  • websocket
  • wi-fi
  • wifi
  • wire
Share this project:

Updates

Private user

Private user posted an update —

ESP32 Smart Door Control System - Major Update v4.2! I'm excited to share the latest evolution of my ESP32 Smart Door Control System - a comprehensive IoT solution that combines hardware automation with AI-powered intelligence!

What's New in v4.2 Wi-Fi-Enabled Web Dashboard

  • Beautiful responsive web interface with real-time sensor monitoring
  • Live WebSocket updates for instant status changes
  • Tabbed navigation: Dashboard, Controls, Settings, AI Chat, About, Contact

AI-Powered Chatbot Assistant

  • Integrated Google Gemini AI for natural language queries
  • Voice control support (Web Speech API)
  • Slash commands for quick actions (/open, /close, /led on, /fan on, etc.)

Enhanced Data Management

  • 100-entry circular buffer data logging
  • CSV export functionality for analysis
  • Real-time sensor data visualization

Core Features Hardware Integration:

  • Servo-controlled door (configurable angles)
  • DHT22 temperature & humidity monitoring
  • HC-SR04 ultrasonic obstacle detection
  • 20x4 I2C LCD real-time display
  • Smart buzzer system with alert patterns
  • Relay-controlled automatic lighting
  • IR remote control (OK=door, *=LED, #=fan)
  • Emergency exit button

Smart Automation:

  • Automatic ventilation when temp >30°C or humidity >70%
  • Obstacle-triggered lighting
  • Auto-close timer with countdown (configurable 1-60 seconds)
  • Email alerts via Formspree integration

Control Methods:

  • Web dashboard controls
  • AI chatbot commands
  • IR remote
  • Physical buttons
  • Voice commands (browser-supported)

Technical Highlights

  • ESP32-WROOM-32 microcontroller
  • AsyncWebServer for efficient web hosting
  • WebSocket real-time communication
  • Preferences API for persistent settings
  • PWM control for fan motor
  • Multiple sensor integration with optimized timing

What's Next?

  • MQTT integration for remote monitoring
  • Mobile app development
  • Additional sensor integrations
  • Enhanced data analytics

Tech Stack: ESP32 C++ Arduino AsyncWebServer Google Gemini AI WebSocket Formspree

Check out the code and full documentation: https://github.com/HorizonHnk/ESP32-Smart-Door-Control-System.git

IoT #ESP32 #SmartHome #Arduino #AI #WebDevelopment #MakerProject

Log in or sign up for Devpost to join the conversation.

Private user

Private user posted an update —

ESP32 Smart Door Control System is now live!

Just submitted this comprehensive IoT access control project to the hackathon. Here's what makes it special:

SECURITY FEATURES:

  • 4-digit PIN authentication via matrix keypad
  • Automated servo lock mechanism
  • Buzzer alerts for access events

SMART AUTOMATION:

  • HC-SR04 ultrasonic sensor detects obstacles within 20cm
  • Automatic lighting control via relay module
  • Real-time distance measurements with temperature compensation

ENVIRONMENTAL MONITORING:

  • DHT22 sensor tracks temperature and humidity
  • Configurable alert thresholds (default: 85°C / 85% RH)
  • Live data display on 20x4 I2C LCD

WEB INTERFACE:

  • WiFi-enabled remote control
  • Real-time sensor data updates (no page refresh needed)
  • Responsive design works on mobile and desktop

TECHNICAL HIGHLIGHTS:

  • Dual-core ESP32 running at 240MHz
  • FreeRTOS multi-threading
  • AsyncWebServer for non-blocking operation
  • Median filtering for noise rejection
  • Proper voltage level translation (5V to 3.3V)

Current Status: Fully functional prototype Code: 800+ lines of optimized C++ Power consumption: Under 400mA total

Try the web interface demo: https://spontaneous-scone-643e85.netlify.app

Would love to hear your feedback! What features would you add? Drop your thoughts in the comments below!

Hashtags: ESP32 IoT SmartHome EmbeddedSystems Arduino HomeAutomation

Log in or sign up for Devpost to join the conversation.

Submission history