A new wemos shield and this time its based on a passive infrared sensor
An overview of a PIR
A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. A PIR-based motion detector is used to sense movement of people, animals, or other objects. They are commonly used in burglar alarms and automatically-activated lighting systems. They are commonly called simply “PIR”, or sometimes “PID”, for “passive infrared detector”.
If you want to read more basics – https://en.wikipedia.org/wiki/Passive_infrared_sensor
The shield uses D3 so that will be unavailable for any other components or shields you may want to use, here is a picture of the shield
The PIR is an AS312
Code
Very simple stuff here, we will output via the serial monitor.
[codesyntax lang=”cpp”]
const int PIR = D3; int PIRState = 0; void setup() { Serial.begin(9600); pinMode(PIR, INPUT); } void loop() { PIRState = digitalRead(PIR); if (PIRState == HIGH) { Serial.write("INTRUDER DETECTED\n"); } else { Serial.write("NOWT GOING ON\n"); } delay(1000); }
[/codesyntax]
Output
Open the serial monitor and move your hand in front of the PIR and then move away
NOWT GOING ON
NOWT GOING ON
NOWT GOING ON
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
NOWT GOING ON
NOWT GOING ON
NOWT GOING ON
INTRUDER DETECTED
INTRUDER DETECTED
Links
https://datasheet.lcsc.com/szlcsc/Nanyang-Senba-Optical-Elec-AS312_C90465.pdf