 Today I was texting with my buddy Andrew. You know him. He's the guy that was there has the CNC machine I've done some videos on And he was telling me we you know talked about this in the past setting up some sort of sensor in my garage to detect Whether the garage door is open or closed and he texts me he said oh you should put some sort of Magnetic switch in there to detect when the door is open and closed and I do actually have one magnetic switch somewhere I said no I probably wouldn't use that because you have to be like physically that magnetic switch has to be Physically really close pretty much touching you know within you know a quarter of an inch if I was going to do something I'd either use a a sonar sensor the text distance or just a motion sensor that detects if the door is moving Which I have a drawer full of both of these as well hook that to a something like a ESP 8266 and a consented signal you know to my computer my server whatever and alert me Or just acknowledge or even just log when the doors opened or closed I said but you know what I probably don't even have to do that I actually have one of my IP cameras out there, so when my daughter was smaller I had a camera in her room It's kind of like a baby monitor. She got older and you know privacy We took the camera out so I just set it up in the garage so that way I can look in my garage And I can see if the door is open if I want but what if I want to Get an alert. Maybe I'm on vacation or just not home. I want to alert whenever the door is open Let me show you this this is a command right here Basically, it's it's a it's a Linux computer. I've shown it before it's a little IP camera made by wands viewers like that some Chinese company I've got two of them this particular one I can even tell that into and get a root shell, but it's all done through a web interface and I went to the web interface open up my developer console my browser, you know and Clicked so the camera has IR LEDs So when the lights turn off it automatically when it gets dark enough the LEDs turn on And that way you have night vision on the camera So I said to my son I don't really need to hook up a sensor because my garage is dark when I'm not out there So I can just detect when things get light which is either someone goes out there and turns on the light switch Which if I'm not home shouldn't be happening if Someone opens the garage door now. They're letting in the sunlight those IRs are gonna turn off or Even if it's nighttime if someone tries to open the garage door At least you know using the motor the light for the the motor is gonna go on and you know You know the light in your garage turns on for a minute or two when you open the garage Or now someone pride open the garage during the night it may not detect But in general I should be able to detect when those IR lights come on and Then I know that something's happened in my garage most of the time So I just said you know I should be able to get that so I go into my web browser And there's a button so you can manually turn on the IR so I did that and I checked my developer console saw what was being get And you can see here that I changed obviously my username password here But I'm just using W get to pull the information So get camera parameters that CGI and it gives you a list of parameters and it gives it to you, you know Line by line as like a JavaScript variable each one says var the name of the variable equals whatever and one of those variables is IR C U T I'm assuming IR circuit and it's either gets a value of zero or one So I'm taking I'm gripping for that line So I'm only getting that line and I'm gonna use cut to crop to cut everything Before the equal sign which just gives me the one or zero and then the trailing Semi-colon I use TR to remove that so this one line of code here. I'm able to Detect whether that IR is on or off and of course I can use this to check if there's a change in that So I can set this to check Regularly and if I go away if I'm not home I can set that if that value changes do something either text me email me alert me or you know for security things I can have it unmute my computer turn the speakers all the way up and play an audio file It says oh true intruder alert intruder alert stand down Please evacuate building or something, you know, which if you're breaking into the building also and you hear that You know, that's why I scarier than an alarm going off, you know, you know the police have been alerted But he recommend my friend Andrew and I'm not criticizing him at all in this It's just people do different things because I should set it up to work with Google home which I don't use Google home or any of those things and and it just in my mind and Andrew you watch some of my videos I'm not criticizing you here in that you do things how you want to do them But why would I do that? He gave me a link to some open source project good for him That allows you to write software that interacts with Google home But I can tell you right now that project alone is going to be a lot bigger than Let's say I'm using W get grep cut and TR all commands which are in busy box So we're looking at one megabyte or less of software here That's Ori on all my systems including the camera Technically I could have the camera be doing this itself In fact, there might be some way to tell that into the machine and have the camera do all the checking I don't even have to remotely check it from my computer But here we have one line of code that checks it and I'm gonna say, you know, check that if This value I can check for a value then do this text me alert me Whatever I want it to do or I can have it check for a change So it can be either anytime. It's one alert me or if it changes from one to zero or zero to one alert me But I'm doing this video because a lot of things So I also I have this whole command here and of course that can be aliased or put in a script. So if I say Cam IR, I believe is what I said to there. It's giving me a zero So I run that you can see how fast it's doing an HTTP request using W get and then running through grep cut and TR Very simple. And if I manually change the IR, so I'm gonna turn it on now The IR is on I write you can see I get one if I turn the IR off and Run it again, I get a zero. So again, this is Me manually changing it, but you can set it so by default action is if it's bright out the IRs turn off When it gets dark the IRs turn on very simple Very clean, you know and works for a little now you're using a sensor like this on the door again We'll detect whether you know if it's the door moving because again this this sensor with the IR if someone turns On the light switch. It's detecting that too, which is a good thing But it may not detect if someone prized open my garage door because that may not turn on lights if it's nighttime. I Could do both I could put one of these sensors out there too again a motion sensor the text the door moving I just have to hook it up there I mean this was like $2 and the ESP 826 is $2 or $3 we're looking at $5 But then I would also have to hook up power to it So I know $3 for a cell phone charger, but I have to make sure there's an outlet there Same thing with this it detects distance so it could be like, oh, you know, it's in front of the door You know, it's so many millimeters and also the number goes up. I can send an alert But again using the Google home thing. It's like now. I am relying on a larger suite of software I am probably gonna have to write more complex code than this one liner of stuff I'm now relying on Google services. I'm assuming we're here. It's like all being done in-house And I can you know, obviously I want myself far away. I'm gonna have to send myself a text. I'm relying on but there's some They're gonna be some sort of Communication there unless I have my own like tower that sends out signals, which I'm pretty sure the FCC would not like But I can use the internet to communicate with myself, but everything else until there's an alert everything is being done in-house With one line of code So that's just food for thought and you see I see a lot of people Over-complicating stuff they they try to think oh here's a Google service that's gonna make things easier It doesn't get any easier than this. I'm literally running one two three four Four commands piping from one to another that are all built into one executable busy box That's tiny teeny tiny and it's it's like this is like first day. I'm learning how to program type stuff Where other things again, you have to learn how to use that open source Library of code and you have to know the API is for Google. I mean, I don't know how complex it gets But it's going to be more complex than this. That's a promise So don't overcomplicate stuff a lot of the stuff out there that is used to make your life easier and to simplify Stuff really complicates it a Lot more than just doing it the basic way and that's what companies want. You know, I use Google services I have an Android phone and I use Google five for my cell phone service You know, I use Google for a lot of stuff, but Google Facebook Apple all these companies they want you to think things are way more complex than they're supposed to be So they give you these solutions that are supposed to make it simpler and usually it's complicating it And it looks simpler because they give you some nice gooey interface, but it's actually more complex and it makes you think Oh, this is hard I'm so glad I have this service and this software from this company and it simplifies it for me So that I can I can do this when reality if you just take a few minutes to learn some basic commands You're gonna have smaller file size again I'm running this command on my local machine But all these commands are built-in busybox which are on the camera already So the camera could be checking itself and then send a signal out. So I don't even have to do it remotely I just did it this way because it was quicker, you know, and And again, I might I might even have to use W get if I'm using it on the camera itself But because the camera is running Linux and I have a root shell through telling it on it Well, now I can do anything, you know, that's the hardware can handle So think about that think about that when you're trying to decide what to do. It's like Is what you're doing something simple and is it using more than a couple of megabytes? That's even getting kind of big to accomplish if it's more than more than two megabytes to accomplish the task You're trying to accomplish you may not be doing it the best way. Are you relying on external services? You may need to for what you're trying to do, but most of the time you don't most times you're running licks, you know, it's an apt-get or Pac-man whatever package manager use to install some sort of service on your local machine that does everything It's very very easy to have your computer. Send an HTTP request Somewhere or to send an email somewhere which can emails can send text. I've talked about that before If you have a cell phone, most likely you can send a text to it from your computer using email It's usually your phone number at and then depending on whatever Service provider you use the at is you know at AT&T MSS So blah blah blah blah blah or Google Fi. I think it's cool dot fi or something like that dot com You can look it up. There's a list of them online your phone number at whatever and it will send you a text and Usually gets there between five and ten seconds so as long as you don't mind a five second delay You will get that text just like I talked about with my water pumps I have my water pumps and I set up some ESP 8266's those pumps run too long It sends a signal to my phone every time they run it sends a signal to my server and logs it and oh by the way I don't know if I mentioned a previous video. I did have a bad bladder valve I was a little concerned about that my pump was running in my tank was running of Around 150 times a day every time I try to think it would run automatically and it shouldn't because I have a 20 gallon tank So it should run for a while before the pump kicks on I Replace the tank. It was obviously bad since then we're looking at 20 to 50 times a day So, you know a 50 on a heavy time like if I'm watering the yard and stuff like that but we went from a hundred hundred fifty on the high end to to you know Around 30 on average after replacing that tank and one of the signals to me that the tank was going bad Was the logs and the numbers going higher and higher and all of a sudden hitting these high numbers it let me know For a couple of dollars and a couple simple commands like this, so we have talked long enough I gave you examples on how this work. I thank you for watching think about it Keep your projects small. That's all I got to say