Difference between revisions of "PIR Sensor"
Jump to navigation
Jump to search
(3 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
[[File:Pir3.PNG|x300px]] | [[File:Pir3.PNG|x300px]] | ||
+ | |||
+ | |||
+ | This one is the HC-SR501 sensor and it should be connected to 5V, GND and a digital Pin. | ||
+ | |||
+ | [[File:Pir2.JPG|x300px]] | ||
+ | [[File:Pir4.JPG|x300px]] | ||
= How to connect it electrically = | = How to connect it electrically = | ||
Line 29: | Line 35: | ||
= Related Tutorial Videos = | = Related Tutorial Videos = | ||
<youtube>C0W-wI0qHIQ</youtube> | <youtube>C0W-wI0qHIQ</youtube> | ||
+ | |||
+ | <youtube>dVE7R-Spf6M</youtube> |
Latest revision as of 00:35, 12 January 2021
Contents
Description[edit]
A PIR Sensor can detect motion, it is also called motion sensor. It detect moveing people or animals. PIR stands for passive infrared. Here we use the SR602.
It has 3 connectors:
- - connected to GND
- + connected to 3.3V
- Out - digital output is 1 if motion is detected
This one is the HC-SR501 sensor and it should be connected to 5V, GND and a digital Pin.
How to connect it electrically[edit]
How to control it in MicroPython[edit]
Reading the value and printing it to the console
1 #Example usage for ESP32
2 from machine import Pin
3 from time import sleep
4 # digital input on pin 26
5 pir = Pin(26, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
6
7 while True:
8 pirVal = pir.value()
9 print(pirVal)
10 sleep(1)
Related Tutorial Videos[edit]