Sie sind auf Seite 1von 21

instructables

Cheap Wireless Motion Sensor Device

by Jochefor

I think we all have the dream to became a super spy, want to figure out the way to make it cheap for
so if you are in a secret mission, you are doing everyone so I use an attiny85, a pir sensor (motion
something in your house and you don't want to get sensor) and a rf link to make the project work.
caught, our you are just eating all the cookies in the
kitchen and you want to know if your mother is If you like this proyect please follow my blog on
coming, the wireless motion sensor devices are for facebook: (is in spanish) Facebook page or enter to
you. my blog http://bioespin.com/

I see a lot of wireless in de web and in movies, but i

1. pir sensor , used to detect movement

Cheap Wireless Motion Sensor Device: Page 1


Step 1: Material

I order my material from a sparkfun distribution in http://www.sparkfun.com/products/8630


México because is where i live but if you live in USA
you can order barely all the material from sparkfun. 9.95 dolar

1 pir sensor
1 rf receiver 315mhz

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

4.95 dolar 4 resistance 180ohm

1 resistance 10k ohm


1 rf transmiter 315mhz
normally open button (optional)
http://www.sparkfun.com/products/10535
1 8 ohm speaker (optional)
3.95 dolar
1 ic 8 pin base

1 attiny85 1pnp transistor ( you can use the 2n2222, just check
out the collector and emitter pins are in the right
http://www.sparkfun.com/products/9378 place)

2.84 dolar 1 lm7805 (5v regulator)

3 electrolitic capacitors 10uf 50v


1 arduino uno

1. rf receiver. its really easy to use because of the


indicators in each pin

Cheap Wireless Motion Sensor Device: Page 2


1

1. this is the transmitter 1. be carefull. red: 9 to 12 volts. brown: ground. black: 5V signal, get low when
activated

Cheap Wireless Motion Sensor Device: Page 3


Step 2: Hardware

As you can see in the image everything in the circuits For the receiver I was going to do also a attiny85
works with 5Volts but the pir sensor works with 9 to device, but I was short in time so I end up making an
12 volts. To fix this and save the work and spend of arduino shield with a speaker. (If somebody want the
connecting the circuits to 2 different kind of voltage i pcb for the attiny85 receiver I'm in half production and
use a lm7805, that is a 5Volts regulator, and connect I will upload it later. thanks for the comprehension).
everything to a 9V(square) battery.
If you print the arduino receiver shield you got to be
If you want to make a pcb to have all the connections careful, the bottom copper side ends up in the top,
in a cleaner way I will put a pdf file below so you can also the pins are place in the bottom and solder
print it and transfer with the method you want. though the holes in the pcb, but all the other
component are solder from the upper part directly
2 connection do not fit in the design so y place them bending the legs. you can have a better look in the 5
with wires. (the two connections are the yellow ones to 8 images.
in the second image)

3 2
7

4
8

6
5

1. place this yellow connections with cables


2. positive 9V
3. Ground
4. switch
5. transmiter
6. transmiter antena
7. led
8. normally open button optional, just to reset the system

Cheap Wireless Motion Sensor Device: Page 4


1

1. here you can see how i bend the legs and solder from the upper side

2
1

1. also with the leds, resistance, and speaker i solder frm the upper side
2. the pins go through the holes in the pcb to make contact from the
bottom to de arduino

Download
http://www.instructables.com/ORIG/FSO/RCGO/H2WESN0U/FSORCGOH2WESN0U.pdf

Cheap Wireless Motion Sensor Device: Page 5


http://www.instructables.com/ORIG/FE6/GN8G/H2WESN0V/FE6GN8GH2WESN0V.pdf
… Download

Step 3: Software

To program the attiny85 you can use the arduino uno rel="nofollow">http://mchr3k-
as isp programmer. You can look this link arduino.blogspot.mx/2012/01/wireless-sensor-node-
(http://hlt.media.mit.edu/?p=1706) for more part-2.html?
information about this procces, but you dont need to showComment=1338749638806#c853067277980266
because im gonna explain everything in detail. 192

I use a attiny because is cheaper than use an download the attiny45_85.zip and the
arduino. you can buy a attiny85 for 2.84USD, manchester.zip files.
compare to an arduino for about 38 dolars. Using an
attiny to comunicate through a rf link represent a 3. Unzip the attiny45_85.zip file. copy the folder.
chalenge because the attiny doesn't have a rx or tx open the arduino-0022 folder. Open hardware and
serial comunication by default. I want to thanks this paste the attiny45_85 folder there.
blog (http://mchr3k-arduino.blogspot.mx/) for make
the program that make possible to comunicate with 4.Unzip the manchester.zip file. open that
an attiny. manchester folder and you should see two other
folders. core and MANCHESTER.
ok. so let go to step by step programing. copy de MANCHESTER folder.
open again the arduino-0022 folder. but this time
1. go to the arduino oficial site and download the open the libraries folder. paste the MANCHESTER
arduino-0022 software. (don't use the arduino 1.0, it folder there.
doesn't work). Unzip the file. you should see a folder
name arduino-0022. Now you have the software ready to program.

2. go to this link. 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. 7. On the arduino program go to tools>board>attiny85


(w/ Arduino as ISP). click again tools>burn
6. Place the attiny85 in a protoboard (breadboard), bootloader>w/ Arduino as ISP. (you may see a error
and connect everythingh to the arduino as the image. but that's ok).
Be shure you place the attiny in the correct way or
you are going to burn it. (happened to me :P) . ok, So let's make the program for the transmitter.

Cheap Wireless Motion Sensor Device: Page 6


Step 4: Transmitter

here is the program for the transmitter. if you make state of the motion sensor
the last step in order now you just have to place the if(pirVal == LOW)//if pir sensor detect movement then
code in the arduino program and upload it.
{/*action, in this case turn ON the transistor to power
#include //include the library to comunicate the transmitter then send the message,
#define TxPin 2 //the pin that is used to send data the turn OFF the transistor*/

unsigned int Tdata = 0; //begin the data in 0 digitalWrite(TRANSISTOR_PIN, HIGH);//transistor


ON
int TRANSISTOR_PIN = 1; //pin that turn ON and delay(1000);
OFF the transistor
int PIR_SENSOR_PIN = 0; //the motion sensor pin 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
void setup() receiver
{
MANCHESTER.SetTxPin (TxPin); //set the pin of MANCHESTER.Transmit(Tdata); //transmit the signal
comunication delay(100);
pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT); digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF
} transistor to save battery
}
void loop() delay(2000);
{ }
int pirVal=digitalRead(PIR_SENSOR_PIN); //read the

Cheap Wireless Motion Sensor Device: Page 7


Cheap Wireless Motion Sensor Device: Page 8
Step 5: Receiver

for the receiver you just have to program the arduino. pinMode(sensor1alarm, OUTPUT);
So go to tools>board and select arduino uno. digitalWrite(sensor1alarm, LOW);
copy this code. and Upload it. pinMode(sensor2alarm, OUTPUT);
digitalWrite(sensor2alarm, LOW);
#include //include the comunication library pinMode(sensor3alarm, OUTPUT);
#define RxPin 6 //define the receiver pin digitalWrite(sensor3alarm, LOW);
#define speaker 9 pinMode(speaker, OUTPUT);
#define sensor1alarm 12 digitalWrite(speaker, LOW);
#define sensor2alarm 11 }//end of setup
#define sensor3alarm 10
void loop()
void setup() {
{ unsigned int data = MANCHESTER.Receive();
MANCHESTER.SetRxPin(RxPin); //user sets rx pin
default 6 if(data==50) //match this number with the sensor
MANCHESTER.SetTimeOut(1000); //user sets number
timeout default blocks {
Serial.begin(9600); // Debugging only digitalWrite(sensor1alarm, HIGH); //turn ON the
//setting the pins in arduino sensor1alarm led

//paste in here if you have another transmitter


for (int i=0; i<500; i++) { // generate a 1KHz tone for
1/2 second }//end of loop
digitalWrite(speaker, HIGH);
delayMicroseconds(500);
digitalWrite(speaker, LOW);
delayMicroseconds(500); /*if you have more than one transmiter you just have
} //end of for speaker 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
digitalWrite(sensor1alarm, LOW); //turn OFF the in the other transmitter.*/
sensor1alarm led
delay(500);

}//end of if

Cheap Wireless Motion Sensor Device: Page 9


1

1. arduino shield place in the arduino

1 2 3

1. alarm1
2. alarm2
3. alarm3
4. speaker

Cheap Wireless Motion Sensor Device: Page 10


1

1. this represents the receiver

Download
http://www.instructables.com/ORIG/FMU/7ESA/H2WESV39/FMU7ESAH2WESV39.pdf

Step 6: Conclusion

You can place your sensor in every case you want. I other sensors with a little changes in the design and
place mine in soda cans because I think no one is you can have temperature sensors, sound sensors,
going to check if there is something wrong with a can. ultrasonic sensors, gas sensors, infrared sensors,
and you can place everywhere and doesn't seems and a lot of other sensors for a cheap price that can
weird. So enjoy been a secret spy or just protect your sense things from a safe distance).
house from strangers in the night. the uses are
endless, you just have to put your creativity to work a I hope you enjoy this instructable :), sorry if my
little. english is not the best.

p.d. (you can change the motion sensor, for a lot of

Cheap Wireless Motion Sensor Device: Page 11


1

1. cut the bottom part with the dremel or a knife

1. this is an incomplete pcb :P just for the picture

1. other sensor, i will paint the interior black and place the label back in
place

Cheap Wireless Motion Sensor Device: Page 12


Step 7: How to Use 3 Transmitters With One Receiver

this is the code for using 3 motion sensors with one for (int i=0; i<500; i++) { // generate a 1KHz tone for
receiver: 1/2 second
digitalWrite(speaker, HIGH);
//use this for the receiver delayMicroseconds(500);
//******************************************************** digitalWrite(speaker, LOW);
*************************************** delayMicroseconds(500);
} //end of for speaker
#include //include the comunication library
#define RxPin 6 //define the receiver pin
#define speaker 9 digitalWrite(sensor2alarm, LOW); //turn OFF the
#define sensor1alarm 12 sensor1alarm led
#define sensor2alarm 11 delay(500);
#define sensor3alarm 10 }
else if(data==150) //match this number with the
void setup() sensor number
{ {
MANCHESTER.SetRxPin(RxPin); //user sets rx pin digitalWrite(sensor3alarm, HIGH); //turn ON the
default 6 sensor1alarm led
MANCHESTER.SetTimeOut(1000); //user sets
timeout default blocks
Serial.begin(9600); // Debugging only for (int i=0; i<500; i++) { // generate a 1KHz tone for
//setting the pins in arduino 1/2 second
pinMode(sensor1alarm, OUTPUT); digitalWrite(speaker, HIGH);
digitalWrite(sensor1alarm, LOW); delayMicroseconds(500);
pinMode(sensor2alarm, OUTPUT); digitalWrite(speaker, LOW);
digitalWrite(sensor2alarm, LOW); delayMicroseconds(500);
pinMode(sensor3alarm, OUTPUT); } //end of for speaker
digitalWrite(sensor3alarm, LOW);
pinMode(speaker, OUTPUT);
digitalWrite(speaker, LOW); digitalWrite(sensor3alarm, LOW); //turn OFF the
}//end of setup sensor1alarm led
delay(500);
void loop() }
{
unsigned int data = MANCHESTER.Receive(); }//end of loop

if(data==50) //match this number with the sensor //********************************************************


number ******************************************
{ //use this for one of the transmitters
digitalWrite(sensor1alarm, HIGH); //turn ON the //transmitter 1.
sensor1alarm led
#include //include the library to comunicate
#define TxPin 2 //the pin that is used to send data
for (int i=0; i<500; i++) { // generate a 1KHz tone for
1/2 second unsigned int Tdata = 0; //begin the data in 0
digitalWrite(speaker, HIGH);
delayMicroseconds(500); int TRANSISTOR_PIN = 1; //pin that turn ON and
OFF the transistor
Cheap Wireless Motion Sensor Device: Page 13
OFF the transistor
digitalWrite(speaker, LOW); int PIR_SENSOR_PIN = 0; //the motion sensor pin
delayMicroseconds(500);
} //end of for speaker
void setup()
{
digitalWrite(sensor1alarm, LOW); //turn OFF the MANCHESTER.SetTxPin (TxPin); //set the pin of
sensor1alarm led comunication
delay(500); pinMode(TRANSISTOR_PIN, OUTPUT);
pinMode(PIR_SENSOR_PIN, INPUT);
}//end of if }
else if(data==100) //match this number with the
sensor number void loop()
{ {
digitalWrite(sensor2alarm, HIGH); //turn ON the int pirVal=digitalRead(PIR_SENSOR_PIN); //read the
sensor1alarm led state of the motion sensor

Cheap Wireless Motion Sensor Device: Page 14


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,
{/*action, in this case turn ON the transistor to power the turn OFF the transistor*/
the transmitter then send the message,
the turn OFF the transistor*/ digitalWrite(TRANSISTOR_PIN, HIGH);//transistor
ON
digitalWrite(TRANSISTOR_PIN, HIGH);//transistor delay(1000);
ON
delay(1000); Tdata = 100;

Tdata = 50; MANCHESTER.Transmit(Tdata); //transmit the signal


delay(100);
MANCHESTER.Transmit(Tdata); //transmit the signal
delay(100); digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF
transistor to save battery
digitalWrite(TRANSISTOR_PIN, LOW);//turn OFF }
transistor to save battery delay(2000);
} }
delay(2000);
} //********************************************************
***********************************
//******************************************************** //use this for transmitter 3
************************************ //transmitter 3.
//use this for the secod transmitter.
//transmitter 2. //receiver 2.

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

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

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

void setup() void setup()


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

void loop() void loop()


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

Cheap Wireless Motion Sensor Device: Page 15


{/*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

Some of you ask if I can upload the receiver pcb for delay(500);
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. }//end of if
I hope you like them.
if(data==100) //match this number with the sensor
I leave the 3 leds as in the arduino version but number
instead of placing a speaker y place a relay so you {
can activate any device you like. For example your for(int i=0 ; i<15 ; i++)
house lights, an alarm or any device that you like. {
digitalWrite(sensor2alarm, HIGH); //turn ON the
Warning: make sure you use a relay made for the sensor2alarm led
Cheap Wireless Motion Sensor Device: Page 16
voltage you are going to use for the circuit. If you are delay(500);
using a 12V relay make sure you use 12v in the digitalWrite(sensor2alarm, LOW); //turn OFF the
BAT1 place sensor2alarm led
delay(500);
here is the code: }

/******************************************************** }//end of if
***************************/
#include //include the comunication library if(data==150) //match this number with the sensor
#define RxPin 0 //define the receiver pin number
#define relay 4 {
#define sensor1alarm 1 for(int i=0 ; i<15 ; i++)
#define sensor2alarm 2 {
#define sensor3alarm 3 digitalWrite(sensor3alarm, HIGH); //turn ON the
sensor3alarm led
void setup() delay(500);
{ digitalWrite(sensor3alarm, LOW); //turn OFF the
MANCHESTER.SetRxPin(RxPin); //user sets rx pin sensor3alarm led
default 6 delay(500);
MANCHESTER.SetTimeOut(1000); //user sets }
timeout default blocks
Serial.begin(9600); // Debugging only }//end of if
//setting the pins in arduino
pinMode(sensor1alarm, OUTPUT); if(data==200) //match this number with the sensor
digitalWrite(sensor1alarm, LOW); number
pinMode(sensor2alarm, OUTPUT); {
digitalWrite(sensor2alarm, LOW); for(int i=0 ; i<15 ; i++)
pinMode(sensor3alarm, OUTPUT); {
digitalWrite(sensor3alarm, LOW); digitalWrite(relay, HIGH); //turn ON the relay
pinMode(relay, OUTPUT); delay(500);
digitalWrite(relay, LOW);
}//end of setup }

void loop() }//end of if


{
unsigned int data = MANCHESTER.Receive();
}//end of loop
if(data==50) //match this number with the sensor /********************************************************
number *******************************/
{
for(int i=0 ; i<15 ; i++) any questions write me in the coments please :)
{
digitalWrite(sensor1alarm, HIGH); //turn ON the http://bioespin.com/
sensor1alarm led
delay(500);
digitalWrite(sensor1alarm, LOW); //turn OFF the
sensor1alarm led

Cheap Wireless Motion Sensor Device: Page 17


7
6
5
4
3

2
1

1. with this relay you can activate any device you want
2. with this relay you can activate any device you want. Be sure you use a relay made for your
voltage
3. attiny85
4. 3 leds for the basic alarm detection
5. 3 leds for the basic alarm detection
6. 3 leds for the basic alarm detection
7. voltage regulator so you can use 9v to 12v

Download
http://www.instructables.com/ORIG/F4M/FNXN/HFSHG4IR/F4MFNXNHFSHG4IR.pdf

Cheap Wireless Motion Sensor Device: Page 18


http://www.instructables.com/ORIG/FGM/LI01/HFSHG4IS/FGMLI01HFSHG4IS.pdf
… Download

Hello I'm beginner and I don't know how to manage this problem. can someone help ?
i got this message and I need example how to fix it . I have no idea yet about command
"Manchester was not declared in this scope"
MANCHESTER.SetTxPin (TxPin); //set the pin of comunication
really thanks for your help
I am not good at this but #include is one way to declare an item to scope.
I get this all the time but no one answers it!
Yes, like Liamthe1st said, you must include it in the program. you have to download the library via
the link the author supplied on step 4, and then move it to the "libraries" folder in the Arduino
software. Sparkfun has a really good tutorial for this.
that is it

Barancan projen ilgimi çekti acaba türkçe bir kaynak var mı ?


Hi, can I do 1 transmitter and maybe 3 receivers?

you can make 1 transmitter with all the receivers you want

please i need you to put me through on a project am working on


copy your first receiver and you have receivers! ^^
Hi everyone,
One could also use https://kerberos.io/, it runs on the Raspberry Pi and it's also open source.
if i got the receiver/transmitter, the frequency is block, or can i change the frequencies for having
more censors?
I'm from vietNam
I like your share (Cheap Wireless Motion Sensor Device)
I building a smart home.
Thank you!..... and thank you!
// I used google translate ^^
hi friend
i have one question ...this codes work for raspiberry pi instead of arduino ?
regards
happy new year
How would it work with an existing wireless motion sensor ?
I am trying to re-use some wireless motion sensors from my previous Wireless Home Alarm
system
ok..use arduino 1.0.3 and compile without error..

Cheap Wireless Motion Sensor Device: Page 19


now the weird thing is why the proteus picture got many component(2 resistor etc) and the other
picture only got like 7 component..did i miss something or that circuit include with voltage
regulator??
yes, is because in the component picture I only add the most important components, and if you see
the picture you need 5v and 12v. In the proteus picture I add a voltage regulator so you only need
one 12V voltage source, and the 5 volts are regulated from there.
ok..thanks sir..u are so helpful
ok..thanks sir..u are so helpful
this two messages are normal

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85

but the two below are not normal, I think you select the wrong programmer. You need to select the
"arduino as isp" programmer, I think you select "avrdude" as programmer in your options
i got this error message..is that normal??
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: invalid byte value (null) specified for immediate mode
avrdude: write to file 'null' failed
Ouch thats expensive you relize on Ebay you can get everything for this project for a lot less, exp
PIR sensor is only 1.75
I forgot to mention, the red pad its actually a wire that you need to place in the component side. I
place it like that because i dont have more room in the bottom part.
hey i was thinking of building a similar device and i had two questions.
One is there any way i can use this device to trigger a video to play?
and am not that much of a hardware connoisseur but i can follow some good instruction well, so
could i build this thing and expect it to work?
yes i think you can make that, but if you are not really good with hardware i recomend you to make
the easy way. buy two arduinos, the motion sensor and the tranmiter and receiver. its a little more
expensive but is way easier. instead of the attiny conect all to the arduino and program the arduino
the normal way. to trigger a video i recomen you to get an old keyboard, sold the enter button the
arduino and in that way you can concet the arduino to the pc without connecting the arduino
phisicaly. if you have more questions please ask. and i will like to see the final proyect when you
finish it :)
thanks! i'll give it a shot somehow since i have access to an arduino it will be much cheaper if i
attempt your model. maybe i'll make an extension to your intractable on how to make it play video.
Is it possible to use an attiny45 for either the xmitter or receiver? I ordered the xmit/rcv pair but
forgot that I'd need another uC. All I have on hand atm are 45's and tiny13's :(
yes you can usea attiny45's just when you program them make sure you select that option. I never
used them but I look in the sources I used and you can use them.
interesting. May build this :-)
thanks :)

¡Yo vivi en Centro America por casi siete años y su ingles es mucho mas mejor que mi
español!

Cheap Wireless Motion Sensor Device: Page 20


This is a great Instructible and very well written.
I don't know electronics, but this seems a very useful project.

thanks. it's really useful for me. I live in mexico and having this make me feel a little safer

Cheap Wireless Motion Sensor Device: Page 21

Das könnte Ihnen auch gefallen