loading

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.

<p>Hello- could this be programmed to play a recording or cheering when trash is put into a trash can?</p>
<p>is there any alternative for rf module</p>
<p>Is it possible to use multiple pir sensor and if is possible, how can we make the receiver know which transmitter transmit?</p>
<p>for the virtualwire.h it must be version 1.9 otherwise it will not work on arduino 1.6.5</p>
<p>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 </p>
<p>I am new at this , to implement this project what i will do about virtualwire.h , can you please explain that part , </p>
<p>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.</p><p>Thanks for all your work, and sharing it.</p>
<p>Very nice work. I love the little 433MHz modules.</p>
<p>What would be the range of this?</p>
<p>90 m in open range with 17.3cm antena</p>

About This Instructable

15,053views

89favorites

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 Thermometer Rotary Encoder LED Strip Brightness Controller Wireless PIR Sensor Alarm 
Add instructable to: