Introduction: Wireless Infra Red Perimeter Detection Device

This Instructable will provide you with the instructions to build a Wireless Infra Red Perimeter Detection Device. The device consists of two parts: the Transmitter and the Receiver. The Transmitter senses motion, flashes an infra red LED light(viewable with night vision and some cameras), and sends a wireless signal to the Receiver. The Receiver uses this signal to display Motion on an LCD display and flash either a red or an infra red LED(selected with a SPDT switch). The circuit will operate without the lights or LCD display if you want a simpler build. The transmitter will also work on its own to flash the lights when motion is detected.

The user manual below will explain normal operation and ranges of the device.

The video below show it detecting motion and flashing the LCD display.

This Instructable borrows from the following sources:

How to install libraries

http://arduino-info.wikispaces.com/Arduino-Libraries


How to use Arduino

http://arduino.cc/en/Guide/HomePage

LCD display
http://arduino.cc/en/Tutorial/LiquidCrystal
http://fritzing.org/projects/how-to-connect-a-qy-1...
although the wiring is a little different for this project

nRF24L01 Transceiver Information

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

https://www.youtube.com/watch?v=wlhuO82IZjQ

Sensor Information
http://playground.arduino.cc/Code/PIRsense

Step 1: Gather Parts

All parts should be available on Amazon. Ebay has better prices and availability on some items. As most sections can be excluded from the design and it will still operate, only purchase the parts you want. Of course LEDs can be switched out for any color.

Parts list:

1 x RioRand 3 x 40P 20cm Dupont Wire Jumper Cable 2.54 1P-1P

Male-Male/Female-Female/Female-Male

http://smile.amazon.com/gp/product/B00J5NSOVA/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

1 x 16x2 LCD Module Blue White Backlight for Arduino 5V

http://smile.amazon.com/gp/product/B004MGXOUQ/ref=...

2 x Arduino Uno

IEIK UNO R3 Board ATmega328P with USB Cable for Arduino -
Compatible With Arduino UNO R3 Mega 2560 Nano Robot

http://smile.amazon.com/gp/product/B00P2FX9WY/ref=...

Some other Arduino versions may work but I couldn't get the communication to work with the Mega

2 x Zitrades Prototyping Prototype Shield + Mini Breadboard +

Free Jumper Cable for Arduino UNO Maga Nano DUE Robot

http://smile.amazon.com/gp/product/B00INLIQ2W/ref=...

Not necessary but the mini breadboard it comes with is excellent for wiring this up

2 x 2013newestseller New 5 X HC-SR501 Adjust Ir Pyroelectric

Infrared PIR Motion Sensor Detector Modules

http://smile.amazon.com/gp/product/B00FDPO9B8/ref=...

2 x AZN Express | DC12volt 1Amp Slim Power Adapter

http://smile.amazon.com/gp/product/B00HQMN638/ref=...

Any normal Arduino power source is fine.

2 x NRF24L01 + 2.4G Wireless Transceiver Module + SMA Antenna

MCU Arduino

http://smile.amazon.com/Nrf24l01-Antenna-Wireless-Transceiver-Communication/dp/B00OIQ8FS6/ref=sr_1_fkmr1_1?ie=UTF8&qid=1430788043&sr=8-1-fkmr1&keywords=2+x+NRF24L01+%2B+2.4G+Wireless+Transceiver+Module+%2B+SMA+Antenna

1 x 2" Round Board 36 IR Red LED Lamp for CCTV Security

Camera

http://smile.amazon.com/gp/product/B0056XFS5S/ref=...

1 x CCTV CCD Camera LED Board Single Head 2 Pin Connector Power

Cable 5pcs

http://smile.amazon.com/gp/product/B007PQ0V6A/ref=...

These go with the IR Red LED lamp above

2 x Plano Guide Series 3449 Size Polycarbonate Field Box

http://smile.amazon.com/Plano-Guide-3449-Polycarbonate-Field/dp/B003JFU652/ref=sr_1_1?ie=UTF8&qid=1430788401&sr=8-1&keywords=Plano+Guide+Series+3449+Size+Polycarbonate+Field+Box

1 x SPDT switch

Any one will do, I scavenged mine from an old toy.

1 x 10k potentiometer

1 x 1k Ohm resistor

2 x 220 Ohm resistor

1 x IR LED

1 x Red LED

1 x IRF 520 MOSFET

1 x 9V battery

Step 2: Wire the Receiver

Use the pictures to wire the Receiver lights, LCD display, and transceiver.

Important! The Transceiver VCC pin connects to 3.3V. NOT 5V!

Resources:

LCD display

http://arduino.cc/en/Tutorial/LiquidCrystal

http://fritzing.org/projects/how-to-connect-a-qy-1...

although the wiring is a little different for this project

nRF24L01 Information

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz...

Step 3: Wire the Transmitter

Use the pictures to wire the IR lights, Sensor, and Transceiver.

Important! The Transceiver VCC pin connects to 3.3V. NOT 5V!

Resources:

nRF24L01 Information

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo?responseToken=df8e6c97ca4ac2a641ac4504d31b2b6c

Sensor Information

http://playground.arduino.cc/Code/PIRsense

the pins will be different but a good resource to test the sensor

Step 4: Upload the Programming

You will need to download and install the RF24 library

https://github.com/maniacbug/RF24

(Click "Download ZIP" on the lower right of the page)
Once you have downloaded the ZIP, you should see a folder called RF24-master.ZIP. Change the name of this file to just RF24.ZIP. Double click on the ZIP and you should see a non-ZIP folder also called
RF24-master. Rename this to just RF24 as well.

Then copy and paste the programs into the Arduino IDE and upload them to the corresponding devices.

Resources:

How to install libraries

http://arduino-info.wikispaces.com/Arduino-Libraries

How to use Arduino

http://arduino.cc/en/Guide/HomePage

Receiver Program:

--------------------------------------------------------------------------------------------------------------------------

/* Infra Red Perimeter Detection Device Receiver
What it does:
Receives a signal from the Transmitter
Displays motion on an LCD display
Flashes LCD backlight and indicator LEDs
Please use and improve this programming in any way
Enjoy!
*/

#include <LiquidCrystal.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int sensor[2]; // 2 element array holding Joystick readings
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 10;
//the time when the sensor outputs a low impulse
long unsigned int lowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 1000;
boolean lockLow = true;
boolean takeLowTime;

int ledPin = 8;

/////////////////////////////
//SETUP
void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Perimeter Detection");

radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();;
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("Calibrating");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
lcd.setCursor(0, 1);
lcd.print("Active ");
delay(50);
}
////////////////////////////
//LOOP
void loop(){
if ( radio.available() )
{
// Read the data payload until we've received everything
bool done = false;
while (!done)
{
// Fetch the data payload
done = radio.read( sensor, sizeof(sensor) );
Serial.println(sensor[0]);
}
if(sensor[0] == 1){
digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
if(lockLow){
//makes sure we wait for a transition to LOW before any further output is made:
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
lcd.setCursor(0, 1);
lcd.print("Motion ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
}
takeLowTime = true;
}
if(sensor[0] == 0){
digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state
if(takeLowTime){
lowIn = millis(); //save the time of the transition from high to LOW
takeLowTime = false; //make sure this is only done at the start of a LOW phase
}
//if the sensor is low for more than the given pause,
//we assume that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again after
//a new motion sequence has been detected
lockLow = true;
Serial.print("motion ended at "); //output
lcd.setCursor(0, 1);
lcd.print("Active ");
Serial.print((millis() - pause)/1000);
Serial.println(" sec");
delay(50);
}
}
}

}

------------------------------------------------------------------------------------------------------------------------

Transmitter Program

------------------------------------------------------------------------------------------------------------------------

/* Infra Red Perimeter Detection Device Transmitter
What it does:
Uses a PIR sensor to detect motion
Flashes an IR light when motion is detected
Sends a wireless signal to the Receiver
Please use and improve this programming in any way
Enjoy!
/
/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
#define SENSOR 8

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int sensor[2]; // 2 element array holding Sensor readings
int ledPin = 7;
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
radio.begin();
pinMode(ledPin, OUTPUT);
radio.openWritingPipe(pipe);
digitalWrite(ledPin, LOW);
}//--(end setup )---

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
sensor[0] = digitalRead(SENSOR);;

radio.write( sensor, sizeof(sensor) );
Serial.print( sensor[0] );
if (sensor[0] == 1){
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
}
}//--(end main loop )---

------------------------------------------------------------------------------------------------------------------------

Step 5: Troubleshooting

Problems that I have found:

When using the Arduino USB cable as a power source it will say motion most of the time even where there is not any.

If signal is lost the receiver will still display "Active" on the LCD display.

I received multiple dead components which caused me a few headaches. It is a good idea to test individual components with sample programs first.

I will expand this section as people make comments.

Step 6: Housing the Components

I used water proof cases and drilled holes for the power source and antenna. On the Receiver I mounted the switch on the outside although this is not necessary. I hot glued the pieces in place.

Step 7: Improve the Devices and Programming!

Feel free to use and modify this for anything.

I would love to see improvements made so when the signal is lost the Receiver would display a "No Signal" message.

I would also like to see multiple Transmitters communicating with one Receiver.

Please post any improvements in the comments.

Thank You