Hacking my garage door with the Raspberry Pi Pico W

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
here in my garage just bought this uh new Raspberry Pi Pico W here in Missouri but you know what I like a lot more than materialistic things the knowledge that I can use this pie to see when my garage doors open on my phone all kidding aside this is a Pico W it's a tiny little circuit board with a microcontroller that's this little black chip in the middle and it also has a Wi-Fi chip under this metal shield that lets you interact with it from anywhere microcontrollers like this are everywhere that smart light bulb you can control from your phone microcontroller the loud toy that plays a song you can't get out of your head instead of ladder [Music] all around also a microcontroller microcontrollers are like tiny little computers that let you program Electronics to do almost anything when I reviewed this Pico W in June I mentioned how I wanted to hack my garage doors so I could impress my wife by not leaving them open all the time after a few months of health issues holding me back I'm happy to say I finally did it now I have no excuse for leaving the garage doors open and to do it I didn't even have to write one line of programming I did it with something called ESP home if you've heard of ESP home you might be wondering how something built for espressive devices like this esp32 runs on the Raspberry Pi Pico well right around the time the Pico W came out I reached out to Nabu Casa the company behind the popular home assistant software they were actually working on supporting the original pipe Pico but it wasn't a priority with the Pico W and its built-in Wi-Fi they decided to make it official ESP home supports the Pico and Pico W now but why would you care well like I mentioned earlier I programmed this Pico W to do exact exactly what I wanted but I didn't have to write any code no python no C nothing all I had to do was give ESP home this yaml file an ESP home built the software to do exactly what I wanted when I opened the garage door the sensor on the door tells the Pico W the door is open then the Pico W sends a message to home assistant then if I leave the garage door open for more than five minutes home assistant starts nagging me until I close it and this setup is all running inside my house with nothing going out to any Cloud anywhere there's no subscriptions no Cloud accounts no special Hardware but how did I get here well there were two main challenges getting the ESP home to work on the Pico and installing the Pico in my garage most programming projects start with a Hello World you want to get a very simple program running just to make sure all the basics work like if I'm building a website the first thing I'll do is add a file that spits out hello world to my browser if I can get at least that working I'm good if not there's no use writing any more code until I get the base Basics sorted out in the case of microcontrollers hello world usually means blinking an LED there's usually a built-in LED and the Pico has this nice little one here so I wrote up some micro python code to make sure my board worked and it did I got that led blinking then I added a little more code to connect to Wi-Fi and that all worked great so I swapped over to the development release of ESP home and wrote up this little LED blink configuration this file tells ESP home everything about what I want to do at the Pico first there's a little section to give my Pico and name I'm calling it the LED blink Pico then you describe the hardware you're configuring in my case it's an rp2040 and the specific board is the RPI Pico W or I guess if you read it fast the r Pi Pi Cal I added this little bit since I'm working on the bleeding edge here and not everything in this video is stable yet by the time you're watching this it might not be necessary then I configure Hardware outputs I want to control in this case just the LED on the board and then there's a Wi-Fi configuration section and for the configuration values it refers out to a secret it's file that stores my Wi-Fi network name and password finally there's a section called interval where I tell ESP home to start running some code every half second to turn on the LED wait then turn off the LED so I ran this ESP home command to compile the hello world LED blinker and waited and well that's strange the LED blinks technically but it's definitely not blinking consistently I turned on debugging messages and watched from my computer and I saw that it seemed to be getting stuck in some sort of boot loop long story short I found out that the software Library ESP home uses for the Pico's Wi-Fi seems to have a bug right now at least if you have a newer Wi-Fi 6 Network like I do you might have to force your 2.4 gigahertz Network into legacy mode how did I figure that out well after trying two different Wi-Fi six routers I pulled out a Raspberry Pi 4 setup rasp AP on it and connected to that and it worked so I knew it was something about the Wi-Fi 6 network settings and it was just a matter of figuring out what's setting was causing the problem that problem took about two full days to South but hey sometimes the hello world is hard once I figured that out Wi-Fi worked and the LED blinked like it had never blinked before that's not a word anyway so next up I decided to retest everything on another Pico W because in my debugging I did some weird stuff to that first Pico and I wanted to make sure that everything I did would work on a brand new picot I popped the Pico onto a breadboard with some headers and soldered them on then I put a couple sets of screw terminals on the same breadboard so I could use jumpers to connect to the garage door sensors I bought for the sensors I bought two of these enforcer switches since they seemed pretty rugged these sensors cost 20 bucks each but that's not a bad price for a device that has to survive in a harsh garage environment there are some other options too but I liked how these mounted to the track before I install the sensors I just need to test them to my office so that's why I'm using these screw terminals on the breadboard with ESP home these sensors are treated like any other kind of open close or on off sensor you plug one wire and into ground and the other into a gpio pin then set it up like this these settings tell ESP home about how the sensor behaves the switch closes when it's near the sensor and that'll tell ESP home the garage door is closed when the switch is closed when it's near the sensor and it's open when the switch is open when it's away from the sensor one of the most important parts is this little pull up true if you don't set that then the Pico might show random value sometimes because the pin can be floating where it doesn't really know if it's open or closed usually for a sensor like this you have to enable an internal pull-up or pull down resistor I also set up the LED on the picot to turn on if the sensor shows the garage doors open and to turn off if the sensor shows it's closed using these little if and else statements down here so yeah maybe I am doing a little programming but it's yaml just kind of crazy ammo at least it's not as complex as kubernetes there are a few other components I added to this file like the OTA section that'll let me upgrade the picot over the air and there's also this API option that's required for it to connect to home assistant later and before before you go taking notes like everything else all the code I wrote for this video is open source in a GitHub repository linked down below to flash the picot I ran the ESP home run command after it was done and the B code connected to my Wi-Fi I was able to see the LED going on and off as I move the sensor so this setup works but it's not very useful yet right now the little LED on the Pico lights up when the garage door opens but that's it I want to know when the garage door opens from inside the house and for that I need to tie it in to home assistant luckily as long as you have that API option set in your ESP home config the Pico W should be picked up automatically all I had to do was go into home assistant settings click on devices then click configure under the garage door Pico home assistant automatically found it for me after I entered the API password I set up I could see straight from home assistant the status of my garage door or well the sensor on my desk so I added a new card for the sensor in my dashboard and moving around the sensor I can confirm it definitely works and that's great except course it's still just sitting on my desk so it's time to put everything in the garage the first step was to set up a nicer mounting option than a breadboard stuck on the wall and at first I was going to use this 3D printed wall mount but then I found this little RPI Pico breakout board on Amazon it comes with screws and spacers and even includes some headers pre-cut for the Pico the best part though is it has labeled screw terminals for every connection so I took everything out to my garage and I mounted the enforcer sensor to the garage door track it was actually a little tricky you have to put one metal piece in the sensor portion then kind of Squish it onto the track then there's a set screw that can be really hard to turn to give it a little extra clamping pressure and when I say it really hard to turn I mean I gave myself a nice bruise trying to get the screw to back out of one of the two sensors I bought luckily the magnet side was a bit easier it has two sets of screw holes depending on how you position it on your door in my case there are already holes in the metal brackets here so I just screwed it into the holes with the self-tapping screws that came with the sensor the magnet doesn't have to line up perfectly you can keep it in inch or two away the next step was routing the cable up the wall and I'm glad it comes with this armored cable attachment you never know what the kids will stack against things on the wall it also makes routing the cable along the wall easier since I can just use these plastic screw in cable clamps then I screwed the breakout board to the wall luckily this is pretty close to where I used to have my Irrigation System Controller plugged in so I can get power from there I screwed the two wires coming from the sensor into ground and gpio pin 2 then I grabbed my Pico and plugged it into the breakout board I plugged power in and of course it looks like nothing happened because the LED defaults to staying off unless the garage door is open so now the moment of truth it worked well at least the LED on the Pico lit up when the garage door was open and turned off when it was closed I had to see if home assistant was also working so I pulled out my phone and sure enough it updates less than a second after the garage door starts opening pretty neat since I can update the Pico over the air I'll be able to update it and add the other sensor when that's ready I started installing it but realized I didn't have any spare 2 conductor wire to get over to the Pico so I'll have to put off doing that until after my next trip to the hardware store but just showing the garage door status and home assistant isn't that helpful I want home assistant to remind me to close the garage door and that's actually really easy to do I already have the app on my phone so I can set up a push notification using an automation now before all you home assistant experts start yelling at me about writing up some alert ammo instead I decided to use an automation because I wanted to do this through the UI and in that UI I added an automation that triggers on the garage door opening after a five minute delay it notifies everyone the garage door is still open pauses for 10 minutes and repeats until the garage door is closed to test it I have had my wife open the garage door while I was down in the office and it worked after five minutes I got this notification on my iPhone and also on my Apple watch and now I'll never have an excuse for leaving the garage door open again at least for more than five minutes or so so that's that I got it all working and the hardest part of the whole process was getting that led blinking at the beginning but the cool thing is ESP home now supports the Raspberry Pi Pico and Pico W and when I mentioned that on Twitter a lot of people ask why would I choose a Pico over an esp32 or esp8266 well for one having more options is usually better but on a more practical note the last time I visited my local Micro Center they had about a hundred Raspberry Pi Pico W and only about three esp32 devices having one standard microcontroller versus the 100 or so variants of esp32 boards means it's also easier to standardize support for it there are other RP 2040 boards but the majority of projects using Raspberry Pi's chip seem to be built around the Pico board and that also means there are third-party kits like pymeroni's Galactic unicorn which runs on a Pico W2 that I might be able to integrate with the ESP home out of the box I'm also building a full wall mounted dashboard with this 10 inch Pi display and I'll be integrating it and this Galactic unicorn into my home assistant setup soon so subscribe and like this video for more until next time I'm Jeff geerling
Info
Channel: Jeff Geerling
Views: 336,817
Rating: undefined out of 5
Keywords: esphome, raspberry pi, pico, pico w, wifi, wireless, esp32, esp8266, automation, home assistant, house, garage, door, enforcer, seco-larm, honeywell, install, guide, tutorial, getting started, helpful, beginner, learning, testing, sensor, push, notification, iphone, apple watch, android, phone, reminder, wife, nag, software, yaml, programming, micropython, led, light, open, close, wired, iot, internet of things, homelab, internal, privacy, cloud, connected
Id: dFDGtlSi9Eg
Channel Id: undefined
Length: 11min 50sec (710 seconds)
Published: Fri Nov 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.