How a PIR sensor works
Passive InfraRed(PIR) sensors use changes in IR radiation to detect motion. The way that they do this is by taking the difference of two conjoined sensors that both detect the IR radiation levels in separate fields. When a person moves past the IR detection fields of one of the two sensors, there will be a change where one will be higher than the other. As the person moves through to the detection field of the neighbouring sensor a higher value will be seen on the other sensor. When looking at the differential of the two readings there will be a point where the value peaks and troughs as the person moves through the two fields. By using this inflection point as a trigger the IR sensor is able to sense motion.
This is represented visually with the diagram below:
Since there would be limited range when using the IR fields unmodified, a Fresnel lens is used. Instead of having one field of detection it spreads the viewing field by using the many faces of the lens to scatter the sensing area.
Luckily for us the pre-processing of the sensor readings are already done for us using this PIR board. This means that instead of looking for inflection points, all that has to be done is wait for a 3.3V signal to be sent to confirm the sensor has detected movement.
Configuring a PIR sensor
There are two potentiometers that control the sensitivity and time delay. By adjusting the potentiometer with a small screwdriver you can vary the sensor’s behaviour.
Sensitivity Adjust: By adjusting the sensitivity the maximum distance the sensor can see can be modified. The distance can range from 3-7M. Clockwise increases sensitivity.
Time Delay Adjust:This controls the time that the sensor will be HIGH after being triggered by motion. The time delay can range from 3 - 300 seconds. Clockwise increases the time delay.
As shown by the photo below, there is also a jumper that allows you to set the retriggering option. The jumper can either be put on the H side or the L side.
H : By putting the jumper on the H side, as long as there is movement the board will output HIGH. This setting allows for retriggering during the time delay set by the potentiometer.
L : If the jumper is put on the L side it will only stay high for as long as you set your Time Delay Adjustment on the potentiometer. Once the delay has been timed out it can be triggered again.
Setting up the Breadboard
Add the Breadboard Block to the canvas and open its Properties Panel:
Click on the ‘Visual Map’ button and configure pins 1, 2 and 3 as shown below:
IO1 → VCC
IO2 → Input
IO3 → Gnd
IO1 - Vcc
IO2 - Input
IO3 - Gnd
The image below shows the labelled pins of the sensor.
Connect the cable to your Breadboard Block making sure the line from the VCC pin on the PIR board is connected to pin 1:
Now that all the configurations are done we are able to use the Logic Maker to read the input from the PIR sensor. By using an Input gate and selecting IO2 we will be able to read the PIR sensor. To visualise the readings from the PIR sensor connect up a display gate. You will see that if the PIR sensor detects movement it will show a 1, when there is no movement it will display a 0.
For an example on how to use your newly configured PIR sensor see this post on how to make a DIY security system: DIY Security System