How To Turn A Dummy Cam Into A Smart IOT Security Camera! (Text Notifications!)



welcome back guys in this video I'm gonna be walking you through how I took a dollar store dummy camera and turn it into a smart security device for my home and so we're gonna be starting this project with a dummy security camera from the dollar store and these cameras come in white and black and they are as described so they do pretty much nothing except for when you put a double-a battery inside there is a red flashing light in the front to simulate a real security camera and so we're gonna begin by taking apart our W camera and the first thing you can do is snap the top cover off it just pretty much pulls off and snaps off and the bottom ball joint metal comes off with a single Phillips head screw the back cover also has four Phillips head screws and the front cover has four Phillips head screws so we're gonna get to work with our screwdriver and remove all of these things so with the front cover and the back cover removed you can see the whole thing pretty much just falls apart in your hands and you're left with the shells of the top half and the bottom half now on the top half you'll see this is where the batteries are housed so on the top side I've also removed the cover which just snaps off and that's where you put two double-a batteries the positive and negative terminal are connected to the red flashing LED which sits in the front cover and so there's a couple more screws here small Phillips heads again that we're gonna remove and we're gonna desolder these wires to that flashing red LEDs after desoldering our red LED and removing the hot glue that was keeping it in the back of the front cover and removing the three screws from the back of the front cover we're left with our top case here with of course no batteries in it three screws which we don't want to lose and this top cover which we can now take apart and see what's inside so there is this back face with the fake camera lens on it where you see a bunch of also fake LEDs there is a retainer ring here and a clear lens in the front so of course these are some things that we don't want to lose because we're going to be reusing a lot of these parts and we're going to be incorporating our PIR motion sensor into this front lens and hiding it behind these pieces here and so after an even closer inspection of this fake front lens we can actually see that the camera lens pushes out from the backside and we're left with just the fake LEDs now unfortunately it's a little bit too small to fit in the PIR sensor but a round file will make quick work of this hole and we should be able to fit this right through the center hole so I've gone ahead and filed the center of this fake lens and it fits on top of the PIR sensor but why settle for fake LEDs when we can use real LEDs so I replicated this piece with a 3d printed part which fits on top of the PIR lens and it accepts five millimeter super-bright white LEDs now these can be triggered when the PIR sensor is triggered to flash or stay on we can program that later whatever we want all of these 3d printed parts in this video I will make available in the description down below and it'll take you to a link on my finger's page where you can download these and replicate them for yourself with a few dabs of hot glue the PIR sensor has been attached to the 3d printed part and with the three original screws the 3d printed part is now attached to the front cover take special note of the orientation of the PIR sensor so the adjustment screws are facing downwards and downwards would be the direction where the original red flashing LED was mounted so it would have been in this hole here looking at it from the front you can see that the PIR sensor is obviously in the center and we're missing all of our white LEDs so we're going to start inserting those next so now I've gone ahead and I have inserted each of the five five millimeter super-bright white LEDs into place on the 3d printed part and I fixed them in place with a little bit of hot glue and these LEDs are all gonna be wired in parallel and so you can see the red jumper wire going from each LED so this is connecting all the positive leads of those five white LEDs the negative leads are all connected with current limiting resistors and they come up to one single point here so all of these are like I said wired in parallel what you'll also notice is at the bottom I have another little five millimeter what looks like an LED fixed in place here with some hot glue but it's actually just a photo resistor which is a little light sensor I have not yet wired that up but it's in place and in the top right hand corner there is what looks like again they're led and it is an LED but it's the original flashing red LED from the dummy camera so we're going to reuse that so we can retain that flashing function so it looks like something is recording so looking at this thing from the front side now you can see the PIR sensor in the middle surrounded by the five super-bright white LEDs the photo resistor at the bottom here and this guy up here will be the original flashing red LED but the front cover now sorted out we can take a look at the brains behind this project and what we have here is the we most d1 mini and this little device is going to allow us to connect our project to the internet then using the if this then that protocol we can send ourselves alerts based on the activity that the camera picks up mounting this device inside of our camera should be pretty easy since our camera is essentially an empty tube so what I've done is I've taken these two 3d printed parts which I've designed and they are designed to fit together like so you can see those tabs that actually just fit into one another and the we mouse is going to sit with its header pins inside these slots right here and the protoboard will sit on the other side and it'll get soldered through the header pins essentially clamping it into place and then of course we can solder onto these little pins here and wire up the rest of our project according to the schematic after a bit of soldering off-camera you can now see the whe most d1 mini has been attached to the 3d printed part by means of soldering it to the prototype board on the other side so it's sort of clamped in place here and you'll also notice the transistor and its base resistor have been soldered to the prototype board those of course being connected to the way most d1 mini and those will be turning the white LEDs on and off so this transistor is more or less just going to act like a switch driving that load you'll also notice a bunch of wire leads here and it's actually quite simple we got two wire leads here for the photo resistor we have a red positive here for our le white LEDs we have a red positive here for the PIR sensor we have a negative wire for our PIR sensor we have the signal wire for our PIR sensor and the last ground wire here is for our white LEDs and of course attached to the transistor completing that circuit so we can use it like a switch moving on we have the front cover again and the top cover with a battery holder and this is just going to slip into place like this and we can put it upside down and we're gonna start mocking things up here and so I've also gone ahead and glued the second 3d printed part to the first 3d printed part so just using a little bit of hot glue on those tabs it's now together and we still have these free wire leads here and we're gonna place this inside of our housing we can start to see how things are going to start sitting inside of our dummy camera which is soon to be a smart camera and you can see all the excess wire on the wire leads I obviously did that on purpose so that now I can start cutting those down and making our connections so like I said we're gonna cut these down strip the ends and start soldering them to the appropriate connections on the front cover a few short minutes later I have the wire leads cut down to size and soldered into place and in a few locations where there are other wires in close proximity I've added a little bit of heat shrink tubing to prevent shorts you can see on the bottom of the bottom two adjustment screws from the PIR sensor are still accessible I've bent the wire leads out of the way so you can still get at them with a screwdriver and the 3d printed part here holding our we most d1 mini has not yet been hot glued into place and the reason for that is just in case we've many any mistakes with the wiring we can still pull it up access it and sort of correct anything we've done incorrectly also in the back now we are going to take a look at the programming so it's time to plug in our USB connection and this is what we're gonna use of course to program B we mostly one mini as well as provide power to this project so let's take a break from the physical build and look at the programming so all of the programming in this project is gonna be done in the arduino ide and for those of you guys new to arduino you're gonna have to head over to the website arduino dot CC and you're gonna have to find the download link and although we aren't actually using an arduino in this project the ide can be used to program different boards including the wii most the many that we're using next you're gonna want to download the drivers for the Wii most d1 mini so your computer recognizes it when you plug it in to the USB port so you're gonna want to head over to the wiki page for we MOS head over to the download section and download the appropriate driver one for Windows and one for Mac if you're using a Mac now you can fire up the arduino ide head over to file preferences and then click the little box here beside the additional boards manager and input this link here i will zoom in on it so you can see the link pause it and of course copy it this is going to allow the arduino ide to interface and program additional boards specifically be.we most you on mini so later on when it comes time to program you'll see that we most elon menu come up as a selectable board at this point we need to sign up for a few services that's going to allow us to get notifications like text messages or emails when our camera is triggered now the first place we're going to sign up here is IFTTT calm and let stands for if this than that and you can just go ahead and sign up for a free account then head over to io adafruit.com and also sign up for a free account this is a great dashboard type service that allows you to monitor your IOT devices and if root also offers a great learning center where you can learn how to use other products including the io dashboard that i just showed you so here we have a little tutorial and I'll zoom in on the link in the top left hand corner here so it's learned adafruit.com and you can see the rest of the link there and this is going to take you through how to set up the arduino ide with the software libraries so you can go to sketch include library manage libraries and then scroll down here and take a look at which software libraries you're going to need so there's the Adafruit bio Arduino library there's a the Arduino sorry data from MQTT library there's Arduino HTTP library and then also when we go into our arduino ide and the library manager one of the other libraries here that i would like you to download if you'd like to be able to very easily manage your Wi-Fi connections with your project is the what's called scroll up a little bit Wi-Fi manager so you're gonna want to search for Wi-Fi manager and download the one or rather install the one called Wi-Fi manager by t's app you also when we go back to the Adafruit tutorial here take a look at this receiving an error when compiling your sketch so I actually had this problem and this did solve my problem so pay special attention to this resolution here if you're also having this problem and so you'd have to actually go back into the board manager in the arduino ide and downgrade your esp8266 board manager here to version two point four point two and that should get rid of any errors you have later on if you run into them like I did now that we have a lot of the background stuff figured out we can look at the finer details of how we're gonna get this thing to work and so the first thing you need to do is sign into your Adafruit IO account and up on the left hand side here click on where it says feeds so it's gonna bring you to a screen that looks like this you're not gonna have any feed set up just yet if you're new to Adafruit IO and you're gonna want to create a new feet so you're gonna go to actions create a new feed you're gonna give it a name I called mine gate and you can just give it a quick description there and then hit create so you can see here that I've already created the gate feet so now that I click on this gate feed it'll bring me into the details on the right hand side we can look at the feed info so we're going to click on the little gear icon and you can see that it's still named gate no disappeared there it's still named gate but the key is the same as the named gate just in all lowercase this is what we're gonna use in our code later on to reference this feed so I can close this and you can set up other details like privacy so mine is set up as private and you can play with other things to feed history disabling it license and that sort of thing that's enough to get us started for now and you can actually also click on this view a ioki so in yellow here if you click on that this is going to give you your unique key for your account and we're gonna need to copy and paste that maybe in a text file something where you can reference it later on in the code but you might as well do that now just copy and paste it and don't share this with anyone because this is gonna give people access to your feeds in your account so if you want to keep things private store it away and don't show it to anybody so now we have to connect our 8 of fruit and IFTTT account and to do that you're gonna go to ifttt.com / Adafruit and this page is gonna come up it's gonna look a little different right now from what you're seeing on your screen because of course mine is already connected so you'll see my applets that are active and there's more out here that you can do but in your screen you'll see something that probably says connect so you're gonna want to go ahead and connect the two accounts together you're gonna follow the on-screen prompts whatever information they need and they're gonna authorize IFTTT to access your Adafruit IO account and that's gonna connect the two together so that way IFTTT can basically pull data from your Adafruit account and then of course you can use that in these little applets next you're gonna want to go over to the IFTTT account that you created login I'll put the search on the top click on the search bar and type in Adafruit they'll going to be there's going to be a bunch of options here for little applets that come up you're probably gonna have to go down to more and we're interested in this one here the feed value limit is reached email me the details so now we can click on that and when this comes up we will turn this applet on and again the description is found in front of you and we can receive notifications when this applet runs and then we'll should be able to find the feed here from your Adafruit IO account and so you can click on the gate which is the one we created and you can save it then you can go back up to your applets and you can see here that I have two of them so I've already created one before because I've obviously done this project already and played around with it but the new one that I've created does is on the left hand side here and so we can click on that and then you can see that it's turned on but you can go up to the gear icon in the top right hand corner click on that and now we can set up all the details of this applet and so you can see again the description at the top is still there the feed is the gate the relationship that we want here is equal to and we can set the value to 1 and so basically what we're doing here is our code is going to monitor the motion sensor and it's going to output a high signal or a 1 when it's triggered and so this is what we're looking for we're looking for this triggered value and then what you can do is you can set things up inside your IFTTT account such as your email address and all that sort of thing contact information and that's going to be used for these notifications and so you can set up an email so the subject you can put in here you can use different ingredients as they call them so you can use your feed name or whatever you want as the subject line and then the body you can also modify this sort of thing with ingredients or put a custom message in there so it could tell you that the gate is triggered at a particular time of day and then of course you can save that and that's pretty much it you're all set up and ready to go so now we can get into the actual details of the code and I'm going to show you in a second where you can head over to github and you can download the code that I created for this project so now we're gonna check out the code that actually runs this thing and if you head down to the video description you'll find a github link that's going to take you to this page here where you can just click the green button download zip and that's going to download the motion jam ino arduino sketch as well as the config dot h which is also an arduino file gonna unzip those open up the motion camp file and you're gonna see this here in front of you now we're not gonna go through the code on a line by line basis it's not very long and it's not very complicated but we're gonna look at it at a very top level and you can see here up at the top that most of this code was actually derived from a Adafruit door detector file so there is some of that code still left over in here but we're just gonna take a look and in the first part right here above the setup you're gonna see that we're initiating some of the GPIO pins one of them being the motion sensor which I call the gate there's white LEDs red LEDs and the thing that pay attention here to is this line right here so this is setting up the Adafruit IO feed and you can see here that I've called it gate and this reference is my gate feed that we set up in a two fruit IO if you guys name your something different then of course get rid of that and type in whatever your feed name is in the set up you can see that we're initializing the serial protocol and going through some of the pin inputs outputs setting the LEDs to low so they're all off by default you're connecting to a two fruit io and then we're just gonna do a little delay here to allow the PIR sensor to stabilize in the main loop you can see here that we're starting pretty much by reading the light sensor and we're gonna take that value and use it a little bit later on to see if we actually want to flash the LEDs or not so I have chosen to only flash the LEDs at night because during the day you're probably not gonna see them and in here there's just a bunch of conditions testing to see if the gate sensor has been triggered and if it has and it's the first time it's been triggered go through flash the LEDs turn them on and off a bunch of times and then the important thing here is you're gonna send that value to Adafruit IO that's where you're gonna trigger all the other IFTTT events and get your notifications by email or text and at the end here this is just the elsif statement so any signal goes low again you can just turn everything off and that's pretty much all there is to it in the actual sketch the next important thing to look at is that config dot H file so opening this file up you can see here that I've left everything blank for you to fill in now we're pretty much only concerned with these first two sections here and this is again another file here from Adafruit and so up at the top this is we're gonna put in your Adafruit Critic credential so your username and that a IO key that is unique to your account so you're gonna want to put that in there next up down here under the Wi-Fi section this is where you're putting in your Wi-Fi credentials and so you're gonna put in your Wi-Fi network name and in the password now this is going to be hard-coded onto your device and so if anything ever changes you're gonna have to actually reprogram your device to update these values here with your credentials now if you don't want to do that and you want to do things a little bit more dynamic that's why we downloaded the Wi-Fi manager library earlier so let's take a quick look at how we can dynamically change things and without having to reprogram our device every single time so now let's first take a look at what Wi-Fi manager is and then we can take a look at how we're going to integrate it with the ADA through ioco and so we're here on the github page for Wi-Fi manager and if you scroll down you'll see a little screenshot of the access point that you'll get when you fire up your device here for the very first time and you don't have any Wi-Fi credentials safe and so what's allowing us to do is create an access point where we can use our cell phone or laptop and we can connect to our camera device or whatever device you're programming and you can scan for Wi-Fi networks and then of course enter in passwords and connect and then it'll save those credentials and so the next time that your device starts up you will of course connect to that network by default but the nice thing about this is that it allows you to again not have to hard code in any credentials into your program and so every time that your wife our current roles change the network name or the password changes you don't have to you know retrieve your device plug it in change the hard code and that's her thing you can do it all wirelessly and because some of your projects might not be in the same spot all the time you might have something here where you're moving the camera around or whatever device you've created you're moving it to a different location and you're gonna have to connect to a different network and so that's the whole idea behind Wi-Fi manager now to get it to work with either fruit IO it's really not that bad but you're gonna have to edit a little bit of code again and so what you want to do is you want to find the library file here so we're gonna go right into our library files so arduino stores library files that you've downloaded usually in My Documents then it creates an Arduino folder now this is true for Windows I'm not sure for Mac users it's any different but inside your Arduino folder you'll find another one called libraries and in there they're looking for the Adafruit underscore IO underscore Arduino folder then you're gonna go into SRC the source and then you're gonna went to Wi-Fi you're gonna look at all of the files in here and you're gonna look for a CPP file called Adafruit io underscore esp8266 you're gonna want to right click that open it in what a WordPad editor once you have it open so I have highlighted some things here for you so it makes it easier to see what we've done but once you have it open you're basically just see a bunch of code which is text and you're gonna want to add in what you see here and so I'll zoom in and we'll take a quick look so you're gonna want to look for the part part where it says hashtag include a – Frio underscore esp8266 dot h underneath you're going to going to want to add these lines of code that i've highlighted in yellow so take a quick look at those write them down and you want to insert those I'm scrolling down a little farther you can see I've highlighted in red here where it actually says connect so inside this little section here we're gonna add this part that I've highlighted so again you're gonna have to take a look at this copy it down and add that under where it says connect and all this is doing is it's firing up the Wi-Fi manager library this part here is commented out if you uncomment this and then you upload your code it'll actually forget all of the previously saved connection points but right now we don't want to do that so I've just commented that out underneath you're looking at the settings and so we're gonna change them the Wi-Fi manager settings and so this is your access point name so the first time your device starts up and you're trying to connect your phone or your laptop to your device the network name then it's gonna create is set up and the password is password and so if you want to change any of those things you'll just modify those as you see fit and once you've connected to the device successfully you'll if you have your serial monitor open it'll stay connected and this actually down here is the original code and so by adding these two forward slash and asterisks so you can actually comment this out so this original code in the Adafruit file here is no longer run and that's pretty much all there is to it and so what's gonna happen is in that config dot H file that you edited before if you have any Wi-Fi credentials hard-coded in it's gonna actually ignore those and it's going to default to using these guys right here in the Wi-Fi manager and so that's pretty much all there is to it to get this code to run with the Adafruit IO library we're turning now to the enclosure there are a few things I want to mention before buttoning this thing back up so during the process of programming and testing out the circuit I did discover first of all that this W camera actually includes a real glass lens so when we were putting this thing together in the beginning I had the glass lens in there and when testing of the circuit I found out that glass and PIR sensors don't work all that well together it turns out that real glass absorbs a lot of infrared light and my PIR sensor wasn't really working properly and so I do actually have a plastic lens back in there now but it's not glass and I found a plastic that seemed to work and be compatible with the infrared light allowing it to pass through and it turns out that this IKEA lid here that I had for a storage bin was perfect it allowed the infrared light to pass through and visible light to pass through so both my PIR sensor and my photo resistor work so I cut a little hole out of here and I just of course used my glass lens to trace this hole out and I believe this plastic is polypropylene so if you guys are looking to replace your front lens and keep things sealed up polypropylene might be your answer now the next thing to do was to actually take this top cover back off and you can see here that I went with some hot glue around the outside of the battery cover and I sealed it up from the inside and the outside this looks kind of ugly on top but it will be covered up later on by the Sun Visor that goes on top of this thing so I wasn't really too concerned about how this looked but I wanted to be watertight and make sure no water was able to leak into the enclosure and after that we can now take our assembly here we can apply some hot glue to the edges of our 3d printed part and insert it back on to the top cover and get it screwed into place and maybe also use some hot glue around this front edge to make sure that of course again no water gets into the enclosure when it's out in the outdoors next we're gonna address the bottom cover and you can see how I have it lined up here with the rest of the housing I've drilled a countersunk hole 20 millimeters from the front edge of the cover and that's gonna coincide with those adjustment screws it's gonna allow us to make adjustments without having to remove this bottom cover and we can always plug this up a little bit later with a little 3d printed plug the last thing we have to take note of is the jumper on our PIR sensor so it's got to be in the last position here so jumping the last two pins together and that's going to put the sensor into retrigger mode that's going to prevent us from continuing to get notifications while this thing continues to detect motion we don't want it flickering on and off we just want it to send one message and one signal only it's finally time to get this thing looking like a camera again and I have the main body here with the USB cable plugged into the back now I've added a little bit of hot glue to prevent this cable from pulling out I've left a few inches of slack on the USB cable and tied a loose knot before exiting out the back of the back cover and I've taken the back cover and open up a hole in the back of it where the fake cable used to run through and this is big enough to allow the u.s. beef head to pass through we can seal that up with some hot glue at the end the USB cable next runs through this rear mount so I've opened up these holes as well again large enough to allow the USB head to pass through on the back side is the other end of the USB cable and this is of course where we can power our project whether it be from a battery or a wall wart adapter whatever we'll need to get 5 volt USB power the back cover will screw on to the main body and we'll add a little bit of hot glue around the outside to prevent water ingress so at this point we're ready to mount this thing and start testing it out so the final mounting in my case was pretty straightforward as I'm replacing this malfunctioning motion lane at the side of my house and all I had to do is create a 3d printed part here which adapts the camera to the metal junction box the emotion life attaches to so we're going to remove that motion light we're gonna reuse the foam gasket that you see here it goes behind the 3d printed part and then it just screws directly on to the metal junction box and the whole thing attaches to the wall and I wish I had a little bit of video to show you guys how this went down but it's a little difficult to hold a camera and install a camera and stay in the ladder at the same time so these pictures are going to have to do so overall it looks pretty convincing and of course this thing is functional so that's a bonus and now we can take a quick look at how this thing looks in the dark when you come around the corner and the lights start flashing so here I am running the corner of my house you can see the white LEDs flashing followed by the red LED flashing simulating a recording camera and of course I got a notification on my phone so that's it guys just a reminder check out the links in the description down below for more resources like the 3d printing files and the programming code on github and be sure to check out my channel if you like this video for more content just like this thanks for watching

One Comment

  1. northshorepx said:

    Interesting project mate! Just thinking if you use a tiny raspberry pi plus camera you can do something smaller but with real capture (motioneye). Either way thanks for sharing your project!

    May 22, 2019
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *