Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

πŸ“˜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

Scroll to Top