{"id":115,"date":"2020-11-19T22:05:19","date_gmt":"2020-11-19T22:05:19","guid":{"rendered":"http:\/\/garett-cook.com\/?p=115"},"modified":"2022-05-19T03:19:45","modified_gmt":"2022-05-19T03:19:45","slug":"iot-garage-door-opener","status":"publish","type":"post","link":"https:\/\/garett-cook.com\/index.php\/2020\/11\/19\/iot-garage-door-opener\/","title":{"rendered":"(IOT) Garage Door Opener"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/gamertweak.com\/wp-content\/uploads\/2019\/06\/cyberpunk-2077-vehicles.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>In this tutorial we will be integrating If This Then That(IFTTT) into our smart garage setup and with it create a smart garage door opener that can be controlled by a mobile phone. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Application<\/h2>\n\n\n\n<p>Knowing how to control devices like a garage door opener from a mobile device has huge implications. Imagine for a second you had to suddenly leave the house and forgot you had food on the stove cooking. If the stove were hooked up to an embedded system you could receive a notification when you get far away from the your home that the stove is still on and turn off the stove from a remote location. Also think about how useful being able to control your garage from anywhere could be. You could let your kids into the house even if you&#8217;re not home. You could set up a geofence to automatically close the door if you forget and start driving away. The possibilists here are endless.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is IFTTT?<\/h2>\n\n\n\n<p>The number of technologies that exist in the world continues to increase and IFTTT is dedicated to making all that tech work together in harmony. For example, phone might be made by Apple and your TV by Samsung. IFTTT makes it so that you can control the TV through your Apple device. For the more advanced, IFTTT allows you to call the API that devices have and connect those to other devices&#8217; APIs. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How does the Relay Work?<\/h2>\n\n\n\n<p>The way we integrate our cell phone into our smart garage setup is fairly simple to understand. The IFFTT app is going to use what&#8217;s called a webbooks to alert a server to open the garage door and the relay will be listening to that server and  toggle the state of the garage. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Materials Needed<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Wemos Relay Shield <\/li><li>Wemos Micro Controller<\/li><li>Arduino D1 Mini<\/li><li>Breadboard<\/li><li>Wires<\/li><li>Mobile Device (preferably phone)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<p>Let&#8217;s start by getting setting up the external software.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adafruit Setup<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Go to <a href=\"https:\/\/io.adafruit.com\/\" data-type=\"URL\" data-id=\"https:\/\/io.adafruit.com\/\">adafruit.io<\/a> and  create an account<\/li><li>Navigate to &#8220;IO&#8221; tab and find &#8220;Feeds&#8221; <\/li><li>Select create new feed and call it garageTrigger<\/li><li>In the settings make sure that the feed is public and not private<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">IFTTT Setup<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Go to <a rel=\"noreferrer noopener\" href=\"https:\/\/ifttt.com\/home\" data-type=\"URL\" data-id=\"https:\/\/ifttt.com\/home\" target=\"_blank\">IFTTT.com<\/a> and setup an account <\/li><li>Select create widget<\/li><li>In the IF This section find the &#8220;Button Pressed Wiget&#8221;<ul><li>You could also do google assistant voice commands, geofence, etc. <\/li><\/ul><\/li><li>In the Then That section search for Adafruit<\/li><li>When prompted to connect your account click connect <\/li><li>You should be redirected to Adafruit.io where you should authorize the connection<\/li><li>Now back in the IFTTT you should have a window showing multiple adafruit options, we want to send data to Adafruit<\/li><li>Once you find that option you should see a screen like this<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"http:\/\/www.aaronnelson95.com\/IT441Lab6_files\/image003.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Use the drop down menu to find the garageTrigger feed and select it<\/li><li>The data to save to the feed is just the number &#8220;1&#8221;<\/li><li>Hit add ingredient and lets move on to setting up the relay.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Relay Setup<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>grab your breadboard, wires, arduino and relay<\/li><li>Place both the arduino and relay into the breadboard so that each won&#8217;t interfer with each other&#8217;s circuits<\/li><li>Take the wires and connect the D1 pin on the Arduino and connect it to the D1 pin on the Relay<\/li><li>Do the same thing with Ground (GND) and 5V <\/li><li>You should have something like this<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"http:\/\/www.aaronnelson95.com\/IT441Lab6_files\/image005.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code <\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>The code is a fairly simple concept we need to connect to both the MQTT broker we setup in a previous <a rel=\"noreferrer noopener\" href=\"https:\/\/garett-cook.com\/index.php\/2020\/10\/27\/iot-garage-setup-raspberrypi-arduino-mqtt\/\" target=\"_blank\">lab<\/a> and to your Adafruit feed<\/li><li>The Arduino will be waiting to see if anything has been posted to the Adafruit feed and when it does will set off the relay<\/li><li>Once the relay is set off the Arduino will then publish to the MQTT broker the state of the Garage door opener. <\/li><li>Here&#8217;s a code diagram I found on Aaronnelson95.com that illustrates the process well<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"http:\/\/www.aaronnelson95.com\/IT441Lab6_files\/image004.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code <\/h2>\n\n\n\n<p>To see my code used for this tutorial check out my <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/gcook19\/IT441Labs\" target=\"_blank\">Github<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Certificate of Work<\/h2>\n\n\n\n<p>The work here represents my own and where I used other&#8217;s work I gave due credit. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Helpful Links<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/adafruit\/Adafruit_MQTT_Library\/blob\/master\/examples\/mqtt_esp8266_callback\/mqtt_esp8266_callback.ino\">https:\/\/github.com\/adafruit\/Adafruit_MQTT_Library\/blob\/master\/examples\/mqtt_esp8266_callback\/mqtt_esp8266_callback.ino<\/a> an example of how to do a Adafruit MQTT call back<\/li><li><a href=\"http:\/\/www.aaronnelson95.com\/IT441Lab6.php\">http:\/\/www.aaronnelson95.com\/IT441Lab6.php<\/a> a student from before who wrote a very comprehensive tutorial<\/li><li>&nbsp;&nbsp;&nbsp;<a href=\"https:\/\/www.instructables.com\/id\/Arduino-WiFi-Garage-Door-Opener\/\">https:\/\/www.instructables.com\/id\/Arduino-WiFi-Garage-Door-Opener\/<\/a>&nbsp;&#8211; A simple tutorial on actually connecting the relay to the garage door button (I don&#8217;t do this in my tutorial but here&#8217;s your chance to go the extra mile) <\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In this tutorial we will be integrating If This Then That(IFTTT) into our smart garage setup and with it create a smart garage door opener that can be controlled by a mobile phone. Application Knowing how to control devices like a garage door opener from a mobile device has huge implications. Imagine for a &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/garett-cook.com\/index.php\/2020\/11\/19\/iot-garage-door-opener\/\"> <span class=\"screen-reader-text\">(IOT) Garage Door Opener<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":93,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-internet-of-things"],"_links":{"self":[{"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":4,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":199,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/posts\/115\/revisions\/199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/media\/93"}],"wp:attachment":[{"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/garett-cook.com\/index.php\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}