Professional Documents
Culture Documents
Cheap Wireless Motion Sensor Device
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/
1 pir sensor
1 rf receiver 315mhz
http://www.sparkfun.com/products/10533 1 switch
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)
1. this is the transmitter 1. be carefull. red: 9 to 12 volts. brown: ground. black: 5V signal, get low when
activated
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. 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
…
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.
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*/
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
}//end of if
1 2 3
1. alarm1
2. alarm2
3. alarm3
4. speaker
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.
1. other sensor, i will paint the interior black and place the label back in
place
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
#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
digitalWrite(TRANSISTOR_PIN, HIGH);//transistor
ON
delay(1000);
Tdata = 150;
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 }
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
…
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
you can make 1 transmitter with all the receivers you want
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!
thanks. it's really useful for me. I live in mexico and having this make me feel a little safer