Home Security projects HC-SR501 PIR sensor example

HC-SR501 PIR sensor example

by shedboy71

In the following example we will demonstrate the HC-SR501 PIR sensor, this sensor has many nice features including the ability to be driven by 5v, low cost (£2 to £3), it has a decent range (7 metres) and a fairly small size. These sensors can take anything between 10-60 seconds to warm up, so you should either avoid motion at this point or in your code you would factor this in.

The HC-SR501 is based on infrared technology, automatic control module, using 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:

Use BISS0001 signal processing IC, sanyo genius regulator
Voltage: 5V – 20V
Power Consumption: 65mA
TTL output: 3.3V, 0V
Delay time: adjustable (0.3 sec – 10 minutes)
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

Connecting these to an Arduino is straightforward,first  connect the VCC and GND up and then connect the output to a digital pin, in our example we connect to digital pin 8. You can see this in the layout and schematics below

Layout

arduino and PIR breadboard

arduino and PIR breadboard

 

Schematic

arduino and PIR schematic

arduino and PIR schematic

 

Code example

This basic example will display a different output depending on whether motion is detected.

[codesyntax lang=”cpp”]

int pirPin = 8;
int val;

void setup()
{
Serial.begin(9600);
}

void loop()
{
val = digitalRead(pirPin);
//low = no motion, high = motion
if (val == LOW)
{
Serial.println(“No motion”);
}
else
{
Serial.println(“Motion detected – ALARM”);
}

delay(1000);
}

[/codesyntax]

 
Links

HC-SR501 Human Sensor Module Pyroelectric on Amazon UK

HC-SR501 Human Sensor Module Pyroelectric on Amazon US

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More