SuperHouseTV #13: Connecting security sensors to Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi i'm jonathan Aqsa and this is super house automation to me means that your environment or your house or whatever can adjust to circumstances it can change its behavior without you having to manually tell it what to do I mean that's what automation is right it's not just a matter of pressing a button and then a life in another room turns on or off or even doing it from around the world that's just being big remote control so in order to have a proper automation system what you need is some form of input like sensors so there is one really handy way you can do that it's a really good way to get started if you've already put some of the building blocks in place and now you want to add some automatic behaviors into your automation system what you can do is grab yourself some of these these are passive infrared motion detectors that are used in alarm systems they typically go up in the corner of the room someone walks into the room when the alarm is set and the alarm goes off the police are called or the security company but these things are pretty cheap and you know they're 20 bucks give or take they're really easy to use and the output is really just a little relay output which is like a switch so it's very easy to wire up to any kind of automation system so that you can have your house turn on the lights as you walk into a room and then what you can do is extend that depending on the type of automation system you have you might do something like have one of these in the passage and if it detects motion after say 11 p.m. or 12 p.m. it will turn the lights on but only it's a 20 percent elimination because it assumes that you just want the lights on enough to be able to get to the bathroom to go to the toilet or whatever and you don't want the lights to come on full brightness just because you're walking around the house at night but at other times of the day it might trigger the lights to come on for elimination and in either case if you have to go up press a button or click a switch and turn lights on the house has adapted to your needs that is what real home automation is about so open this up is actually pretty simple they have connections on them for power they just run up 12 volts and they have a normally closed output typically for the alarm circuit so what happens is if it detects movement the circuit is broken and then your system is notified if you don't care about security as such you can just treat this as a switch the output of it is just a switch that you can connect to your Arduino or your alarm panel or whatever a microcontroller system you want to use however to make this really secure there are some things you should know so imagine that in your house you have some kind of control system it could be a an alarm panel could be a microcontroller we'll just call it the panel for now like in security terms the panel is whatever is connected to and controlling everything else and over here you have your passive infrared motion detector with this detector panel there and this can detect any motion in front of it so you need to connect it back to the alarm panel or to the microcontroller now there are a couple of outputs on it the most important is the alarm output now the alarm output is normally closed so what that means is that it's a short circuit when it doesn't detect movement if it detects movement the alarm opens the circuit and that way you can detect that something has happened so the very simple way to connect this is to run a pair of wires all the way back to the panel from here and you can just treat this as a normally closed switch now that'll certainly work but you have some problems what happens for example if someone crawls into the route of your house and then short circuits across those wires after that the alarm can go off or the motion detector can detect motion but because the wire has been short-circuited the signal will never go back to the panel they can walk around in a house all day and the system will never know about it so we need some way to be able to protect against that so what we can do is use a system called end of line resistors now there are a number of different schemes for this a lot of systems use a single end-of-line resistor and there is also a double end-of-line resistor scheme I'll show you what I mean now imagine that we have this panel and we take a resistor and we put it in series with the output so what this means now is that there is a resistance through here when the switch is closed so the alarm hasn't been triggered if we measure the resistance of the entire circuit we know that it hasn't been cut because it was cut it will go to infinite resistance it hasn't been short-circuited because I don't go to zero resistance and it will be at a known state so if the alarm goes off it breaks the connection and it's effectively cutting the wire so it goes to higher resistance so then we have a system where we can detect whether the wire has been cut or short-circuited and we can also detect an alarm event now we can't distinguish between an alarm event and the way I've been cut we just know that there is an alarm event of some kind so you can get around that by putting another resistor in parallel with a normally closed output so we'll call that one resistor a and then we have the series resistor that resistor B so what this means is that in a normal condition the resistance will be the wire and then through the normally closed switch which bypasses resistor a goes through resistor B and then back down again so now what we have a situation where we can detect four possible states normally it's just resistor B wire is cut it's infinite wire short circuited at zero ohms if the alarm is triggered then it will be the resistance a plus B because they're in series so now we're in a pretty good shape we can detect wire tampering and we can detect alarm events but there's something else we can do to to extend this idea even further now typical motion sensors have a tamper switch inside them and this is so that the alarm system can detect if the panel is opened or if any of the sensors are open or physically tampered with even when the alarm is not armed now that can be really important imagine a situation where you have a retail establishment might be a shop with lots of people going through and you have motion detectors now normally during the day the alarm system will be disarmed so someone could walk up to a motion detector and temple with it and they could be doing whatever they like to it and because the system is disarmed that won't be detected now this is where tamper detection comes in with tamper detection there is another pair of outputs and once again this is a normally closed output so that's not a pair of terminals inside the motion detector that we can connect to so what we do is instead of wiring this back to here we take this resistor and run it into one side of the tamper switch we come back here and then we add another resistor in parallel with the tamper switch so we now have resistors a B and C which are in series apart from two of them being shorted out by the switches now you might say what benefit does this give seems pretty confusing but what it allows the alarm panel to do is detect whether the tamper has been triggered even when the alarm is turned off and that means that the alarm system needs to be in one of three possible States it can be in its regular disarmed state in which case people can move around the shop or the house or whatever the other might go off no alarms will be raised but if someone opens a motion detector or tethers the system the tamper switch will cause the alarm to go off because the alarm system knows that that is a tamper event as distinct from a motion event then it needs to be in an armed state which is where either a tamper or an alarm event is going to cause the alarm to be triggered or it can be in a maintenance mode and that is what an alarm technician will put it into using a special code at the control panel before they start doing any maintenance that may require them to open up the panel or open up any of the sensors or make any other changes to the wiring so what that means is that the alarm system can be checking the integrity of the entire system even while is disarmed and there might be people walking around inside the premises so that's our objective what we're going to do is wire up a motion detector using this triple end-of-line resistor system so that from a panel which could be an Arduino we can detect wire cut wire shorted we can detect an alarm state we can detect the tamper stage and of course we need to our form tamper and alarm at the same time and all of those events give different resistances depending on what resistor values we pick for here so because alarm sensors are typically at the end of a fairly long wire we want these to be moderately low values like you wouldn't use 20 or 30 K plot type resistors so usually what's used is something like about 4.7 K or a 2.2 K resistor now the important thing is to make sure that the values for a and C are not the same and that is what allows the pedal to detect the different events so the values that I typically use are for a resistor a I normally use 4.7 K for assistive B I typically use 2.2 K and for C I use 2.2 K so what that means is that in a normal operational state the only resistance that matters is B so the whole system will be resistance of 2.2 okay if Tampa has been triggered this switch is opened and it will be B plus C in series so 4.4 K if it's an alarm state then it will be a in B in series which means that will be 6.9 K and of course if it's tampered with and the alarm is triggered it will be a plus B IC which means we would have a total resistance of 9.1 K through the system and of course we can still detect line cut and line short events when choosing a motion detector there are several factors to consider firstly the type of lens this is a standard lens motion detector which means that it has about a 110 degree field of view it has a range between 7 and 10 meters or so and any motion in front of it will be detected you can also get a type that has a thing called a pet le lens and what that means is that it will attempt to ignore movement of small objects or objects that are very low and if you have a cat that walks around inside your house and you want to be able to turn your alarm on that might be the solution so if you have pets make sure you look for a motion detector that has a pet safety feature the other thing is that you can have standard passive infrared motion detector or what's called a dual technology detector now passive infrared detector we crack it open we can see what's inside it I typically just clip open have this little detector sensor down here and what that does is detect changes in reflected infrared radiation in front of it now with a dual technology sensor which I think I have to crack open from this end in this particular case you will see that it has the same sort of sensor down the bottom but up the top this is a microwave motion detector which basically operates like a radar so the one on the left is a standard motion detector is infrared only this one which is the dual technology sensor is infrared and radar what that allows it to do is have greater range better noise suppression better sensitivity so in general the dual technology senses operate better than standard infrared senses but standard infrared is fine typically the dual technology ones are used in large rooms like auditoriums or unusual circumstances so just put that one aside for now and have a little look at this one now there are a couple of things to notice firstly if you look at this little spring here let's connect it to a switch that's the tamper switch so when the case is closed the switch is pushed in and it's in it's normally closed position if this is mounted on the wall and someone opens it up the switch is released and the tamper terminals go open circuit which is how we detect tampering with the sensor you'll also see that there is an LED up the top here and this illuminates whenever the sensor is detecting movement that is normally used by installers to do what they call a walkthrough test and that is when all of the sensors are powered up they're functional and the alarm installer just walks through the premises and you can see just by looking at the sensor whether it has detected any movement now that's great for testing but a lot of people don't like that to be in used in normal operation because what that allows is an intruder or someone coming through the premises when the alarm is disabled to probe the sensitivity of these but you can walk very slowly in front of it for example and see if you can move without triggering the sensor but if you don't have that visual feedback you can't tell how sensitive the sensor is so here we have a little jumper if we take this jumper off that disables the LED so typically what happens is that an armed installer will do the walkthrough test and then they'll go around and remove all the jumpers from the sensors so there is no more visual feedback there are a couple of other jumpers in here one is the relay jumper in here so we can set two normally open or normally closed mode usually we want normally-closed and there is also a pulse count jumper and what this allows is for you to change the sensitivity essentially of the motion detector in its most sensitive mode in single pulse any movement in front of it will cause the alarm to be triggered this can lead to some false alarms though so by putting it into a different pulse count mode it might be a two pulse or three or five pulse it means that there need to be that many alarm events or motion events in front of it within a rolling window usually four seconds for the alarm to be triggered that can reduce false alarms but of course it also reduces sensitivity and finally across the top we can see all of the screw terminals there is a pair of terminals for positive and negative 12 volts which is the power supply there is the tamper output over here which is simply wired with the switch and there are the alarm outputs which are normally closed circuit because of the setting on the jumper and they go open circuit when the alarm is triggered now you'll also see that there are some dimples in the back of the case here those are the various purposes those are deliberately weakened points in the case and they can be used for screwing to the wall you can use a electric screwdriver and then just try the self tapping screws straight through the case to attach it in position and you can also use those and punch them out to run cable through typically the cable will come through in near the top of the the detector and will come through and then be screwed into the terminals here so the cable is totally concealed behind the unit when it's attached to the wall the quick and dirty way to fit the end of line resistors and this is what most alarm installers do is just to bend them around stick them into the screw terminals put the wire in screw it all together then you just push these down out of the way now that certainly works but I find that that's really annoying because typically when you're installing this you'll be hanging off a ladder somewhere it's kind of awkward you're holding a screwdriver and all these bits in your hands you don't want to drop things so what I usually do is prepare all my motion to take this in advance by opening them up taking the circuit boards out it's really easy to do it's usually only held in by one screw and then just sole during their resistors directly across the terminals on the back in the pattern that I showed earlier using 1 4 k 7 resistor and a couple of 2k 2 resistors so that way once you're up the ladder your motion detector is all prepared all you got to do is push the wires in screw them on it's a lot less they can go wrong when you're in an awkward physical situation so here's another motion detector that I did this too in preparation I'll crack this one open and you can't really even see them that's a bit difficult to see but just under there are some resistors there hiding under the circuit board and I've already connected up this wire so I've drilled a hole through the case and I've put some four core cable through it I've got black and red four negative and positive 12 volts I'm using a blue and white pair and I'm connecting it from one of the tamper terminals to the opposite side alarm output terminal and normally this would not be sufficient but of course we have those resistors under the circuit board bridging across those terminals so this is all set up ready to go with the triple end-of-line resistor system so let's power it up and measure the resistance and see if this really behaves the way we expect it to the PIR is now powered up we've got 12 volts supplied down the cable from a bench power supply and also I have the multimeter connected across the output terminals measuring resistance as you can see it's currently showing 2.2 K which is what we expect when the motion detector hasn't been triggered if I move my hand in front of it you'll see the resistance will jump up goes up to about 6.9 K which is what we expect given the resistors that are inside there now I shut it with my hand and you can probably just barely see the LED if I hold my hand very still it's now dropped out of alarm mode and by moving again you'll see the LED turn on and the resistance has changed and of course if I shorted these wires or broke this connection would also get infinite resistance or get zero resistance so we've got all those cases covered and now if I open up the case which will trigger the tamper sensor you'll see that the resistance is now about 9.1 K or a little bit under based on the tolerance of these resistors now once that it drops out of alarm mode it's going back to 4.4 K which once again is what we expect given that the system has a line integrity but the tamper switch has been depressed and if I push the tamper switch we can also see the value change so now you have a motion detector with the end of line resistors in place you have an Arduino and you connect them up well let's have a look at a good way to do that what you can do is basically imagine that the or motion detector with its resistors inside is just a big variable resistor so if you have a typical hard we know board it'll have some analog inputs so I say we're talking about analog input 0 it's also going to have a ground connection internally with a terminal for it and we'll have a connection which is probably 5 volts or 3.3 volts depending on how it runs now if you connect a resistor between the high voltage and the analog input and then you have another resistor between this point and ground what the analog input will see is a voltage which is divided between 5 volts and 0 volts depending on these two resistors so I'll draw this other resistor in here now just to show you what it would look like this is the classic voltage divider now what we actually have over here is our motion detector with its two terminals and inside it's got all its resistors and various things that have been wired up basically this is a big variable resistor so what we can do is simply take the two terminals that we want a wire while one through to ground on the arduino this resistor disappears because it's been replaced by our motion detector and then went by this route to the arduino so what we have now is an analog input that can read different values depending on the state of the motion detector because this resistor is fixed so if we put say a 4.7 kilo ohm resistor here and this resistance will vary between 2.2 K or 4.4 K or 9.1 K or whatever depending on the state of the alarm of the motion detector we can then detect those events of the arduino so then just imagine that this is a long bit of wire it goes from here all the way through to your sensor now this is going to expose an analog pin to a very long piece of wire which is effectively an antenna now that's not really ideal there are a couple of things that can be done to protect it what you can do is put a resistor in series at this point this could be say a 1k resistor that allows the analog input still to detect the voltage at this point in the voltage divider but it gives a bit of inrush current protection it should reduce likelihood of damage to the analog input you can also do things like put lightnings to suppresses or you know a protection zener across this so we could have a zero here or like a young a lightning protection system and that would prevent the voltage on this input from going too high and hopefully protect this now these sorts of protection systems are often found on USB connections so these parts are pretty easily available so as you can see it's basically an Arduino and a couple of resistors and you're done in fact you could get away with just not we know and one resistor if you really wanted to so you could just wire that up yourself you can take your Arduino take the analog inputs and put a resistor in place but that gets really annoying and also you need somewhere handy to wire up the power because we also want 12 volts going to our motion detector so what it did was laid out a little shield this is a security sensor shield that I designed a while ago and it's got handy screw terminals on here for the connections to be infrared motion sensors it's got connections to V in which mean or to the screw terminals here which means that you can supply 12 volts to your Arduino in fact what we can do is go stick this on the Arduino right here if we run 12 volts into here then we will have 12 volts available on each of these screw terminals and we also have the two connections for the sensor line now this shield already has four k7 resistors in place on it and it also has an LED next to each screw terminal so that the Arduino can display the status that it's detecting all the connections are now in place we're not designing the shield I also added some holes so that I could run cable ties through and mechanically mount the cable really strongly that's very important because you need to make sure that these connections aren't going to move we don't want pressure hanging on the screw terminals themselves so now we can just check this onto the Arduino and if we apply 12 volts to it through the Arduino power you see we've got power on the shield 12 volts the motion detector is now powered up it's in its warm-up mode which reminds me when you first power these up they will always act as if they're triggered for a little while it's because it needs to stabilize its internal sensor so when you first turn it on and power it up if it looks like it's just always triggered don't worry it's not broken but it sit there for a minute and I should settle down just for some quick feedback I've loaded up a sketch on the Arduino fitted an LCD shield and it's just reading the analog input and giving us the value displayed on the screen and it's also looking at whether the number is within a certain range and it's showing the state of the sensor so at the moment sensor isn't triggered at showing normal values analog reading is 323 out of 1023 if I move my hand over the sensor goes to 606 and the Arduino then knows it's an alarm state now I'm hiding in the doorway to my home office because just up around the corner there is a motion detector that's now connected up to an Arduino published into MQTT so if I step into the garage to pick up the motion and the lights come on brilliant so check out the website for all the code and there should be detailed instructions for how to make this happen see you next time you
Info
Channel: SuperHouseTV
Views: 101,494
Rating: undefined out of 5
Keywords: Home Automation (Competitive Space), Arduino (Brand), Automation (Industry), Electronics (Field Of Study), Technology (Industry), Security Alarm (Invention)
Id: NfPDpwtPi6g
Channel Id: undefined
Length: 26min 33sec (1593 seconds)
Published: Wed Apr 01 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.