Cheap Wireless Motion Sensor Device

I think we all have the dream to became a super spy, so if you are in a secret mission, you are doing something in your house and you don't want to get caught, our you are just eating all the cookies in the kitchen and you want to know if your mother is coming, the wireless motion sensor devices are for you.

I see a lot of wireless in de web and in movies, but i want to figure out the way to make it cheap for everyone so I use an attiny85, a pir sensor (motion sensor) and a rf link to make the project work.

If you like this proyect please follow my blog on facebook: (is in spanish) Facebook page or enter to my blog Bioespin

Step 1: Material

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
I order my material from a sparkfun distribution in M xico because is where i live but if you live in USA you can order barely all the material from sparkfun.

1 pir sensor

http://www.sparkfun.com/products/8630

9.95 dolar


1 rf receiver 315mhz

http://www.sparkfun.com/products/10533

4.95 dolar


1 rf transmiter 315mhz

http://www.sparkfun.com/products/10535

3.95 dolar


1 attiny85

http://www.sparkfun.com/products/9378

2.84 dolar


1 arduino uno


1 switch

4 resistance 180ohm

1 resistance 10k ohm

normally open button (optional)

1 8 ohm speaker (optional)

1 ic 8 pin base

1pnp transistor ( you can use the 2n2222, just check out the collector and emitter pins are in the right place)

1 lm7805 (5v regulator)

3 electrolitic capacitors 10uf 50v

Step 2: Hardware

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Show All 8 Items
As you can see in the image everything in the circuits works with 5Volts but the pir sensor works with 9 to 12 volts. To fix this and save the work and spend of connecting the circuits to 2 different kind of voltage i use a lm7805, that is a 5Volts regulator, and connect everything to a 9V(square) battery.

If you want to make a pcb to have all the connections in a cleaner way I will put a pdf file below so you can print it and transfer with the method you want.

2 connection do not fit in the design so y place them with wires. (the two connections are the yellow ones in the second image)

For the receiver I was going to do also a attiny85 device, but I was short in time so I end up making an arduino shield with a speaker. (If somebody want the pcb for the attiny85 receiver I'm in half production and I will upload it later. thanks for the comprehension).

If you print the arduino receiver shield you got to be careful, the bottom copper side ends up in the top, also the pins are place in the bottom and solder though the holes in the pcb, but all the other component are solder from the upper part directly bending the legs. you can have a better look in the 5 to 8 images.

Cheap Wireless Motion Sensor Device
arduino receiver shield.pdf4 KB
Cheap Wireless Motion Sensor Device
transmitter pcb.pdf44 KB

Step 3: Software

Cheap Wireless Motion Sensor Device
To program the attiny85 you can use the arduino uno as isp programmer. You can look this link (http://hlt.media.mit.edu/?p=1706) for more information about this procces, but you dont need to because im gonna explain everything in detail.

I use a attiny because is cheaper than use an arduino. you can buy a attiny85 for 2.84USD, compare to an arduino for about 38 dolars. Using an attiny to comunicate through a rf link represent a chalenge because the attiny doesn't have a rx or tx serial comunication by default. I want to thanks this blog (http://mchr3k-arduino.blogspot.mx/) for make the program that make possible to comunicate with an attiny.

ok. so let go to step by step programing.

1. go to the arduino oficial site and download the arduino-0022 software. (don't use the arduino 1.0, it doesn't work). Unzip the file. you should see a folder name arduino-0022.

2. go to this link.

http://mchr3k-arduino.blogspot.mx/2012/01/wireless-sensor-node-part-2.html?showComment=1338749638806#c853067277980266192

download the attiny45_85.zip and the manchester.zip files.

3. Unzip the attiny45_85.zip file. copy the folder.
open the arduino-0022 folder. Open hardware and paste the attiny45_85 folder there.

4.Unzip the manchester.zip file. open that manchester folder and you should see two other folders. core and MANCHESTER.
copy de MANCHESTER folder.
open again the arduino-0022 folder. but this time open the libraries folder. paste the MANCHESTER folder there.

Now you have the software ready to program.

5. launch the arduino-0022 program. click in the arrow poining up (open) and open the ArduinoISP example. click in tools>board>arduino uno. (look you now have all the attiny in there).

Upload the program.

6. Place the attiny85 in a protoboard (breadboard), and connect everythingh to the arduino as the image. Be shure you place the attiny in the correct way or you are going to burn it. (happened to me :P) .

7. On the arduino program go to tools>board>attiny85 (w/ Arduino as ISP). click again tools>burn bootloader>w/ Arduino as ISP. (you may see a error but that's ok).

ok, So let's make the program for the transmitter.


Step 4: Transmitter

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
here is the program for the transmitter. if you make the last step in order now you just have to place the code in the arduino program and upload it.

#include //include the library to comunicate
#define TxPin 2 //the pin that is used to send data

unsigned int Tdata = 0; //begin the data in 0

int TRANSISTOR_PIN = 1; //pin that turn ON and OFF the transistor
int PIR_SENSOR_PIN = 0; //the motion sensor pin


void setup()
{
MANCHESTER.SetTxPin (TxPin); //set the pin of comunication
pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT);
}

void loop()
{
int pirVal=digitalRead(PIR_SENSOR_PIN); //read the state of the motion sensor
if(pirVal == LOW)//if pir sensor detect movement then

{/*action, in this case turn ON the transistor to power
the transmitter then send the message,
the turn OFF the transistor*/

digitalWrite(TRANSISTOR_PIN, HIGH);//transistor ON
delay(1000);

Tdata = 50; //I use 50 as sensor1alarm number but you can use the number that you want
//be sure you use the same number in transmiter and receiver

MANCHESTER.Transmit(Tdata); //transmit the signal
delay(100);

digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF transistor to save battery
}
delay(2000);
}

Step 5: Receiver

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
for the receiver you just have to program the arduino. So go to tools>board and select arduino uno.
copy this code. and Upload it.

#include //include the comunication library
#define RxPin 6 //define the receiver pin
#define speaker 9
#define sensor1alarm 12
#define sensor2alarm 11
#define sensor3alarm 10

void setup()
{
MANCHESTER.SetRxPin(RxPin); //user sets rx pin default 6
MANCHESTER.SetTimeOut(1000); //user sets timeout default blocks
Serial.begin(9600); // Debugging only
//setting the pins in arduino
pinMode(sensor1alarm, OUTPUT);
digitalWrite(sensor1alarm, LOW);
pinMode(sensor2alarm, OUTPUT);
digitalWrite(sensor2alarm, LOW);
pinMode(sensor3alarm, OUTPUT);
digitalWrite(sensor3alarm, LOW);
pinMode(speaker, OUTPUT);
digitalWrite(speaker, LOW);
}//end of setup

void loop()
{
unsigned int data = MANCHESTER.Receive();

if(data==50) //match this number with the sensor number
{
digitalWrite(sensor1alarm, HIGH); //turn ON the sensor1alarm led


for (int i=0; i digitalWrite(speaker, HIGH);
delayMicroseconds(500);
digitalWrite(speaker, LOW);
delayMicroseconds(500);
} //end of for speaker


digitalWrite(sensor1alarm, LOW); //turn OFF the sensor1alarm led
delay(500);

}//end of if

//paste in here if you have another transmitter

}//end of loop



/*if you have more than one transmiter you just have to give a diferent number to the transmiter and copy from if(data==50) to end of if, and paste it in the indication. and change the number 50 to the number in the other transmitter.*/
Cheap Wireless Motion Sensor Device
arduino receiver shield.pdf4 KB

Step 6: Conclusion

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
You can place your sensor in every case you want. I place mine in soda cans because I think no one is going to check if there is something wrong with a can. and you can place everywhere and doesn't seems weird. So enjoy been a secret spy or just protect your house from strangers in the night. the uses are endless, you just have to put your creativity to work a little.

p.d. (you can change the motion sensor, for a lot of other sensors with a little changes in the design and you can have temperature sensors, sound sensors, ultrasonic sensors, gas sensors, infrared sensors, and a lot of other sensors for a cheap price that can sense things from a safe distance).

I hope you enjoy this instructable :), sorry if my english is not the best.

Step 7: How to use 3 transmitters with one receiver

Cheap Wireless Motion Sensor Device
this is the code for using 3 motion sensors with one receiver:

//use this for the receiver
//***********************************************************************************************

#include //include the comunication library
#define RxPin 6 //define the receiver pin
#define speaker 9
#define sensor1alarm 12
#define sensor2alarm 11
#define sensor3alarm 10

void setup()
{
MANCHESTER.SetRxPin(RxPin); //user sets rx pin default 6
MANCHESTER.SetTimeOut(1000); //user sets timeout default blocks
Serial.begin(9600); // Debugging only
//setting the pins in arduino
pinMode(sensor1alarm, OUTPUT);
digitalWrite(sensor1alarm, LOW);
pinMode(sensor2alarm, OUTPUT);
digitalWrite(sensor2alarm, LOW);
pinMode(sensor3alarm, OUTPUT);
digitalWrite(sensor3alarm, LOW);
pinMode(speaker, OUTPUT);
digitalWrite(speaker, LOW);
}//end of setup

void loop()
{
unsigned int data = MANCHESTER.Receive();

if(data==50) //match this number with the sensor number
{
digitalWrite(sensor1alarm, HIGH); //turn ON the sensor1alarm led


for (int i=0; i digitalWrite(speaker, HIGH);
delayMicroseconds(500);
digitalWrite(speaker, LOW);
delayMicroseconds(500);
} //end of for speaker


digitalWrite(sensor1alarm, LOW); //turn OFF the sensor1alarm led
delay(500);

}//end of if
else if(data==100) //match this number with the sensor number
{
digitalWrite(sensor2alarm, HIGH); //turn ON the sensor1alarm led


for (int i=0; i digitalWrite(speaker, HIGH);
delayMicroseconds(500);
digitalWrite(speaker, LOW);
delayMicroseconds(500);
} //end of for speaker


digitalWrite(sensor2alarm, LOW); //turn OFF the sensor1alarm led
delay(500);
}
else if(data==150) //match this number with the sensor number
{
digitalWrite(sensor3alarm, HIGH); //turn ON the sensor1alarm led


for (int i=0; i digitalWrite(speaker, HIGH);
delayMicroseconds(500);
digitalWrite(speaker, LOW);
delayMicroseconds(500);
} //end of for speaker


digitalWrite(sensor3alarm, LOW); //turn OFF the sensor1alarm led
delay(500);
}

}//end of loop

//**************************************************************************************************
//use this for one of the transmitters
//transmitter 1.

#include //include the library to comunicate
#define TxPin 2 //the pin that is used to send data

unsigned int Tdata = 0; //begin the data in 0

int TRANSISTOR_PIN = 1; //pin that turn ON and OFF the transistor
int PIR_SENSOR_PIN = 0; //the motion sensor pin


void setup()
{
MANCHESTER.SetTxPin (TxPin); //set the pin of comunication
pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT);
}

void loop()
{
int pirVal=digitalRead(PIR_SENSOR_PIN); //read the state of the motion sensor
if(pirVal == LOW)//if pir sensor detect movement then

{/*action, in this case turn ON the transistor to power
the transmitter then send the message,
the turn OFF the transistor*/

digitalWrite(TRANSISTOR_PIN, HIGH);//transistor ON
delay(1000);

Tdata = 50;

MANCHESTER.Transmit(Tdata); //transmit the signal
delay(100);

digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF transistor to save battery
}
delay(2000);
}

//********************************************************************************************
//use this for the secod transmitter.
//transmitter 2.

#include //include the library to comunicate
#define TxPin 2 //the pin that is used to send data

unsigned int Tdata = 0; //begin the data in 0

int TRANSISTOR_PIN = 1; //pin that turn ON and OFF the transistor
int PIR_SENSOR_PIN = 0; //the motion sensor pin


void setup()
{
MANCHESTER.SetTxPin (TxPin); //set the pin of comunication
pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT);
}

void loop()
{
int pirVal=digitalRead(PIR_SENSOR_PIN); //read the state of the motion sensor
if(pirVal == LOW)//if pir sensor detect movement then

{/*action, in this case turn ON the transistor to power
the transmitter then send the message,
the turn OFF the transistor*/

digitalWrite(TRANSISTOR_PIN, HIGH);//transistor ON
delay(1000);

Tdata = 100;

MANCHESTER.Transmit(Tdata); //transmit the signal
delay(100);

digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF transistor to save battery
}
delay(2000);
}

//*******************************************************************************************
//use this for transmitter 3
//transmitter 3.

//receiver 2.

#include //include the library to comunicate
#define TxPin 2 //the pin that is used to send data

unsigned int Tdata = 0; //begin the data in 0

int TRANSISTOR_PIN = 1; //pin that turn ON and OFF the transistor
int PIR_SENSOR_PIN = 0; //the motion sensor pin


void setup()
{
MANCHESTER.SetTxPin (TxPin); //set the pin of comunication
pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT);
}

void loop()
{
int pirVal=digitalRead(PIR_SENSOR_PIN); //read the state of the motion sensor
if(pirVal == LOW)//if pir sensor detect movement then

{/*action, in this case turn ON the transistor to power
the transmitter then send the message,
the turn OFF the transistor*/

digitalWrite(TRANSISTOR_PIN, HIGH);//transistor ON
delay(1000);

Tdata = 150;

MANCHESTER.Transmit(Tdata); //transmit the signal
delay(100);

digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF transistor to save battery
}
delay(2000);
}

Step 8: Receiver 2.0

Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device
Cheap Wireless Motion Sensor Device

Some of you ask if I can upload the receiver pcb for making the receiver with a attiny85 like the transmitters, to avoid using the arduino uno. Sooo here they are the files to make the receiver for cheap. I hope you like them.

I leave the 3 leds as in the arduino version but instead of placing a speaker y place a relay so you can activate any device you like. For example your house lights, an alarm or any device that you like.

Warning: make sure you use a relay made for the voltage you are going to use for the circuit. If you are using a 12V relay make sure you use 12v in the BAT1 place

here is the code:

/***********************************************************************************/
#include //include the comunication library
#define RxPin 0 //define the receiver pin
#define relay 4
#define sensor1alarm 1
#define sensor2alarm 2
#define sensor3alarm 3

void setup()
{
MANCHESTER.SetRxPin(RxPin); //user sets rx pin default 6
MANCHESTER.SetTimeOut(1000); //user sets timeout default blocks
Serial.begin(9600); // Debugging only
//setting the pins in arduino
pinMode(sensor1alarm, OUTPUT);
digitalWrite(sensor1alarm, LOW);
pinMode(sensor2alarm, OUTPUT);
digitalWrite(sensor2alarm, LOW);
pinMode(sensor3alarm, OUTPUT);
digitalWrite(sensor3alarm, LOW);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
}//end of setup

void loop()
{
unsigned int data = MANCHESTER.Receive();

if(data==50) //match this number with the sensor number
{
for(int i=0 ; i {
digitalWrite(sensor1alarm, HIGH); //turn ON the sensor1alarm led
delay(500);
digitalWrite(sensor1alarm, LOW); //turn OFF the sensor1alarm led
delay(500);
}

}//end of if

if(data==100) //match this number with the sensor number
{
for(int i=0 ; i {
digitalWrite(sensor2alarm, HIGH); //turn ON the sensor2alarm led
delay(500);
digitalWrite(sensor2alarm, LOW); //turn OFF the sensor2alarm led
delay(500);
}

}//end of if

if(data==150) //match this number with the sensor number
{
for(int i=0 ; i {
digitalWrite(sensor3alarm, HIGH); //turn ON the sensor3alarm led
delay(500);
digitalWrite(sensor3alarm, LOW); //turn OFF the sensor3alarm led
delay(500);
}

}//end of if

if(data==200) //match this number with the sensor number
{
for(int i=0 ; i {
digitalWrite(relay, HIGH); //turn ON the relay
delay(500);

}

}//end of if


}//end of loop
/***************************************************************************************/

any questions write me in the coments please :)

Cheap Wireless Motion Sensor Device
receiver_bottom.pdf289 KB
Cheap Wireless Motion Sensor Device
receiver_top.pdf57 KB
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel