β ESP32 Smart Door Lock (Bluetooth Terminal)
ESP32 + Servo + Solenoid Lock + 1-Channel Relay
π Bluetooth Commands (From Mobile)
Open Bluetooth Terminal app and send:
| Command | Action |
|---|---|
1 |
Unlock (Servo open + Solenoid ON) |
0 |
Lock (Servo close + Solenoid OFF) |
S |
Show status |
β ESP32 Bluetooth Door Lock CodeΒ
Β
β Code Explanation (Very Simple & Clear)
πΉ 1) Libraries
-
BluetoothSerial.hβ makes ESP32 Bluetooth work like serial communication -
Servo.hβ controls servo motor angle
πΉ 2) Bluetooth Start
This creates Bluetooth device name:
π ESP32_DoorLock
You will see this name in phone Bluetooth list.
πΉ 3) Pins Used
-
Servo signal connected to GPIO 13
-
Relay IN connected to GPIO 26
πΉ 4) Servo Lock Angles
You can change these depending on your lock setup.
Example:
-
If your servo rotates wrong direction:
-
change
90to180 -
or change
0to180
-
πΉ 5) Relay Control
Relay ON β Solenoid ON β lock pin moves.
Relay OFF β Solenoid OFF.
πΉ 6) Bluetooth Command Reading
This reads the command from your phone.
πΉ 7) Unlock Function
It does:
-
Servo rotates to unlock latch
-
Relay ON β solenoid activates
-
Door unlocks
πΉ 8) Lock Function
It does:
-
Relay OFF β solenoid stops
-
Servo rotates back to lock angle
-
Door locks
π± How to Use Bluetooth Terminal App
Use this app:
β Serial Bluetooth Terminal (Android)
Steps:
-
Upload code to ESP32
-
Turn ON Bluetooth in phone
-
Pair with ESP32_DoorLock
-
Open app β connect
-
Send command:
-
1unlock -
0lock
-
β οΈ IMPORTANT NOTES (Must Read)
β Servo Power
-
Servo must get 5V external
-
Do not use ESP32 3.3V
β Relay Power
-
Relay VCC = 5V
-
Relay GND = ESP32 GND
β Solenoid Power
-
Solenoid uses 12V
-
Never connect solenoid directly to ESP32