PIR Sensor: Difference between revisions
Jump to navigation
Jump to search
Created page with "= Description = A PIR Sensor can detect motion, it is also called motion sensor. It detect moveing people or animals. PIR stands for passive infrared. It has 3 connectors: *..." |
|||
Line 10: | Line 10: | ||
= How to connect it electrically = | = How to connect it electrically = | ||
[[File: | [[File:PIR-electro.PNG|x400px]] | ||
= How to control it in MicroPython = | = How to control it in MicroPython = |
Revision as of 21:32, 29 August 2020
Description
A PIR Sensor can detect motion, it is also called motion sensor. It detect moveing people or animals. PIR stands for passive infrared.
It has 3 connectors:
- + connected to GND
- - connected to 3.3V
- Out - digital output is 1 if motion is detected
How to connect it electrically
How to control it in MicroPython
Reading the value and printing it to the console
#Example usage for ESP32
from machine import Pin
from time import sleep
# digital input on pin 26
pir = Pin(26, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
while True:
pirVal = pir.value()
print(pirVal)
sleep(1)
Related Tutorial Videos