πHome Security SystemΒ
π― Objective of This Lesson
Students will learn:
-
How to connect PIR sensor with ESP32
-
How digital output works
-
Proper GPIO selection
-
Power considerations
-
Correct installation position
π§ͺ Components Required
-
ESP32 Development Board
-
PIR Motion Sensor (HC-SR501 recommended)
-
Breadboard
-
Jumper wires
-
USB cable
π PIR Sensor Pin Description
Most PIR modules have 3 pins:
| Pin | Function |
|---|---|
| VCC | 5V power |
| GND | Ground |
| OUT | Digital Output |
π Circuit Connections (ESP32 + PIR)
π Connection Table
| PIR Pin | ESP32 Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| OUT | GPIO 27 |
You can use any digital GPIO, but GPIO 27 is safe and recommended.
π§ Why We Use GPIO 27?
-
Supports digital input
-
Safe for sensor signals
-
Not used for boot configuration
-
Stable and reliable
β‘ Power Considerations
Important points:
1οΈβ£ PIR works on 5V
2οΈβ£ ESP32 works on 3.3V logic
3οΈβ£ PIR output is safe for ESP32 digital input
4οΈβ£ Do NOT power PIR from 3.3V (may cause unstable detection)
π§ How the Circuit Works
1οΈβ£ PIR senses infrared radiation
2οΈβ£ When motion is detected β OUT becomes HIGH
3οΈβ£ When no motion β OUT becomes LOW
4οΈβ£ ESP32 reads HIGH or LOW from GPIO 27
5οΈβ£ Program decides what to do
So basically:
Motion β HIGH
No Motion β LOW
π Physical Installation Guidelines
To get best performance:
-
Mount sensor at height of 6β8 feet
-
Face toward entrance or movement area
-
Avoid pointing directly at windows
-
Avoid facing fans or AC
-
Keep away from heat sources
β PIR Module Adjustments
Most PIR sensors have two potentiometers:
πΉ Sensitivity Adjustment
-
Clockwise β Increase range
-
Counterclockwise β Decrease range
πΉ Time Delay Adjustment
-
Controls how long output remains HIGH
-
Adjustable from few seconds to few minutes
π Trigger Mode Jumper
Two modes available:
H Mode (Retriggerable)
-
Output stays HIGH if motion continues
-
Recommended for security systems
L Mode (Non-Retriggerable)
-
Output goes LOW after delay even if motion continues
For Home Security:
π Use H Mode
β³ Warm-Up Time
After powering ON:
-
Wait 30β60 seconds
-
Sensor stabilizes
-
During warm-up, output may fluctuate
Important to explain this to students.
π Signal Behavior Summary
| Condition | PIR Output |
|---|---|
| No Motion | LOW |
| Motion Detected | HIGH |
π Learning Outcomes
After this lesson, students understand:
-
Digital sensor interfacing
-
GPIO input concept
-
Motion detection basics
-
Practical installation logic
-
Sensor calibration basics