Beaglebone and PIR sensor example

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.

All objects with a temperature above absolute zero emit heat energy in the form of radiation. Usually this radiation isn’t visible to the human eye because it radiates at infrared wavelengths, but it can be detected by electronic devices designed for such a purpose.

The term passive in this instance refers to the fact that PIR devices do not generate or radiate energy for detection purposes. They work entirely by detecting infrared radiation (radiant heat) emitted by or reflected from objects.

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”.

I used an HC-SR501

HC-SR501 is based on infrared technology, automatic control module, using Germany imported LHI778 probe design, high sensitivity, high reliability, ultra-low-voltage operating mode, widely used in various auto-sensing electrical equipment, especially for battery-powered automatic controlled products.Specification:◦ Voltage: 5V – 20V◦ Power Consumption: 65mA◦ TTL output: 3.3V, 0V

Lock time: 0.2 sec◦ Trigger methods: L – disable repeat trigger, H enable repeat trigger
Sensing range: less than 120 degree, within 7 meters◦ Temperature: – 15 ~ +70◦ Dimension: 32*24 mm, distance between screw 28mm, M2, Lens dimension in diameter: 23mm

Application:

Automatically sensing light for Floor, bathroom, basement, porch, warehouse, Garage, etc, ventilator, alarm, etc.

Features:

Automatic induction: to enter the sensing range of the output is high, the person leaves the sensing range of the automatic delay off high, output low.
Photosensitive control (optional, not factory-set) can be set photosensitive control, day or light intensity without induction.
Temperature compensation (optional, factory reset): In the summer when the ambient temperature rises to 30 ° C to 32 ° C, the detection distance is slightly shorter, temperature compensation can be used for performance compensation.

Triggered in two ways: (jumper selectable)
non-repeatable trigger: the sensor output high, the delay time is over, the output is automatically changed from high level to low level;
repeatable trigger: the sensor output high, the delay period, if there is human activity in its sensing range, the output will always remain high until the people left after the delay will be high level goes low (sensor module detects a time delay period will be automatically extended every human activity, and the starting point for the delay time to the last event of the time).

With induction blocking time (the default setting: 2.5s blocked time): sensor module after each sensor output (high into low), followed by a blockade set period of time, during this time period sensor does not accept any sensor signal. This feature can be achieved sensor output time “and” blocking time “interval between the work can be applied to interval detection products; This function can inhibit a variety of interference in the process of load switching. (This time can be set at zero seconds – a few tens of seconds).
Wide operating voltage range: default voltage DC 4.5V-20V.
Micropower consumption: static current <50 microamps, particularly suitable for battery-powered automatic control products.
Output high signal: easy to achieve docking with the various types of circuit.

 

Parts List

Name Link
Beaglebone BeagleBone Black TI AM3358 Cortex-A8 development BB-Black Rev.C
HC-SR501 HC-SR501 human infrared sensor module Pyroelectric infrared sensor
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematics

 

 

Code

A bonescript example

var b = require('bonescript');

b.pinMode('P8_7', b.INPUT);
setInterval(checkPIR, 2000); // Checks the Sensor Every 2 Seconds

function checkPIR()
{
	b.digitalRead('P8_7', printStatus);
}

function printStatus(x) 
{
    if(x.value === 0)
    {
    console.log("Motion Detected");
    }
    else
    {
    console.log("No Motion Detected");
    }
}

 

Output

Bonescript: initialized
Bonescript: initialized
No Motion Detected
No Motion Detected
No Motion Detected
Motion Detected
No Motion Detected
No Motion Detected
No Motion Detected
Motion Detected
Motion Detected
No Motion Detected
No Motion Detected
Motion Detected

LEAVE A REPLY

Please enter your comment!
Please enter your name here