Wireless PIR Sensor Alarm

Introduction: Wireless PIR Sensor Alarm

About: My hobby is electronics since childhood. I'm interested in Arduino, programming, drawing PCB in Eagle and solder the connections.....

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.

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    11 Discussions

    0
    twinstef
    twinstef

    3 years ago

    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.

    0
    rwkahn3
    rwkahn3

    4 years ago

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

    0
    karthick96
    karthick96

    4 years ago

    is there any alternative for rf module

    0
    MuhammadS95
    MuhammadS95

    5 years ago on Introduction

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

    0
    SakibJ
    SakibJ

    5 years ago on Introduction

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

    0
    SakibJ
    SakibJ

    5 years ago on Introduction

    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

    0
    SakibJ
    SakibJ

    5 years ago on Introduction

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

    0
    2n2222
    2n2222

    5 years ago on Introduction

    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.

    0
    WWC
    WWC

    5 years ago on Introduction

    What would be the range of this?