Course Content
📘 MODULE 6 – Smart Pet Feeder
0/1
📘 MODULE 7 – Smart Water Management System
0/2
📘 MODULE 8 – Water Quality Monitoring System
0/2
📘 MODULE 10 – Gas Leakage Detection System
0/2
Mastering IoT with 11 Real-World Projects and 1 mega project

🔐 SMART DOOR LOCK SYSTEM (ESP32 + Servo + Solenoid + Relay)

✅ 1) Introduction (Project Idea)

This project is a Smart Door Lock System where:

  • ESP32 is the brain (controller)

  • A Servo motor rotates to open/close a latch (like knob turning)

  • A Solenoid lock works as a strong locking mechanism (push/pull lock)

  • A 1-channel relay is used to turn ON/OFF the solenoid lock safely

This is a very strong and real-world door lock system.


✅ 2) Component List (Complete)

🧠 Main Controller

  1. ESP32 Dev Board

🔩 Locking Devices

  1. Servo Motor (SG90 / MG90S / MG996R)

  2. 12V Solenoid Door Lock

⚡ Power & Switching

  1. 1-Channel Relay Module (5V)

  2. 12V Adapter (for solenoid)

  3. 5V Adapter (for ESP32 + servo)
    (or one 12V adapter + buck converter)

🔌 Extra Safety Components (Highly Recommended)

  1. 1N4007 diode (for solenoid protection)

  2. Jumper wires

  3. Breadboard / PCB

  4. Screw terminals / connectors


✅ 3) Component Details (Simple Explanation)

🧠 ESP32

  • Works like Arduino but much faster

  • Has WiFi + Bluetooth built-in

  • Controls servo and relay signal pin

Why ESP32?
Because it can later connect to:

  • Blynk

  • WiFi App

  • Bluetooth app

  • Fingerprint

  • RFID

  • Keypad


🔧 Servo Motor

Servo rotates to a specific angle like:

  • 0° = Lock

  • 90° = Unlock

📌 Servo is used for mechanical latch movement.

✅ Best for Door Lock:

  • MG90S (metal gear)

  • MG996R (heavy duty)


🔒 Solenoid Lock

Solenoid lock is like:

  • When power ON → pin pulls/pushes

  • When power OFF → returns back

📌 Works like an electric lock used in real doors.

⚠️ Most solenoid locks are 12V and need good current.


🔥 1-Channel Relay Module

Relay works like a switch.

ESP32 gives small signal → relay turns ON/OFF → solenoid gets power.

📌 Relay protects ESP32 from high voltage and high current.


✅ 4) Connection / Wiring (Very Clear)

🔌 SERVO Connection to ESP32

Servo has 3 wires:

Servo Wire Connect To
Red (VCC) 5V external power
Brown/Black (GND) GND
Orange/Yellow (Signal) ESP32 GPIO (example GPIO 13)

⚠️ Do NOT power servo from ESP32 3.3V
Use external 5V.


🔌 RELAY Connection to ESP32

Relay has 3 pins:

Relay Pin Connect To
VCC 5V
GND GND
IN ESP32 GPIO (example GPIO 26)

🔌 SOLENOID Lock Connection with Relay

Relay output side has:

  • COM

  • NO

  • NC

Use COM and NO.

Wiring:

12V Adapter + → Relay COM
Relay NO → Solenoid +
Solenoid – → 12V Adapter –


✅ 5) IMPORTANT: Common Ground Rule (Very Important!)

If you use:

  • 12V for solenoid

  • 5V for ESP32/servo

You MUST connect:

GND of 12V supply + GND of 5V supply + ESP32 GND together

Otherwise relay/servo may behave wrongly.


✅ 6) Working Logic (How It Works)

When Unlock Command comes:

  1. ESP32 rotates servo to open latch (example 90°)

  2. ESP32 turns ON relay

  3. Relay powers solenoid

  4. Solenoid pulls pin → door unlocks

When Lock Command comes:

  1. ESP32 turns OFF relay

  2. Solenoid returns to lock

  3. Servo rotates back to lock angle (0°)


⭐ Recommended Power Setup (Best Option)

Instead of 2 adapters, use:

12V Adapter (2A or 3A)
and use:

Buck Converter (LM2596) to make 5V for ESP32 + servo.

This is the cleanest setup.

Scroll to Top