Introduction: Wireless PIR Sensor Alarm

Picture of Wireless PIR Sensor Alarm

This is a simple wireless PIR sensor alarm.The device consists of two parts.One is a transmitter that contains PIR sensor and a transmitter module.A second receiver consisting receiving module and piezo speaker. Test your PIR sensor before you made this with any code from internet.

Step 1: Parts

Picture of Parts

You need:

1. Two arduinos any version

2. PIR sensor

3. Piezo speaker

4: RF 433MHz or 315 MHz module

5. 10Kohm resistor

Step 2: Transmitter

Picture of Transmitter

This is code of transmitter. When PIR sensor detects human movement transmitter sends uppercase letter A. When pir sensor it holds no signal transmitter sends lowercase letter a.

int pirPin = 2;
int statePir = 0;

#include <VirtualWire.h>

void setup(){

Serial.begin(9600);

vw_setup(2000);

vw_set_tx_pin(3);

pinMode(pirPin,INPUT);

}

void loop(){

statePir = digitalRead(pirPin);

if (statePir == HIGH){

const char *msg = "A";

vw_send((uint8_t *)msg, strlen(msg));

vw_wait_tx();

}

if (statePir == LOW){

const char *msg = "a";

vw_send((uint8_t *)msg, strlen(msg));

vw_wait_tx();

}

}

Step 3: Receiver

Picture of Receiver

Here is the code for receiver. Piezo play very loud alarm sound.

int led = 13;
int speaker = 10;

#define wait 1

#define time 100

int freq = 0;

#include

void setup(){

Serial.begin(9600); // Debugging only

vw_setup(2000);
vw_set_rx_pin(11);

vw_rx_start();

pinMode(speaker, OUTPUT);
pinMode(led, OUTPUT);

}

void loop(){

uint8_t buf[VW_MAX_MESSAGE_LEN];

uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen))
{

for (int i = 0; i < buflen; i++)

{

if(buf[i] == 'A') {

digitalWrite(led, HIGH);
digitalWrite(speaker, HIGH);

for (freq = 500; freq < 3000; freq += 10)

{
tone(speaker, freq, time);

delay(wait);

}

for (freq = 3000; freq > 500; freq -= 10)

{

tone(speaker, freq, time);

delay(wait);

}

for (freq = 500;

freq < 3000;

freq += 10) //

{

tone(speaker, freq, time);

delay(wait);

}

for (freq = 3000;

freq > 500; freq -= 10)

{

tone(speaker, freq, time);

delay(wait);

}

for (freq = 500;

freq < 3000;

freq += 10) //

{

tone(speaker,

freq, time);

delay(wait);

}

for (freq = 3000;

freq > 500;

freq -= 10)

{

tone(speaker, freq, time);

delay(wait);

}

for (freq = 500; freq < 3000; freq += 10)

{

tone(speaker, freq, time);

delay(wait);

}

for (freq = 3000;

freq > 500; freq -= 10)

{

tone(speaker, freq, time);

delay(wait);

}

} if(buf[i] == 'a')

{ digitalWrite(led, LOW); digitalWrite(speaker, LOW);

}

}

}

}

Step 4: Library

For this project you need VirtualWire libraries. In the link below have all the files needed for this project. In video see how this work.

Comments

twinstef (author)2017-10-04

Hello

I time ago, i tried to do a similar mount but i hat the following problem on the emitter:

When the emitter send information - vw_send(...) - the Pir module stay in high mode even with no more mouvement .

But without emission the PIR can return to low.

I see that you put a 10k resistor in pull-up mode - is it to avoid the same problem ?

thanks.

rwkahn3 (author)2016-02-21

Hello- could this be programmed to play a recording or cheering when trash is put into a trash can?

karthick96 (author)2015-11-08

is there any alternative for rf module

MuhammadS95 (author)2015-09-30

Is it possible to use multiple pir sensor and if is possible, how can we make the receiver know which transmitter transmit?

SakibJ (author)2015-07-11

for the virtualwire.h it must be version 1.9 otherwise it will not work on arduino 1.6.5

SakibJ (author)2015-07-09

and i want to add an ultrasonic sensor at receiver end to stop the alarm [ i want to make the alarm keeps making sound until someone stops it ] where should i change the code

SakibJ (author)2015-07-09

I am new at this , to implement this project what i will do about virtualwire.h , can you please explain that part ,

2n2222 (author)2015-04-23

Look like great project, I like the work you added in Wireless_PIR,rar. I think I will add this code into my Wireless Robot project.

Thanks for all your work, and sharing it.

Very nice work. I love the little 433MHz modules.

WWC (author)2014-11-06

What would be the range of this?

MisloElectronics (author)WWC2014-11-06

90 m in open range with 17.3cm antena

About This Instructable

16,273views

91favorites

License:

Bio: My hobby is electronics since childhood. I'm interested in Arduino, programming, drawing PCB in Eagle and solder the connections.....
More by MisloElectronics:Attiny85 5110LCD DS18B20 ThermometerRotary Encoder LED Strip Brightness ControllerWireless PIR Sensor Alarm
Add instructable to: