Introduction: 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

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

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

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

author
rwkahn3 made it!(author)2016-02-21

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

author
karthick96 made it!(author)2015-11-08

is there any alternative for rf module

author
MuhammadS95 made it!(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?

author
SakibJ made it!(author)2015-07-11

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

author
SakibJ made it!(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

author
SakibJ made it!(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 ,

author
2n2222 made it!(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.

author
Volthaus+Electronics+Laboratory made it!(author)2015-04-02

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

author
WWC made it!(author)2014-11-06

What would be the range of this?

author
MisloElectronics made it!(author)2014-11-06

90 m in open range with 17.3cm antena

About This Instructable

15,420views

90favorites

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: