<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Da Post]]></title><description><![CDATA[My personal blog of things]]></description><link>https://blog.rbrtson.com</link><generator>GatsbyJS</generator><lastBuildDate>Fri, 13 Dec 2019 04:41:31 GMT</lastBuildDate><item><title><![CDATA[Final Project - The Morning Routine]]></title><description><![CDATA[Objectives The purposes of this lab are to: Automate my morning using Alexa to have her do the following Start playing music Tell me my…]]></description><link>https://blog.rbrtson.com/final-project/</link><guid isPermaLink="false">https://blog.rbrtson.com/final-project/</guid><pubDate>Thu, 12 Dec 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objectives&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Automate my morning using Alexa to have her do the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start playing music&lt;/li&gt;
&lt;li&gt;Tell me my calendar for the day&lt;/li&gt;
&lt;li&gt;Turn on my living room light to help my house wake me up&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Build a novel way to see what the weather is going to be like and have it also suggest what I should wear&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (For programming the Arduino)&lt;/li&gt;
&lt;li&gt;Personal smart phone (For configuring Alexa)&lt;/li&gt;
&lt;li&gt;Smart bulb of your choosing (As long as it integrates with Amazon Alexa)&lt;/li&gt;
&lt;li&gt;Apple Music account&lt;/li&gt;
&lt;li&gt;Kasa Account (or whatever account is required for your smart bulb)&lt;/li&gt;
&lt;li&gt;1 x Echo Dot (or other Amazon Alexa capable device)&lt;/li&gt;
&lt;li&gt;1 x ESP8266 Wemos D1 Mini (Microcontroller)&lt;/li&gt;
&lt;li&gt;1 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x USB -&gt; MicroUSB cable for power and flashing the microcontroller&lt;/li&gt;
&lt;li&gt;3 x LED lights&lt;/li&gt;
&lt;li&gt;10 x Female to male jumpers&lt;/li&gt;
&lt;li&gt;4 x Male to mail jumpers&lt;/li&gt;
&lt;li&gt;1 x OLED Arduino screen&lt;/li&gt;
&lt;li&gt;1 x Cardboard box to store it all in&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BuiltInExamples&quot;&gt;Arduino IDE Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot;&gt;PubSubClient Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.home-assistant.io/getting-started/&quot;&gt;Install Home Assistant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/420640/unable-to-connect-to-any-wifi-with-networkmanager-due-to-error-secrets-were-req&quot;&gt;Connecting Home Assistant to WiFi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.home-assistant.io/integrations/ifttt/&quot;&gt;Connecting Home Assistant to IFTTT&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;h4&gt;Setting Up Alexa&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Plug in your new Echo Dot (or other device)&lt;/li&gt;
&lt;li&gt;Download the Alexa App (&lt;a href=&quot;https://itunes.apple.com/us/app/amazon-alexa/id944011620?mt=8&amp;#x26;at=1001lnRX&amp;#x26;ct=tomsguide-1456038539298567853&quot;&gt;iOS&lt;/a&gt; or &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.amazon.dee.app&amp;#x26;hl=en_US&quot;&gt;Android&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Devices&lt;/code&gt; on the lower right hand corner&lt;/li&gt;
&lt;li&gt;Press the ➕ in the top right of the screen and select &lt;code class=&quot;language-text&quot;&gt;Add Device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Amazon Echo&lt;/code&gt; from the list&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select your model (in my case it is an Echo Dot)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I then select 3rd generation because that’s the one I have. Feel free to select whichever version you purchased&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now follow the directions on the screen to pair your new device!&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Setting Up a Routine&lt;/h4&gt;
&lt;p&gt;Here we are going to set up two different routines: one that starts the morning off and one that ends the morning. The one to start it needs to read you what is going on that day (according to the calendar that we will add), turn on the living room smart light, and start playing some music. The ending routine should stop the music and turn the living room light off in preparation of us leaving the house.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Before we can start adding routines, we need to make sure that we have all of the devices and skills we need added to the app&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Note: A skill is simply an integration with another app or service that Alexa can then use&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;First, we’ll set up our Apple Music &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Click on the hamburger menu in the top left of the screen and select &lt;code class=&quot;language-text&quot;&gt;Skills &amp;amp; Games&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click the 🔍 icon in the top right hand corner and search for &lt;code class=&quot;language-text&quot;&gt;Apple Music&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click on the Apple music skill and click on the &lt;code class=&quot;language-text&quot;&gt;Enable to use&lt;/code&gt; button&lt;/li&gt;
&lt;li&gt;Now it will prompt you to login with your AppleID. Do this and the skill is activated and ready to use!&lt;/li&gt;
&lt;li&gt;You can test this by saying &lt;em&gt;“Alexa, play music form Apple Music”&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;At this point, you can also make it so that whenever Alexa is asked to play music, she plays it from Apple music by default. You can do this by going to the left hand menu and selecting &lt;code class=&quot;language-text&quot;&gt;Settings&lt;/code&gt; and go to &lt;code class=&quot;language-text&quot;&gt;Music &amp;amp; Podcasts &amp;gt; Default Services&lt;/code&gt;. Here you can set what you would like your defaults to be.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Second, we’ll set up Google Calendar&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We are going to add this skill a little bit differently. This time, we want to go to &lt;code class=&quot;language-text&quot;&gt;Settings &amp;gt; Calendar &amp;amp; Email&lt;/code&gt; and select &lt;code class=&quot;language-text&quot;&gt;Add Account&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Select your account type&lt;/li&gt;
&lt;li&gt;Follow the on screen instructions to sign into your account and like your calendar to Alexa. You can also add your email at the same time&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lastly, we’ll add in our smart light&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Devices&lt;/code&gt; in the bottom right hand corner&lt;/li&gt;
&lt;li&gt;Press the ➕ in the top right of the screen and select &lt;code class=&quot;language-text&quot;&gt;Add Device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Light &amp;gt; [Your brand name]&lt;/code&gt;. I am adding a TP-LINK Kasa light&lt;/li&gt;
&lt;li&gt;You will then most likely be prompted to set up your device in the lights proprietary app. Do this and then come back to the Alexa app and click discover devices&lt;/li&gt;
&lt;li&gt;Your device should be found and you can click add. It will then give you some options on naming the light and such&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now, we’re ready to set up our routines! We’ll start with our morning start route&lt;/p&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;From the Alexa app, click on the hamburger menu on the top left of the screen and select &lt;code class=&quot;language-text&quot;&gt;Routines&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click the ➕ in the top right hand corner to add a new routine&lt;/li&gt;
&lt;li&gt;Add a routine name (I just selected Morning Start)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a &lt;code class=&quot;language-text&quot;&gt;When this happens&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I chose &lt;code class=&quot;language-text&quot;&gt;Voice&lt;/code&gt; and said when Alexa hears: &lt;em&gt;“Alexa, good morning”&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now it is time for the meat of the routine: the actions. First we will add an action to set the volume Alexa should speak at in the mornings&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Device Settings &amp;gt; Volume&lt;/code&gt; and set the volume you want Alexa to be at in the morning&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, we want Alexa respond to our good morning&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Alexa Says &amp;gt; Customised&lt;/code&gt;. Here you can tell Alexa to say whatever you want her to in response to your &lt;em&gt;“good morning”&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, we want Alexa to turn on our smart light&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Smart Home &amp;gt; [The name of your light]&lt;/code&gt; and click next&lt;/li&gt;
&lt;li&gt;Choose Power and make sure the switch is On and click next&lt;/li&gt;
&lt;li&gt;Done!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, we want Alexa to read us the calendar&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Calendar &amp;gt; Today&amp;#39;s Calendar&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click next and you’re all set up!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, we need to set up Alexa to play Apple Muxic&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Music&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Fill out form and select what you want Alexa to play&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now, we will set up the Morning end routine that will run when we leave the house in the morning&lt;/p&gt;
&lt;ol start=&quot;14&quot;&gt;
&lt;li&gt;From the Alexa app, click on the hamburger menu on the top left of the screen and select &lt;code class=&quot;language-text&quot;&gt;Routines&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click the ➕ in the top right hand corner to add a new routine&lt;/li&gt;
&lt;li&gt;Add a routine name (I just selected Morning End)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add &lt;code class=&quot;language-text&quot;&gt;When this happens&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I chose `Voice and said when Alexa hears: &lt;em&gt;“Alexa, goodbye”&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now time for the actions! First we will add and action to have Alexa respond&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Alexa Says &amp;gt; Customised&lt;/code&gt;. Here you can tell Alexa to say whatever you want her to in response to your &lt;em&gt;“goodbye”&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, we want Alexa to turn the music off&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Device Settings &amp;gt; Stop Audio&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Select the device to stop&lt;/li&gt;
&lt;li&gt;Click next to confirm&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, we want Alexa to turn off the light&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;code class=&quot;language-text&quot;&gt;Add Action &amp;gt; Smart Home &amp;gt; [The name of your light]&lt;/code&gt; and click next&lt;/li&gt;
&lt;li&gt;Choose Power and make sure the switch is Off and click next&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Your Alexa and routines are all set up! Give it a test by saying &lt;em&gt;“Alexa, Good Morning”&lt;/em&gt; and then, &lt;em&gt;“Alexa, goodbye”&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Setting up The Weather Caja™&lt;/h4&gt;
&lt;p&gt;The Weather Caja™ is a box that will help me know what I need to do in the mornings. It will read out the forecast for the day and let me know what the current temperature, low temperatures, and high temperatures for the day are. It will do this using and OLED screen and 3 LEDs all run by an ESP8266 microcontroller. &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Wire up your OLED screen to your ESP8266 using the following diagram
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/031f31a345a3238a48f231002be35b0c/8bef1/oled-to-wemos.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 60.45627376425855%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAACmFAAAphQGPVf7hAAADIklEQVQoz42Sf0zUZRzHvzaj6ZboVGw5oAUNcmAz1GURlnfSDwHT2ZUKeEKxcLVZocfmGVKaI3LNGSD+dhybOyHRVArh8hRn/XM2ryD6XufBOMS1nYbncXdfnnv13B1t/tln++z97PM8z+v5fJ7PR0Faz00PSfrNZD+bzLykmaSlJjF33mwy1lfz54gveoQJIWI6Nh7C5w8SCmuMh8IxD4Y1ocm90X8CqhI9tPtoOwnPF/JUyhPMmT2LpDmzyMxexIy8Ek79cD0OnBDRi3T3e1lb20Tqu1vJNFaTUbKNdKNZLN57lgbbzTiwsfkw6cuL2PVFLW2n22g5eYIq8y4ydKux205HcTEXEfjG1kdGmRll6RqU5RtRcg1SjeJxUzt7LvXFgQ2HjpHy0ps0NjVw+bKdnu4uTOYastcZaO/Zj3vEzm/uc7hvu8itbUHJ/4CpuhIe0W9CkT791Q0icWUZ0/TlceC3B4+QkltA3ddfceFiJ729vez4fDfp+QZOdFxh6B44h8boH71N1aFPSSyqQHmlmCm6Ugk0MvPFArEsawHPZWVPZnj4OE/nFbKv/ks62qx0d55nb30daStWY2k5yuCgm2vXrmD77gybNm98CFgyCVwlgZnkLFyoKg8cDhprzCTnF5P1VgUvbPiIxW9X8kzB+8zXGWg+fgTnmbP0WyyMdl2i8JN6lDcq4yWvNDIlWrKuWMxYtYWE1ypVxdtqwXHjV9IM20ks3E6CfguP6j9k/js1PLnGREfPL/jln0ZtXHal5YaXBeU7UXKKUF5ej7JsndRS8ViVlT1dv6vKXbudwft+kg0msirreX1HEytMB1iydT+p5XVYe534r9qRDUaTY9PuuEXRzgMsKv2Ype9Vs6RsGzkVn4m8fRc5dlV2WW0+iF91YbOew3H+R/7++Toe2090W9roPGll4PsLeFpbYxkSiRAIadwPamgy27B0Tb6kCWJTfy8QUhVfXx93nU7CbhfBv1yMqSqBW24iw0MwMkxAxh7cuTPJi/CwCTFBKBiMqpgMxbv8f+w/WFSFiK99Ph8ej0dOwZAY9nr5Y2DA9S8eQawekF0IiQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;OLED to ESP8266&quot;
        title=&quot;OLED to ESP8266&quot;
        src=&quot;/static/031f31a345a3238a48f231002be35b0c/b9e4f/oled-to-wemos.png&quot;
        srcset=&quot;/static/031f31a345a3238a48f231002be35b0c/cf440/oled-to-wemos.png 148w,
/static/031f31a345a3238a48f231002be35b0c/d2d38/oled-to-wemos.png 295w,
/static/031f31a345a3238a48f231002be35b0c/b9e4f/oled-to-wemos.png 590w,
/static/031f31a345a3238a48f231002be35b0c/8bef1/oled-to-wemos.png 789w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;D1 is the I²C Clock Pin&lt;/li&gt;
&lt;li&gt;D2 is the I²C Data Pin&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Wire up your 3 LEDs to D5, D6, D7 pins&lt;/li&gt;
&lt;li&gt;Use the code from previous labs to connect the ESP8266 to the internet, specifically WiFi&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Initialize the display using the following code&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;#include &amp;lt;SPI.h&amp;gt;
#include &amp;lt;Wire.h&amp;gt;
#include &amp;lt;Adafruit_GFX.h&amp;gt;
#include &amp;lt;Adafruit_SSD1306.h&amp;gt;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET     -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;amp;Wire, OLED_RESET);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After you have initialized the display begin communication in the setup() function with the following code&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
  Serial.println(&amp;quot;[OLED]\tSSD1306 allocation failed&amp;quot;);
  for(;;);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now you can write to the display using the following code&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
// Display static text
display.println(&amp;quot;[Your Text]&amp;quot;);
display.display();&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Now you can write to the screen. &lt;/li&gt;
&lt;li&gt;Next, you should use the http client from ESP8266 to get the weather from any API you would like&lt;/li&gt;
&lt;li&gt;Use the &lt;code class=&quot;language-text&quot;&gt;ArduinoJson&lt;/code&gt; library to parse the JSON payload. &lt;/li&gt;
&lt;li&gt;Based on these values from the API, you are able to turn on and off certain lights if the clothes you need to wear need to be lit up&lt;/li&gt;
&lt;li&gt;Now, you have everything set up for your very own Weather Caja™. You just need to put it all in a box and make it look nice!!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. &lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: DIAGRAMS&lt;/h4&gt;
&lt;p&gt;Alexa Logical Layout 1
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/6191ea95ac49bc32d1d8ad7a6544372a/566ce/alexa-logical-1.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 72.72727272727273%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAABcSAAAXEgFnn9JSAAACSklEQVQ4y5WTy27TQBSGveMdeAyWiAeAFRLvwJZVN9yFugpFStOINPfIduLcPL7OJA2JI0pF5CYQCRRQqVCyQF1nAfufmXHdhkBFuxjNeI7nO/+5KZ7n4arLdd2zs2VZCMMQi8UClFIoVwXFMLH7vi+Bs9kMy+Xy8sB1UHx2HAe1Wg3T6RTz+Ry9Xg/KRT+vhrV+J5QIWLPZRKvVgm3bME1TqlXWQX8CxLcLh+82X67ny4e6rqNYLIIQIuFGvYFCscxtJFIYexWexLc4y/tTR3vUxZDa6NFIlVhCYfTWRfCG4W3QQa/rR0CR3EKhgGw2i0wmI/MSQT10qYeH2Q7upt7hQZrC4qoYY/wNBfU9mBbD5m6IR6kJUuUAinioaZqEqaoqw0mn0zIc2+HOSAs3Xx7g2osvuLE1hqpVUalUUCqV0W41oBo27j37hjuPf2BjOzwH5nI5GYpQl0wmT4E8LA68venj+pP3uPXU43ZD5rHdbsO2CKoNgo3CHPdfn+CVPo6Ao9EIiUQCOzs7MmTDMM7yyBhFtqTj+dYutjMl1KpVXtm2hAq7xaGaWoKulblNg9Lv9zGeTKRH0QIin2KtFoXxXHk2QYf5XLklo8nn87JNaIehy3hBuIBOtwslCAKEh4cYDAZ/9VtcRdlWvGWcldYSHWHU67yye/h5dIRfBxN8nXyGIgyEyxf7Rc0d360uEYVJTDDi4+Tjko/fEqNPx1FjC+P6dPxv/OLRGw4D7A+PYYffsf9hej56/xq5y8BFGoy6hnpVBeF1+A1t+JGRjvv1NwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Logical Layout&quot;
        title=&quot;Logical Layout&quot;
        src=&quot;/static/6191ea95ac49bc32d1d8ad7a6544372a/b9e4f/alexa-logical-1.png&quot;
        srcset=&quot;/static/6191ea95ac49bc32d1d8ad7a6544372a/cf440/alexa-logical-1.png 148w,
/static/6191ea95ac49bc32d1d8ad7a6544372a/d2d38/alexa-logical-1.png 295w,
/static/6191ea95ac49bc32d1d8ad7a6544372a/b9e4f/alexa-logical-1.png 590w,
/static/6191ea95ac49bc32d1d8ad7a6544372a/f9b6a/alexa-logical-1.png 885w,
/static/6191ea95ac49bc32d1d8ad7a6544372a/566ce/alexa-logical-1.png 1100w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Alexa Logical Layout 2
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/7da6c38c9f50c332c1e39ff9e04bf910/4239f/alexa-logical-2.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 73.13432835820896%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAABcSAAAXEgFnn9JSAAACIUlEQVQ4y51Ty27TUBD1mg1/woK/YMFP8AusECsIlbIDKY+GKC/lYSck4d5rO25Tt4HGSkkTpIIiobCMhLKphBArhMM9zL2JIwdahLo4mtF47pk5M2PDtu0fhF+E1U3AOV9Np9PVbDZbCSFWBgVDAm4Cx3FAhFgsFlgulzqmCH9uEuS/QNW3VoHIJGNMdrtdOZ/PNTzPk/EO5XWdEMGOdV1Xd2ZZFlqtFohIQ8W2hJvKiLAmW/tc2GBC5djodDowTRPlchnUoZZdqVSQz+dB3cKgB+GmqpKhqyu7JSfSvitw7DIckDVNi9DQxFFhlR9Bd6gcqiCz2SwUVCWHiCPJj/MeHuTe4NlLBsHW39SbaAxxGL1eLywWiyiVSlJJUchkMnhNcoTgqJtt3EmOcevJDPdeBPBdvpEvdmYb+Zowl8uh2WzKarWqLNLpNDrU5ZqwhbtPB7j96B3uJw9xRITcdmJz3oXR7/fDI99HIpGQhUIBqVRKd+nGJCdTZTzc28fz/Qo67Vd6GX/J5RvJJ4NBODo7Q61Wk41GQwfjS1EPPYfDYW0ceq4+E1WY8rcLsXs00wNvvZRhEITnkwl835fxQcdvUJ2LIJk8ttXofEbDAN8/XOBbMMX78RQGHWOoDpIgrxv0Vb7ruLBaFk7EMS4/fsXn2SVOxxfY+VOuG/RVpMoyzhC8HSEYfkH/0xKn55P/J/yTeDsKuoRqvYp6vU6LYfgNgM2VrS5ruRUAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Logical Layout&quot;
        title=&quot;Logical Layout&quot;
        src=&quot;/static/7da6c38c9f50c332c1e39ff9e04bf910/b9e4f/alexa-logical-2.png&quot;
        srcset=&quot;/static/7da6c38c9f50c332c1e39ff9e04bf910/cf440/alexa-logical-2.png 148w,
/static/7da6c38c9f50c332c1e39ff9e04bf910/d2d38/alexa-logical-2.png 295w,
/static/7da6c38c9f50c332c1e39ff9e04bf910/b9e4f/alexa-logical-2.png 590w,
/static/7da6c38c9f50c332c1e39ff9e04bf910/f9b6a/alexa-logical-2.png 885w,
/static/7da6c38c9f50c332c1e39ff9e04bf910/4239f/alexa-logical-2.png 1139w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 2: Configs&lt;/h4&gt;
&lt;p&gt;Morning Start Routine
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/7e0ae/morning_start.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 216.42512077294685%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAArCAYAAAB4pah1AAAACXBIWXMAAAsSAAALEgHS3X78AAAE9ElEQVRIx5VWWVMbRxDeP4AD2hVCXDLYBgPm0oU4DZjDOkBIAgySAAkkQBxFuQKxk3JSlTyl4lT+cqe/3p1lV4CQH1qtmdnp6ePrQ/PGctQ594nerB1Rz/t9Mqay1D69TdgHf4pw7p/dpYH1ktBw4oR8vK9BQO9inhYKn+ltvEyeSMa+pEez5IlmbGqLbJFuPQjet1ykpcNbmt2/odTZN9nXfDPbFFgquD5WGuDCq5UDer16KDTImgSW8rYV4D+F0kJ4sGthzxQ4+LEsh9jUoxlbu2DmnCK5S5rauaLY7jXN5z/T6EbVZYVvZoe8fDfAwvqWC6R1ze/RAPsPGrxlwdBI+Q8XoXlb2KRWSxNlgRdCwTkGxmKRvCxcBI6wQ+HUkeSJmCUfPxIUWOMMmC1wnoO5eiyCNRzCd7plsjGVEzMaRdret7Vkn0JzXmtd7/M0tn1Nw1s1GkhUaGjznIbS59TN+/UCH6wdQhVp0Ah+aoWfhKfFdwIVi8N/+K4ZfGqIzPb1n7R+8lWimb74g1ZKd7R2/EUoXvmVNmu/C4QUAhoK7Fw6oMHMpUQY0R5NVW3cIQPerB5JsLoZFoYDp08KNPinLbYt5sI8mG5nR8SkHzLZhEjz+ftgry4wWufCPke1Rq85wgNs7kCyaqL/GeEPhOGO5DL/dDJg/cz94AzOZrR14RA0mRQsakC5Z+uG9PgZ6ckaGU1q5xQK8px/J2O9ygK5pnlXyuRdOiTv8iG1I0ti9wFoSI5v9NJfIscMSiRN7QwJL6vsvCD52ywFLZN9szvUu3xAHawp6hmKhaJmgwOLfJbvtb7VEsVvv0uRRa2bSJ/R+OapABxCnS3hMVKFNvDBVEpr58h28sWnXkfJepSm77k7U1h6W2iTVBnDGtVa9RMnN8ms6uo72wLEAOWrl5N+rvJNGpUqsqDhxLGYDf4uVZE2gUKM/zhH7oOjwkNo92JBfK7hT7h4K620/0PRbkwgtNZ+9g0KhLlnFg3wl+xznEERaIa6KgIhvTW4IZvOlqmKg65cMOUmQxEi7DQZkQnwix0MH5SoHs5tBR+sVR95jlTbYNgcUfznf0R1tM1w9oJ5TaATYt7hwGJD2IhSgM20CRscKjNMk3JNFdT6nHb50PZV1AmfTMMUVGe2QCB8vso9gyMcztZocss0G/AIyfpM/PiU2WqvezGvYJOnSPFOJin4ERPYS25cCIhaP1a56wW6YPNiImnDRldwcWSI4YBJuwUTF83cP6J1zO1S/3qZA/NJCgS0AmgDzLGGhuDYg+ZIgMcGAETYhM1aiRJ3/8oFQGUofiywGWUfSspxK4VPx60qpFLNNeMwIuxq44JL1EHOaDsibsTc7bQ+WIJDmK2Q3gw1mnl4WNrnQemCBjdOH4xx3hh4zg3eZx7Qnkon51DpovpzO/0skzEzI4cn2elj3AJCVkAwRNmXeUwRstYKWkow/iOofnad4DCYvaRw7koqDgD+LnVKw8mKBMTHJhu7v5Cx91X8jL2hREW+MayS9WrlSNaSeh5+eZjHj5HkKXmsgWmED8d5PEGN83E50y//I+P0b/KtnZAe3qRQ7pqiuzf298HslRA0FR9K/VswKw4qT+8i1N8TuLRMpKhlocBUpBeTG9TCBOj4HQDv4bRTE69W71xEFS+NMYg/8rApg2fplumOVstfKFH9TfytfFgfzP8BvpOmeHY3WaEAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Alexa Morning Start Routine&quot;
        title=&quot;Alexa Morning Start Routine&quot;
        src=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/b9e4f/morning_start.png&quot;
        srcset=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/cf440/morning_start.png 148w,
/static/0c91c60e40fc2bae2c366f6c58381937/d2d38/morning_start.png 295w,
/static/0c91c60e40fc2bae2c366f6c58381937/b9e4f/morning_start.png 590w,
/static/0c91c60e40fc2bae2c366f6c58381937/7e0ae/morning_start.png 828w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Morning End Routine
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/7e0ae/morning_start.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 216.42512077294685%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAArCAYAAAB4pah1AAAACXBIWXMAAAsSAAALEgHS3X78AAAE9ElEQVRIx5VWWVMbRxDeP4AD2hVCXDLYBgPm0oU4DZjDOkBIAgySAAkkQBxFuQKxk3JSlTyl4lT+cqe/3p1lV4CQH1qtmdnp6ePrQ/PGctQ594nerB1Rz/t9Mqay1D69TdgHf4pw7p/dpYH1ktBw4oR8vK9BQO9inhYKn+ltvEyeSMa+pEez5IlmbGqLbJFuPQjet1ykpcNbmt2/odTZN9nXfDPbFFgquD5WGuDCq5UDer16KDTImgSW8rYV4D+F0kJ4sGthzxQ4+LEsh9jUoxlbu2DmnCK5S5rauaLY7jXN5z/T6EbVZYVvZoe8fDfAwvqWC6R1ze/RAPsPGrxlwdBI+Q8XoXlb2KRWSxNlgRdCwTkGxmKRvCxcBI6wQ+HUkeSJmCUfPxIUWOMMmC1wnoO5eiyCNRzCd7plsjGVEzMaRdret7Vkn0JzXmtd7/M0tn1Nw1s1GkhUaGjznIbS59TN+/UCH6wdQhVp0Ah+aoWfhKfFdwIVi8N/+K4ZfGqIzPb1n7R+8lWimb74g1ZKd7R2/EUoXvmVNmu/C4QUAhoK7Fw6oMHMpUQY0R5NVW3cIQPerB5JsLoZFoYDp08KNPinLbYt5sI8mG5nR8SkHzLZhEjz+ftgry4wWufCPke1Rq85wgNs7kCyaqL/GeEPhOGO5DL/dDJg/cz94AzOZrR14RA0mRQsakC5Z+uG9PgZ6ckaGU1q5xQK8px/J2O9ygK5pnlXyuRdOiTv8iG1I0ti9wFoSI5v9NJfIscMSiRN7QwJL6vsvCD52ywFLZN9szvUu3xAHawp6hmKhaJmgwOLfJbvtb7VEsVvv0uRRa2bSJ/R+OapABxCnS3hMVKFNvDBVEpr58h28sWnXkfJepSm77k7U1h6W2iTVBnDGtVa9RMnN8ms6uo72wLEAOWrl5N+rvJNGpUqsqDhxLGYDf4uVZE2gUKM/zhH7oOjwkNo92JBfK7hT7h4K620/0PRbkwgtNZ+9g0KhLlnFg3wl+xznEERaIa6KgIhvTW4IZvOlqmKg65cMOUmQxEi7DQZkQnwix0MH5SoHs5tBR+sVR95jlTbYNgcUfznf0R1tM1w9oJ5TaATYt7hwGJD2IhSgM20CRscKjNMk3JNFdT6nHb50PZV1AmfTMMUVGe2QCB8vso9gyMcztZocss0G/AIyfpM/PiU2WqvezGvYJOnSPFOJin4ERPYS25cCIhaP1a56wW6YPNiImnDRldwcWSI4YBJuwUTF83cP6J1zO1S/3qZA/NJCgS0AmgDzLGGhuDYg+ZIgMcGAETYhM1aiRJ3/8oFQGUofiywGWUfSspxK4VPx60qpFLNNeMwIuxq44JL1EHOaDsibsTc7bQ+WIJDmK2Q3gw1mnl4WNrnQemCBjdOH4xx3hh4zg3eZx7Qnkon51DpovpzO/0skzEzI4cn2elj3AJCVkAwRNmXeUwRstYKWkow/iOofnad4DCYvaRw7koqDgD+LnVKw8mKBMTHJhu7v5Cx91X8jL2hREW+MayS9WrlSNaSeh5+eZjHj5HkKXmsgWmED8d5PEGN83E50y//I+P0b/KtnZAe3qRQ7pqiuzf298HslRA0FR9K/VswKw4qT+8i1N8TuLRMpKhlocBUpBeTG9TCBOj4HQDv4bRTE69W71xEFS+NMYg/8rApg2fplumOVstfKFH9TfytfFgfzP8BvpOmeHY3WaEAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Alexa Morning Start Routine&quot;
        title=&quot;Alexa Morning Start Routine&quot;
        src=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/b9e4f/morning_start.png&quot;
        srcset=&quot;/static/0c91c60e40fc2bae2c366f6c58381937/cf440/morning_start.png 148w,
/static/0c91c60e40fc2bae2c366f6c58381937/d2d38/morning_start.png 295w,
/static/0c91c60e40fc2bae2c366f6c58381937/b9e4f/morning_start.png 590w,
/static/0c91c60e40fc2bae2c366f6c58381937/7e0ae/morning_start.png 828w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 3: Demo and Images&lt;/h4&gt;
&lt;p&gt;Weather Caja™ Image
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/67b4687b9104542914a724d8c4b3a04b/d19b4/weather_caja.jpg&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 216.42512077294685%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAArABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAMEAQX/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/2gAMAwEAAhADEAAAAeOtuFoBOy57coaZaquG9nEYX//EABwQAAIBBQEAAAAAAAAAAAAAAAECAAMREiExMv/aAAgBAQABBQJtG8XYb26FInGRmc0akAKxe4tc+k7u5G8jkTZcjP/EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BX//EABgRAAMBAQAAAAAAAAAAAAAAAAABEBEh/9oACAECAQE/AY8UfTD/xAAcEAACAgMBAQAAAAAAAAAAAAAAARAhETFxIOH/2gAIAQEABj8CxheLij6YcOtD6Ip7H0Vz/8QAHhABAAMAAgMBAQAAAAAAAAAAAQARITGRUWFxQaH/2gAIAQEAAT8hVo6J8HUBah1Dv7GKpulRVuKa8vMVmMCfscy6K8wynfKG39ozFqGj7Wzs0X8jmNYOwr1/k//aAAwDAQACAAMAAAAQI/zO/wAv/8QAGBEBAAMBAAAAAAAAAAAAAAAAAQARIRD/2gAIAQMBAT8QXa4C7Kg0ZLn/xAAZEQEBAAMBAAAAAAAAAAAAAAABABAhQRH/2gAIAQIBAT8QDUy0ry9h0Yf/xAAcEAEBAQEAAwEBAAAAAAAAAAABEQAhMUFRsfH/2gAIAQEAAT8QOEx84rY9TvxjmlIJhQ0Ci8wwU7vCKETDdxb5jII6Ab3CGvqHvrkmgBJ5M32v0yfYKqyPdC9REUujy/pq+u5AFzeKjuRQK+0O/9k=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Weather Caja Pic&quot;
        title=&quot;Weather Caja Pic&quot;
        src=&quot;/static/67b4687b9104542914a724d8c4b3a04b/c739e/weather_caja.jpg&quot;
        srcset=&quot;/static/67b4687b9104542914a724d8c4b3a04b/8ee9c/weather_caja.jpg 148w,
/static/67b4687b9104542914a724d8c4b3a04b/ebbe7/weather_caja.jpg 295w,
/static/67b4687b9104542914a724d8c4b3a04b/c739e/weather_caja.jpg 590w,
/static/67b4687b9104542914a724d8c4b3a04b/d19b4/weather_caja.jpg 828w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 2: Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/it441-final-project&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Lab 5 - Home Assistant]]></title><description><![CDATA[Objectives The purposes of this lab are to: Install an open source home automation platform Interface this platform via MQTT with your…]]></description><link>https://blog.rbrtson.com/lab-5/</link><guid isPermaLink="false">https://blog.rbrtson.com/lab-5/</guid><pubDate>Mon, 02 Dec 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objectives&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install an open source home automation platform&lt;/li&gt;
&lt;li&gt;Interface this platform via MQTT with your various devices&lt;/li&gt;
&lt;li&gt;Use Home Assistant to monitor the state of the garage door, and whether the car is parked in the garage. &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (MacBook Pro)&lt;/li&gt;
&lt;li&gt;3 x ESP8266 Wemos D1 Mini (Microcontroller)&lt;/li&gt;
&lt;li&gt;3 x USB -&gt; MicroUSB cable for connecting the Microcontroller to the computer&lt;/li&gt;
&lt;li&gt;3 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x Stop light LED component with built in resistors&lt;/li&gt;
&lt;li&gt;1 x Hypersonic distance detector&lt;/li&gt;
&lt;li&gt;1 x Magnetic door sensor&lt;/li&gt;
&lt;li&gt;9 x Male to male jumper cables&lt;/li&gt;
&lt;li&gt;1 x Raspberry Pi 3&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BuiltInExamples&quot;&gt;Arduino IDE Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot;&gt;PubSubClient Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.home-assistant.io/getting-started/&quot;&gt;Install Home Assistant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/420640/unable-to-connect-to-any-wifi-with-networkmanager-due-to-error-secrets-were-req&quot;&gt;Connecting Home Assistant to WiFi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.home-assistant.io/integrations/ifttt/&quot;&gt;Connecting Home Assistant to IFTTT&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download Hassio Home Assistant onto the Raspberry pi using the following instructions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.home-assistant.io/getting-started/&quot;&gt;https://www.home-assistant.io/getting-started/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, you will need to make sure that you set up the network correctly. For me, I wasn’t able to get the suggested USB network configuration file to work. Instead I used the &lt;code class=&quot;language-text&quot;&gt;nmcli&lt;/code&gt; approach.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First login to hassio with the command &lt;code class=&quot;language-text&quot;&gt;login&lt;/code&gt; after bootup (using root as the username)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the following command to see if the ssid you’re going to try and connect to exists&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nmcli con show&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the following command to delete that connection if it exists and make sure that you are starting from scratch&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nmcli con delete &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;SSID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the following command to (re)add the new connection&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nmcli dev wifi connect &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;SSID&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; password &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;password&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start up the new connection&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nmcli con up &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;WiFi Name&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now you can connect to your new Home Assistant instance at the IP address it has or if you have mDNS discovery on your network you can go to `&lt;a href=&quot;http://hassio.local:8123&quot;&gt;http://hassio.local:8123&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you are connected to Home Assistance, you need to install the MQTT Add On&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the Hass.io Page and select the Add On tab&lt;/li&gt;
&lt;li&gt;Search for MQTT&lt;/li&gt;
&lt;li&gt;Click on the mosquitto broker and install it&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Configuration &amp;gt; Users&lt;/code&gt; and add a new username and password for the user that will be used to connect all the ESP-8266&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rewrite all of the Arduino code to connect to the new Home Assistant MQTT broker. After you have done this, remove all the logic from the stop-light that decided on what light it should be set to. This logic is going to be moved into home assistant using automations. You will need to add the following line to each of the setup functions of each Arduino.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;client.connect((char*) device_id.c_str(), &amp;quot;[username]&amp;quot;, &amp;quot;[password]&amp;quot;);
client.publish(&amp;quot;homeassistant/sensor/garage/[dev_name]/config&amp;quot;, &amp;quot;{\&amp;quot;name\&amp;quot;: \&amp;quot;[Device Name]\&amp;quot;, \&amp;quot;state_topic\&amp;quot;: \&amp;quot;/[Publish Topic]\&amp;quot;}&amp;quot;);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now that you have all of your devices registering themselves with home assistant you are ready to create your dashboard. You can do this by going to the &lt;code class=&quot;language-text&quot;&gt;Overview&lt;/code&gt; and click the edit button (it is a pencil).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You will then go to the add FAB at the bottom to add a card. &lt;/li&gt;
&lt;li&gt;Select sensor and select the 3 entities: door, distance-sensor, and stop-light&lt;/li&gt;
&lt;li&gt;Now you will be able to see the state of these three different entities. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now it’s time to add the logic to actually make the stop light work again. As previously stated, this logic is now going to be in Home Assistant. That means that we are going to need to add a hand full of automations. You should put an automation that will trigger on the mqtt topic of the distance sensor but only if the door sensor is open.&lt;/li&gt;
&lt;li&gt;Once you have these automations up and running, you’ll need to then set up some kind third party automation. I chose to use IFTTT to make it so that I would get a notification if the Garage Door was left open too long. &lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To set up IFTTT, you need to do the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Register with an IFTTT account on &lt;a href=&quot;https://ifttt.com&quot;&gt;https://ifttt.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Add webhook Applet and configure it to send a notification on the webhook of the garage door being left open&lt;/li&gt;
&lt;li&gt;Then add an automation in Home Assistant that will hit that webhook on the trigger of the garage door being open for 10s and there is no change in the stoplight. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now you have a home assistant client that is set up to correctly change a stoplight and will send you a notification if your garage door has been left open for too long.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Thought Questions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Which version of Home Assistant did you choose to install? (Docker-based Hass.io, Raspbian-based Hassbian, or install it yourself?) Why did you choose this particular version?&lt;/h4&gt;
&lt;p&gt;I used the Raspbian based Hass.io image. I used this because I was familiar with the installation process. I did try the .vhdx of hass.io but it was having some kernal issues when I was installing it with Hyper-V so I changed to the raspberry pi image.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;How should you decide which logic to perform in Home Assistant versus coding the logic directly into the devices? What guiding principles would you establish for future devices?&lt;/h4&gt;
&lt;p&gt;In my mind it matters most about how quickly triggers need to cause things to happen in the system. In this case, where the stoplight needs to change super quickly as things change then the logic needs to be close to the stoplight. The stoplight should probably have the logic inside of it so it is the most repsonsive. However, if something doesn’t need to be super responsive the logic can be in Home Assistant or the like.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What features do you like the most about Home Assistant?&lt;/h4&gt;
&lt;p&gt;The feature I like most about home assistant is the automation part. I really like that you can just set arbitrary triggers and have them set something into motion. This seems like it is extremely extendible. I also really like how you can have conditional triggers as well. It makes it so that the integrations can be much larger.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Please estimate the total time you spent on this lab and report.&lt;/h4&gt;
&lt;p&gt;9 hrs&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. &lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: DIAGRAMS&lt;/h4&gt;
&lt;p&gt;Logical Layout
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/00d6621cb5e9afbe37c0b102bb885ca5/c1478/logical-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 61.87433439829606%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAABYlAAAWJQFJUiTwAAABvUlEQVQoz32TzXLTMBDH83g8Bi/Ql+DAEzDDDU4MvTLDob2E6RO0BVpCGuPSOnGciR3Lsmzrw/5XK6E0FBfN7HhntfvbD60nfd+DZBgGBP2pAAO46hExiYQr3FnRZjxmEhSt9R5M569EWiHeMuStcXep0ODS6mNACjDGgDEGzjmEEKjreg/rlMJ2k+FXXuPzb4HpsrEioFyF/f8rJCE4genr27WBTQXeaXyarXEyW2Ea5y7Zsy2HNsNp29Zeett1aXByW2HO9J/bx5EoWz0lPgTvWz6dnmGZrqGkRLbZgFUVdNfizVWFDwuB9z+5G0VRltiR7HauE7IROEAdUFrDj/kComnQdR1KG0C6kh3ezTjefs3xcVFj6A2kVA5Q2YQ0b4JmWebiiDXxc8JIy95eSOB7VqHoeveqw4EQmPwYK9E0wvlPXFBR4Pj1K6yTBMY5MDcG0ge7MlWxhbGj6J88Qpj9+eUt7pP8EZimKY5evkAczd3CNrZdCiDocrXC+cUFVtbncD/3a2VHcPktwU208cBQerSMobR/ydASrRFVn9jK6Tv8U6GHfjm7RhRnHnhY+thehf0Mf9KYeLDXHwCKL6BkUXn2EAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Logical Layout&quot;
        title=&quot;Logical Layout&quot;
        src=&quot;/static/00d6621cb5e9afbe37c0b102bb885ca5/b9e4f/logical-diagram.png&quot;
        srcset=&quot;/static/00d6621cb5e9afbe37c0b102bb885ca5/cf440/logical-diagram.png 148w,
/static/00d6621cb5e9afbe37c0b102bb885ca5/d2d38/logical-diagram.png 295w,
/static/00d6621cb5e9afbe37c0b102bb885ca5/b9e4f/logical-diagram.png 590w,
/static/00d6621cb5e9afbe37c0b102bb885ca5/f9b6a/logical-diagram.png 885w,
/static/00d6621cb5e9afbe37c0b102bb885ca5/2d849/logical-diagram.png 1180w,
/static/00d6621cb5e9afbe37c0b102bb885ca5/c1478/logical-diagram.png 1878w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 2: Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/it441-home-assistant&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Lab 4 - MQTT Event Hub – Garage Door Sensor]]></title><description><![CDATA[Objectives The purposes of this lab are to: Implement an Event Hub for publish/subscribe notifications between devices Develop a…]]></description><link>https://blog.rbrtson.com/lab-4/</link><guid isPermaLink="false">https://blog.rbrtson.com/lab-4/</guid><pubDate>Tue, 29 Oct 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objectives&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement an Event Hub for publish/subscribe notifications between devices&lt;/li&gt;
&lt;li&gt;Develop a communications protocol for devices across the event bus&lt;/li&gt;
&lt;li&gt;Establish more complex conditions for the actuator involving multiple sensors &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (MacBook Pro)&lt;/li&gt;
&lt;li&gt;3 x ESP8266 Wemos D1 Mini (Microcontroller)&lt;/li&gt;
&lt;li&gt;3 x USB -&gt; MicroUSB cable for connecting the Microcontroller to the computer&lt;/li&gt;
&lt;li&gt;3 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x Stop light LED component with built in resistors&lt;/li&gt;
&lt;li&gt;1 x Hypersonic distance detector&lt;/li&gt;
&lt;li&gt;1 x Magnetic door sensor&lt;/li&gt;
&lt;li&gt;9 x Male to male jumper cables&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BuiltInExamples&quot;&gt;Arduino IDE Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot;&gt;PubSubClient Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://subscription.packtpub.com/book/application_development/9781787287815/1/ch01lvl1sec12/installing-a-mosquitto-broker-on-macos&quot;&gt;MacOS Mosquitto Instructions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.steves-internet-guide.com/install-mosquitto-linux/&quot;&gt;Linux Mosquitto Instructions&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Set up MQTT server/broker. This can be done by installing it on Linux or Mac using the following guides&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.steves-internet-guide.com/install-mosquitto-linux/&quot;&gt;Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://subscription.packtpub.com/book/application_development/9781787287815/1/ch01lvl1sec12/installing-a-mosquitto-broker-on-macos&quot;&gt;MacOS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up your Arduino dev environment to work with the ESP8266 Wemos D1 Mini&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go to Preferences and add the following URL to the &lt;strong&gt;Additional Boards Manager URLs&lt;/strong&gt; field&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;http://arduino.esp8266.com/stable/package&lt;span class=&quot;token italic&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;token content&quot;&gt;esp8266com&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;/span&gt;index.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name] -&amp;gt; Boards Manager&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Search for &lt;em&gt;Wemos&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Install esp8266 by ESP8266 Community (&lt;em&gt;Note: this tutorial was made using verions 2.5.2 and does not guarantee that everything will work the exact same in later versions&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name]&lt;/code&gt; again and select the following board&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;LOLIN(WEMOS) D1 R2 &amp;amp; Mini&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Port&lt;/code&gt; and select the port that your Arduino is plugged into. (If you have issues on this step, you can find help &lt;a href=&quot;https://learn.sparkfun.com/tutorials/usb-serial-driver-quick-install-/all&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Erase Flash:&lt;/code&gt; and select &lt;code class=&quot;language-text&quot;&gt;All Flash Contents&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You are ready to start coding!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implement WiFi on the 3 Arduinos for 3 different files: stoplight, distance sensor, and door sensor using the example WiFi setup by going to&lt;br/&gt;&lt;code class=&quot;language-text&quot;&gt;File -&amp;gt; Examples -&amp;gt; ESP8266WiFi -&amp;gt; WiFiClientBasic&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Here are the libraries you’ll need&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;
#include &amp;lt;ESP8266WiFiMulti.h&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Here is the function to connect to wifi&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;void connectToWifi(){
WiFi.mode(WIFI_STA);
wifiMulti.addAP(ssid1, passwd1);
wifiMulti.addAP(ssid2, passwd2);

Serial.print(&amp;quot;\nConnecting&amp;quot;);

while (wifiMulti.run() != WL_CONNECTED){
delay(500);
Serial.print(&amp;quot;.&amp;quot;);
}
Serial.println();

Serial.print(&amp;quot;Connected to &amp;quot;);
Serial.print(WiFi.SSID());
Serial.print(&amp;quot;, IP Address: &amp;quot;);
Serial.println(WiFi.localIP());

if (wifiMulti.run() == WL_CONNECTED){
digitalWrite(BUILTIN_LED, LOW);
}
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You should call the function above in the setup function&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;void setup(){
Serial.begin(115200);
connectToWifi();
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;After you have tested that you are able to connect to network, you are ready to start connecting all your devices to your HUB/broker&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the following code exerpts to set up each device to talk on the event hub&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Connect to the correct HUB by initializing a PubSubClient client and create a device name of your choosing&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;WiFiClient wifiClient;
PubSubClient client(&amp;quot;broker-ip-addr&amp;quot;, 1883, wifiClient);
String device_name = &amp;quot;esp8266-[whatever name you want]&amp;quot;;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Actually run the client’s connection function&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;while (!client.connected()){
if (client.connect((char*) device_name.c_str())){
Serial.println(&amp;quot;Connected to MQTT Hub&amp;quot;);
String message = &amp;quot;Distance sensor (&amp;quot; + device_name + &amp;quot;) connected @ &amp;quot; + WiFi.localIP().toString();
client.publish(&amp;quot;[topic name]&amp;quot;, message.c_str());
client.subscribe(&amp;quot;[topic name]&amp;quot;); // only if you are going to subscribe to any topic
} else {
Serial.println(&amp;quot;Connection to MQTT failed, trying again...&amp;quot;);
delay(3000);
}  
} &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check at the beginning of each loop to make sure that you’re still connected and try and reconnect if not. If we are connected, we will run the clients loop inside of our loop&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;void loop(){
if (!client.connected()){
reconnectToHub();
}
client.loop()&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can test no that each of your devices connect since they will all publish their IP to the hub. You can subscribe on the command line of the mosquitto broker to see all their connections come through with the following command&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;mosquitto_sub -t &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;topic-name&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; -v&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you have confirmed that all of your devices are correctly talking to the HUB let’s get the door sensor, the simplest sensor, up and running&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up sensor by attaching one pin of the sensor to a pin, I used D6, on the Microcontroller. It doesn’t matter which one you connect as either one will work for the sensor’s circuitry. Connect the sensor’s other pin to ground. Now that the sensor is connected we’re ready to hook it up in the code&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To do this you will want to make the pin type &lt;code class=&quot;language-text&quot;&gt;INPUT_PULLUP&lt;/code&gt;. This should be done in the setup() function. You can initialize the pin, D6 in this case, using the following&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;pinMode(D6, INPUT_PULLUP);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Now all you’ll want to do is watch to see if the pin changes from high to low of vice versa. Once it changes, you should publish this change onto the hub to tell everyone subscribed that the door status has changed. It is also worth while to send out a periodic status of the door in case any node connects in between state changes they can still get the current status.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next we will want to set up the distance sensor. To do this, we will need to set up the same code as in &lt;a href=&quot;../lab-3&quot;&gt;Lab 3&lt;/a&gt;. This will send out a hypersonic frequency and determine how far something is away based on the frequency that comes back. To do this, we will need to do the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Initialize each pin in the setup function. The trig pin or trigger pin should be an OUTPUT pin and the echo pin should be an INPUT pin&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, on every loop we should send out a frequency and listen for the response. With this response, we can determine the distance the object in front of the sensor is using what we know about the speed of sound. This will look something like this&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Using this distance, we can publish the current distance away something is based on the sensor’s reading. To do this you should use the &lt;code class=&quot;language-text&quot;&gt;client.publish([topic], [message]);&lt;/code&gt; function. I chose to do this every second so that any given point anything subscribed to the distance should have a pretty accurate reading of the distance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now that we have our two sensors publishing to the event hub, we can consume that data to determine what color our stoplight should be. The basic idea is that a stoplight should be off if the garage door is closed (i.e. the door sensor reads closed) and on if the garage door is open (i.e. the door sensor reads open). The color of the stoplight should be determined by the distance sensor using the following ranges &lt;em&gt;(NOTE: All numbers are computed using the above distance algorithm and are measured in cm)&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;RED: &amp;#x3C; 15 and &gt;= 5&lt;/p&gt;
&lt;p&gt;YELLOW: &amp;#x3C; 25 and &gt;= 15&lt;/p&gt;
&lt;p&gt;GREEN &gt;= 25&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;You’ll notice that there is a hole in these ranges of less than 5. This is because when the distance reader is less than 5, the stoplight should flash red indicating that the car has gone too far and should back up. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The stoplight should subscribe to the topic for the distance sensor and for the door sensor. This way, it will be able to know when there are changes and change accordingly.&lt;/li&gt;
&lt;li&gt;That’s it! You now have a stoplight that will change colors based on an objects distance and only function when the garage door is open. It also functions without using any kind of web server architecture! How amazing right?!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Thought Questions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;How does the communication between devices change with the shift to using an event hub? How does this facilitate greater scalability? What things did you do to learn to use MQTT?&lt;/h4&gt;
&lt;p&gt;Things no longer have to worry about staying up to date with everything via requests. Now, everything just listens to exactly the information they need and acts upon it accordingly. This infrastructure scales so much nicer. You are able to set up an infrastructure where things will publish and subscribe how you set up. Then, at a later date, there is no issue with adding something that will continue to consume the data that is already being published. Furthermore, if you add another sensor of some kind, the configuration can already be in all the devices to listen to that topic even before that sensor is put into place. I read a few posts about the idea of what MQTT was and why is was important. Most of my learning came from implementing the library PubSubClient into my devices. As well, I spent a little bit of time having 3 or 4 terminal windows open and publishing and subscribing from them. This helped me easily see in real time what was going on the event hub.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What are strengths and weaknesses of the direct communication between the sensor and actuator? What are strengths and weaknesses of the event hub? Which do you feel is better for this application?&lt;/h4&gt;
&lt;p&gt;I feel there are many strengths with this direct communication. I am able to easily know when something is updated for one or many devices. One weakness I found having to think differently about was the fact that requesting information isn’t where this direct communication shines. It was awkward at first when I was thinking of how to get some of the information because I kept thinking of it as a request/response system which is not how this should be architected. I do think that there are some cases where the request/response architecture still has its merit. I loved the event hub. I thought that being able to just spit information into the system and anyone can access it is absolutely incredible. It made connecting multiple devices a breeze. I feel that MQTT is hands-down the better solution for this application. I think that the ability to have the distance and door sensors information available to anyone who desires it makes this application run smoothly and be super scalable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What was the biggest challenge you overcame in this lab?&lt;/h4&gt;
&lt;p&gt;The biggest challenge for me in this lab was learning how to respect the event hub as an event hub and not a different version of a web server. My mind kept reverting to the web server way of thinking for every little problem to solve and this was not the best way to go about things. Once I got into stride with thinking about the event hub for what it truly was, I was able to come up with much better and more practical solutions. I ran into a few other hiccups here and there with my logic in my stoplight. But overall, my biggest challenge was definitely figuring out how to holistically think differently.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Please estimate the total time you spent on this lab and report.&lt;/h4&gt;
&lt;p&gt;5 hours&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. &lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: DIAGRAMS&lt;/h4&gt;
&lt;p&gt;State Diagram
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/fcc4b9e9f9335814d48cadbb908cad1d/f911f/state-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 77.72972972972974%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAABYlAAAWJQFJUiTwAAACLklEQVQ4y32Uy47TQBBF87n8Ah/AhiWLEUgsgC0LlgyCkZAAaWYBQkKjWQ1SHiSxYzt+v+1Ln056gElCSSWX2123bt3q9mQYBt33cRzVtq2CIFCWZSrLUlVVWSfmm913JG9yDIwnQKvVStvtVnme23eeABZFocLEfd//A3oU0IGxGYbr9doy67pOTdP8ATRxGIYaJA17EsN9QCqQTKJ7khxFkWVX17Vq2m47hd+ulJ49VvH5Qr0BHfcSHDAEgESYOEaugNWyLLQtSm1fnKl7+EDlk0dqzNoI06E/BCQJNggPM1rebDa2CG0jRTuMim9+qHp1pvDThWqzrn3bBy3DEFCcgeAAOSP2PU+5KYAlhq3v+7sBoSGLBDgGE6aLwzKOY5vAoHbHpTft18rSVG3pqcgSU7w2+TtSEyZFi+iEp2ajneKe6Xw+t+BJkthiVVUqyyv5048qZ8+V/Do3hbq74zahOpsRHRD0gj5gaPi3kUTROMkVzd6pnj9VPH2tpq6QcAfoNmIALhYLLZdLeehkmLOGjoATw7A3Q8nSUGX0XXE4U1k1x4eCww62gLkD7drBMfT0/cCcO5lOWnm+d7fv5NWjZTRDQxgT842CmBcsdbO+1CqampbNsNxQ/vdzcHfXHWzXcm1YfZ291/ntM32ZvjHsWlvkJKADpQ1OARoC6KacxKmu51f68POlLm/fKgyMnlbb/jSgA3VtAgbTuqnNO/d2VFKGStLEMN/93sj5DdNg1NQHe5P9AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;System State Diagram&quot;
        title=&quot;System State Diagram&quot;
        src=&quot;/static/fcc4b9e9f9335814d48cadbb908cad1d/b9e4f/state-diagram.png&quot;
        srcset=&quot;/static/fcc4b9e9f9335814d48cadbb908cad1d/cf440/state-diagram.png 148w,
/static/fcc4b9e9f9335814d48cadbb908cad1d/d2d38/state-diagram.png 295w,
/static/fcc4b9e9f9335814d48cadbb908cad1d/b9e4f/state-diagram.png 590w,
/static/fcc4b9e9f9335814d48cadbb908cad1d/f9b6a/state-diagram.png 885w,
/static/fcc4b9e9f9335814d48cadbb908cad1d/2d849/state-diagram.png 1180w,
/static/fcc4b9e9f9335814d48cadbb908cad1d/f911f/state-diagram.png 1850w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Logical Layout
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/a4cb6f4d0244a535a39f5ee7713e7dd3/e9603/logical-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 53.295128939828075%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAABYlAAAWJQFJUiTwAAABIUlEQVQoz5VSyYqFQAz0///Ngx5ExX1BRdwVdzNUIIPTh8e8QGg7SyVVrXbfNz3PQ6ohhtxxHHSeJ13X9fv9qUdDcp5nyvOcsixj77qOAfZ9p2maqCxLsm2b48MwcPO2bVQUBaVpyl5VFcc0TESR7/sUBAF5nkdN09C6rrwRwJCLoojzyMGWZWEgDArDkOsQ07BJ3/ccdF2Xm+q65mkYliQJ6bpOhmGQaZqcewM6jsM92BBMmTJAYaAn+qgOFu876gQY0kiMASUJjbAtgMdx5FMcVN938bZtWZo/gPJiKJBXxNb/dVmKAREAd7yYZVkUxzEDQ0OYDJQGlbbqGtYFAH4XCIwTd2gjgN84U4ZeeHaA4YSWb6G/BlT/+k+UVAnU2A+K2lR2n2EOFAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Logical Layout&quot;
        title=&quot;Logical Layout&quot;
        src=&quot;/static/a4cb6f4d0244a535a39f5ee7713e7dd3/b9e4f/logical-diagram.png&quot;
        srcset=&quot;/static/a4cb6f4d0244a535a39f5ee7713e7dd3/cf440/logical-diagram.png 148w,
/static/a4cb6f4d0244a535a39f5ee7713e7dd3/d2d38/logical-diagram.png 295w,
/static/a4cb6f4d0244a535a39f5ee7713e7dd3/b9e4f/logical-diagram.png 590w,
/static/a4cb6f4d0244a535a39f5ee7713e7dd3/f9b6a/logical-diagram.png 885w,
/static/a4cb6f4d0244a535a39f5ee7713e7dd3/2d849/logical-diagram.png 1180w,
/static/a4cb6f4d0244a535a39f5ee7713e7dd3/e9603/logical-diagram.png 1396w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 3: Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/it441-mosquitto-hub&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Lab 3 - Arduino Stop Light w/ Distance Detector 🚦]]></title><description><![CDATA[Objectives The purposes of this lab are to: Build an IoT sensor using GPIO pins for inputs Establish a machine-to-machine (M2M…]]></description><link>https://blog.rbrtson.com/lab-3/</link><guid isPermaLink="false">https://blog.rbrtson.com/lab-3/</guid><pubDate>Tue, 15 Oct 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objectives&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build an IoT sensor using GPIO pins for inputs&lt;/li&gt;
&lt;li&gt;Establish a machine-to-machine (M2M) communication protocol&lt;/li&gt;
&lt;li&gt;Design an IoT interaction between a sensor and an actuator.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (MacBook Pro)&lt;/li&gt;
&lt;li&gt;2 x ESP8266 Wemos D1 Mini (Microcontroller)&lt;/li&gt;
&lt;li&gt;2 x USB -&gt; MicroUSB cable for connecting the Microcontroller to the computer&lt;/li&gt;
&lt;li&gt;2 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x Stop light LED component with built in resistors&lt;/li&gt;
&lt;li&gt;1 x Hypersonic distance detector&lt;/li&gt;
&lt;li&gt;9 x Male to male jumper cables&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BuiltInExamples&quot;&gt;Arduino IDE Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi/examples&quot;&gt;ESP8266WiFi Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266HTTPClient&quot;&gt;ESP8266HTTPClient Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../lab-2&quot;&gt;Stoplight Lab&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/&quot;&gt;Guide On Arduino Ultrasonic Sensor&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Set up stoplight with web server by following &lt;a href=&quot;../lab-2&quot;&gt;Lab 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up your Arduino dev environment to work with the ESP8266 Wemos D1 Mini&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go to Preferences and add the following URL to the &lt;strong&gt;Additional Boards Manager URLs&lt;/strong&gt; field&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;http://arduino.esp8266.com/stable/package&lt;span class=&quot;token italic&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;token content&quot;&gt;esp8266com&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;/span&gt;index.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name] -&amp;gt; Boards Manager&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Search for &lt;em&gt;Wemos&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Install esp8266 by ESP8266 Community (&lt;em&gt;Note: this tutorial was made using verions 2.5.2 and does not guarantee that everything will work the exact same in later versions&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name]&lt;/code&gt; again and select the following board&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;LOLIN(WEMOS) D1 R2 &amp;amp; Mini&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Port&lt;/code&gt; and select the port that your Arduino is plugged into. (If you have issues on this step, you can find help &lt;a href=&quot;https://learn.sparkfun.com/tutorials/usb-serial-driver-quick-install-/all&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Erase Flash:&lt;/code&gt; and select &lt;code class=&quot;language-text&quot;&gt;All Flash Contents&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You are ready to start coding!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Implement WiFi on the Arduino using the example WiFi setup by going to &lt;code class=&quot;language-text&quot;&gt;File -&amp;gt; Examples -&amp;gt; ESP8266WiFi -&amp;gt; WiFiClientBasic&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;After you have tested that you are able to connect to network, you are ready to start setting your client you will use to send requests to the stop light&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up your client by first creating the client object by&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;WifiClient client;
HTTPClient http;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;This will create the objects needed to make an HTTP request&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can make an HTTP request using the following format&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;if (http.begin(client, [url])){
  int httpCode = http.GET();

  if (httpCode &amp;gt; 0){
    if (httpCode == HTTP_CODE_OK){
      String payload = http.getString();
      Serial.println(payload);
    }
  } else {
    Serial.printf(&amp;quot;[HTTP] GET Failed, error: %s\n&amp;quot;, http.errorToString(httpCode).c_str());
  }
  http.end();
} else {
  Serial.println(&amp;quot;[HTTP] Unable to connect&amp;quot;);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After you have your function that will make your HTTP request to change the light, you will need to make sure that your pin setup is correct and all pins are set to the correct mode meaning&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Trig Pin =&gt; OUTPUT&lt;/li&gt;
&lt;li&gt;Echo Pin =&gt; INPUT&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you have this set up, you will need to add the code to your loop() function to make it so that you can get the distance of an object at any point.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You are going to do this by calculating the amount of time it takes for the sound to go out, bounce off the object you’re measuring, and come back to the other sensor.&lt;/li&gt;
&lt;li&gt;This can be accomplished using libraries, however, let’s do it from sratch, for fun.&lt;/li&gt;
&lt;li&gt;The way this works is the Trig Pin (Trigger) sends a frequency (of about 40kHz) out for 10 µs. The echo pin then takes this frequency back in and calculates the duration the frequency took to get from trigger to echo.&lt;/li&gt;
&lt;li&gt;After you have this duration you can figure out how many cm away the object is by the equation &lt;code class=&quot;language-text&quot;&gt;duration * 0.034 / 2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Here is all of that in code&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;c#&quot;&gt;&lt;pre class=&quot;language-c#&quot;&gt;&lt;code class=&quot;language-c#&quot;&gt;  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
  Serial.println(distance);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Now you have the distance of he object, you can do some nice if statements to figure out which light you should turn on. Once you have done this you have a stoplight that responds to a distance sensor and tells you whether to pull forward or not!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Thought Questions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Think of the interaction between your devices. How well would this scale to multiple devices? Is it easy to add another sensor? Another actuator?&lt;/h4&gt;
&lt;p&gt;It wouldn’t be awful to scale out a few more devices. The part that seems like it would be a headache is managing all of the IP addresses for the actuators. Having to keep that in sync with the sensors would be painful. I definitely think an event hub will solve this issue wonderfully.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What are strengths and weaknesses of the tennis-ball-on-a-string system that Don had originally? What are strengths and weaknesses of the IoT system that he developed? What enhancements would you suggest?&lt;/h4&gt;
&lt;p&gt;Some strengths of the tennis-ball-on-a-string is that it is simple. You are able to set it up in a couple of minutes and, quite frankly, it gets the job done. Some weaknesses of it is that it is an annoyance whenever the car isn’t in the garage. There is just a tennis ball in the way of anything else you are trying to do in there. As well, there is a likelihood of the tennis ball falling off or getting knocked off. Some of the strengths of the IoT system is that it would be able to be a system that the driver would use every day. Drivers are very accustomed to stop lights and this would make it nice to be able to incorporate into a normal routine. Some weaknesses would be complexity and maintenance. This solution would need to be maintained in order for it to remain useful.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What was the biggest challenge you overcame in this lab?&lt;/h4&gt;
&lt;p&gt;When trying to get this lab up and running on BYU’s campus, I ran into the captive portal of BYU-WiFi. I didn’t know this was necessarily happening at first and so it caused me good amount of headache trying to debug. Once I realized that’s what it was, it wasn’t too bad to get my hotspot set up and all of my devices connected to it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Please estimate the total time you spent on this lab and report.&lt;/h4&gt;
&lt;p&gt;3 hours&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. &lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: System Interface - Web Page&lt;/h4&gt;
&lt;p&gt;State Diagram
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/f3ccd/state-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 119.53578336557061%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAYAAAD6S912AAAACXBIWXMAABYlAAAWJQFJUiTwAAACwUlEQVQ4y5VVyW7TUBTNT1cCCYkNSHTBH6BShVKx6wqxoQUE3VCVTiK0Lk3qxBk81Y6HxPF0eOeZV5kkRM2Vru6L7XfuuWMaRVFgXsuyBCVNU8RxjOl0iiRJ5DvKsjtKG8vAeNn3fYzHY1iWJc9BEEgbRdHDAQlGRp7nIc9zCWzbtgSj8psoCuHf3YlzvhqQYAyRrCgEHI1G0DQNpmlKJ0FQvZuI72PhrCxXAFIYDhk5joNer3efSyXxbAb75hp3h5/RPj2p8pnnywGzLJM54pnseCbjmQCZCTZpIdLR0xG9fAq8eCRt2L1dAG2ocFlJKnNIpYNOp4NWq4XRYICuZcPYeyfBzM0nKJ5vIDz4AMZQiG8XAFX+eKayCAo8EY540T07xvTZBrD5GLGw5slRle95QAU6mUxkqFSe68KKe2GI4PwHxnu78AW4JapN4d3/tk39zFzSuq6LrigSbUYAOhDf9Pt9WX3mWd1trGpSpQRmOpJkKtHYFLNZhuFwKJ8zXWsByt6T6QgxCU2MzRPEwgZBLBu8Po4PAmRbMMxu5wKh3gTsJoLbJjxHvx+C9QAFi1wQjewjJMYWRpfbiPVX8rdsm9oYNlTsq23FMHDbmPa2UVpNRPoWnNHl33Dz9YtStU4KZ/gTsfUNvq1hOLLu+3bNkLll4mqVjUOkAj/NSrk0WOW124Yaiqbm9onCSLLN0kz0oSGHYCmgol6nPx9yHE1wrf/CtXUKyx8I8FgUa0nbqGWqdJkDiukZ2L/ZwdfBLj6138IwO4ttwwukzP13dXUlLXPFEJkfahAGcG0P37V9fOnt4P3Za3zsbEOzjit2ZfFvyPSgNguVDviMK6xSMVoiMsNu4+D2jWT4Wd/FuSa2T1xFxfFb2NhK6qHWrSCCvujFC+MQv40WHNuVC4JLQ/15NeaT/5C5hjCpWA5kNU/gDw11PWYtMtekAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;System State Diagram&quot;
        title=&quot;System State Diagram&quot;
        src=&quot;/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/b9e4f/state-diagram.png&quot;
        srcset=&quot;/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/cf440/state-diagram.png 148w,
/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/d2d38/state-diagram.png 295w,
/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/b9e4f/state-diagram.png 590w,
/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/f9b6a/state-diagram.png 885w,
/static/ba4f63b0a8877cfe8cb19dd7a9ee2486/f3ccd/state-diagram.png 1034w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 3: Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/it441-arduino-distance-sensor&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Lab 2 - Arduino Stop Light 🚦]]></title><description><![CDATA[Objective The purposes of this lab are to: Reinforce enumerating requirements from use cases and user stories Become familiar with the…]]></description><link>https://blog.rbrtson.com/lab-2/</link><guid isPermaLink="false">https://blog.rbrtson.com/lab-2/</guid><pubDate>Tue, 01 Oct 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objective&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reinforce enumerating requirements from use cases and user stories&lt;/li&gt;
&lt;li&gt;Become familiar with the Arduino platform and its programming methodologies.&lt;/li&gt;
&lt;li&gt;Program an Arduino-based microcontroller to use the GPIO pins to control LEDs.&lt;/li&gt;
&lt;li&gt;Develop iteratively, beginning with a minimum viable product and add functionality until the requirements are met.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (MacBook Pro)&lt;/li&gt;
&lt;li&gt;1 x ESP8266 Wemos D1 Mini (Microcontroller)&lt;/li&gt;
&lt;li&gt;1 x USB -&gt; MicroUSB cable for connecting the Microcontroller to the computer&lt;/li&gt;
&lt;li&gt;1 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x Stop light LED component with built in resistors&lt;/li&gt;
&lt;li&gt;5 x Male to male jumper cables&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BuiltInExamples&quot;&gt;Arduino IDE Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer&quot;&gt;ESP8266WebServer Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.esp8266.com/viewtopic.php?f=8&amp;#x26;t=4685&quot;&gt;Forum on how to use PROGMEM to store HTML&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Install the Arduino IDE from &lt;a href=&quot;https://www.arduino.cc/en/main/software&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up your environment to work with the ESP8266 Wemos D1 Mini&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go to Preferences and add the following URL to the &lt;strong&gt;Additional Boards Manager URLs&lt;/strong&gt; field&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;http://arduino.esp8266.com/stable/package&lt;span class=&quot;token italic&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;token content&quot;&gt;esp8266com&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;_&lt;/span&gt;&lt;/span&gt;index.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name] -&amp;gt; Boards Manager&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Search for &lt;em&gt;Wemos&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Install esp8266 by ESP8266 Community (&lt;em&gt;Note: this tutorial was made using verions 2.5.2 and does not guarantee that everything will work the exact same in later versions&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Board: [Some Board Name]&lt;/code&gt; again and select the following board&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;LOLIN(WEMOS) D1 R2 &amp;amp; Mini&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Port&lt;/code&gt; and select the port that your Arduino is plugged into. (If you have issues on this step, you can find help &lt;a href=&quot;https://learn.sparkfun.com/tutorials/usb-serial-driver-quick-install-/all&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Go to &lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Erase Flash:&lt;/code&gt; and select &lt;code class=&quot;language-text&quot;&gt;All Flash Contents&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You are ready to start coding!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Implement WiFi on the Arduino using the example WiFi setup by going to &lt;code class=&quot;language-text&quot;&gt;File -&amp;gt; Examples -&amp;gt; ESP8266WiFi -&amp;gt; WiFiClientBasic&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;After you have tested that you are able to connect to network, you are ready to start setting up your web server. &lt;/li&gt;
&lt;li&gt;Using the docs found for the &lt;a href=&quot;https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer&quot;&gt;ESP8266WebServer Library&lt;/a&gt;, create a web server that will turn on and off the lights and set them to a cycle mode. For the cycle mode, I would suggest using the millis() library so that you don’t lock up your server by using delay()‘s.&lt;/li&gt;
&lt;li&gt;Once you have all of your code written and you’re ready to test it, connect your Arduino to the computer and flash it by going to &lt;code class=&quot;language-text&quot;&gt;Sketch -&amp;gt; Upload&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Once it has been flashed, keep it connected and open up the serial monitor (&lt;code class=&quot;language-text&quot;&gt;Tools -&amp;gt; Serial Monitor&lt;/code&gt;) so that you can monitor the server’s output.&lt;/li&gt;
&lt;li&gt;You have now implemented a stoplight using an Arduino! What else can you do using the same simple libraries??&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Thought Questions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;What are some key differences between developing this lab on a Raspberry Pi, and developing on Arduino?&lt;/h4&gt;
&lt;p&gt;Developing on a Pi has a lot of overhead. There are a lot of different steps needed to even get the Pi up and running and able to host a web server. A Pi has multiple uses other than running a program for you since it has an entire OS on it. An Arduino on the other hand has a single purpose: be given compiled code and run it whenever I have power. Because of the simplistic nature, I had to be more creative to do things that are pretty easily implemented on a Pi (such as timeouts).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What are the strengths and trade-offs of each of these platforms?&lt;/h4&gt;
&lt;p&gt;I think that a Pi can do more complicated things quicker. As well, a Pi is a bit easier to work with. An arduino on the other hand is much more straight forward. There are two functions that need to be implemented and then you have a working product. As well, there is no overhead with starting/stopping a server which I think is incredible. It either has power or it doesn’t and if it does have power, it runs. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;How familiar were you with the Arduino platform prior to this lab?&lt;/h4&gt;
&lt;p&gt;I had never used the Arduino platform prior to this lab. However, I will definitely be using it going forward it is an incredibly easy platform to work with and very powerful. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;What was the biggest challenge you overcame in this lab?&lt;/h4&gt;
&lt;p&gt;The biggest challenge I had to overcome was getting my Arduino on WiFi. For one reason or another, my Arduino really struggled to get connected. It wasn’t until I erased all settings on the Arduino when I flashed the code (instead of just the sketch) that it actually worked for me.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Please estimate the total time you spent on this lab and report.&lt;/h4&gt;
&lt;p&gt;I spent about 1.5 hours on this project as a whole. Most of that time was familiarizing myself with the Arduino architecture.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. &lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: System Interface - Web Page&lt;/h4&gt;
&lt;p&gt;State: Startup, /lights-out
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/f570d/stoplight-off.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 77.5%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABzElEQVQ4y6WTW5OaQBCFeV8FBEE3iwreuKlEZ7hauqwRtSqV/P9/c9IjbqqSrEtVfDh1mJ7uj56btC0rRLzAiuVY8RxhxOHMfAzHLkYT0tgjJ9H4GrvJpthVUx/uPIQbLLH8yiFVlwsOxyMOVYVd+UZ+Jj8gLXKseQaeJNjEMXiaIclzMHKW5IhYfAUkRYEf5Suq0xFxVkByPRdzdwbPF17L9XwEgUffIZKEI01jMM7g+x7lBXD9EM5khqE9wXRGtWGAuRdgOnchyW0FsvyvWq02dL2LvNjidL5gs2F4emrd5mUo5Iqi1mPBaMswDBOSpun4WwLU6WgYDIZYhgusgpA6DmGavTqH5v/Mr73ff4YkCj+Cir+PbAdVkuEnT1AwDoOA9/JF3BQd3ktQb8BXgp3WtPlr1gjs9foNwJGDbZGi3CXgdCiG0QT8ZMmqWgOPb7Tkc4o84+gaj3R4AxZ5iv0uBWcPLlkhoD2yEZdbsPMeG7qLYtMfBDrIvu2Rfi/BqdOHgKragWUNsFxFWEQR3cMFHYrxf8COcIqLOf3FhmG70Mzn37APawTws4v9Hu9aDsyxD71v3e3uPf/Li9UM1HQDWte8PrcmoHh6vwANNaZ7qnb9ywAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Off&quot;
        title=&quot;Stoplight Page Off&quot;
        src=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/b9e4f/stoplight-off.png&quot;
        srcset=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/cf440/stoplight-off.png 148w,
/static/d3e4c54b7531058b67078a58b48e20a4/d2d38/stoplight-off.png 295w,
/static/d3e4c54b7531058b67078a58b48e20a4/b9e4f/stoplight-off.png 590w,
/static/d3e4c54b7531058b67078a58b48e20a4/f9b6a/stoplight-off.png 885w,
/static/d3e4c54b7531058b67078a58b48e20a4/f570d/stoplight-off.png 960w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: RED on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/4909f/stoplight-red.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.03970741901776%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABD0lEQVQ4y62RTW6DMBCFc4AqwTZQIiVAjISNnUTtgr+CCF00qqqepLsepPuetZtXg8SiUtJEkMVoNG+eP82MZ5QyEELR5SGGerGwsFqtUaQZmqpGGIa9durNELP/mpZF4PsBdFFgX9fgUdRrp7xXAyMh8cUTfAcCiVSwzngvApmJuQHuYoEfugHmAUqR4M54GRk5ITFALiU+9o/43D1AKH3We/XK0qzcvJRojiW01kabCBQGeDzkeG1zaHULYCyRHSpkbQV1i5WFuWH21iJ7f4babvu7TgLG5pfTpxxpVSBJ1LQJO912XHh+BG/N4bjeOOBQd5kwG85GwuEK1Hb/9EZNSKkN5i7B7pegBn5pwl9OZErlaIKrmwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Red&quot;
        title=&quot;Stoplight Page Red&quot;
        src=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/b9e4f/stoplight-red.png&quot;
        srcset=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/cf440/stoplight-red.png 148w,
/static/ebaa16bfbc609529750cbc0831e1db5a/d2d38/stoplight-red.png 295w,
/static/ebaa16bfbc609529750cbc0831e1db5a/b9e4f/stoplight-red.png 590w,
/static/ebaa16bfbc609529750cbc0831e1db5a/f9b6a/stoplight-red.png 885w,
/static/ebaa16bfbc609529750cbc0831e1db5a/4909f/stoplight-red.png 957w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: YELLOW on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/4909f/stoplight-yellow.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.4576802507837%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABH0lEQVQ4y6WTb06DMBiHd4IBbQFnMhYYgQIzgcmfUcIy/WCcHtMDeAJP4AX84A08xM+WuMVMmSb98KTll74P75umE8ZsUCph35DfKrcsgvncQ1lWEK2A7/tD9mvNFxNC6HDoFJUbhgnPW6DebND1PYJgOWRjNYqjUK2nmKaFKIohigIiz8F5Mnr2wFmhIYUJ57hf13goalxlmfyJhtCSwmXIcdc32G9rRHGm2aFhIU043p4FPl46lOsM0ykB1RFyOfLrU4t3Kb3OpdDQEKpLCeXI7U5A3Hb6Iyuh6rDa71A93iBbrYZMSxjHHE3fotkKpKlmhyq3HReXi3DAcS/+L/zBIacMzOewgxSEOUfh2ZcyiiqWQurMQN3ZsCd/dPgJ1rNNyhvfpTQAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Yellow&quot;
        title=&quot;Stoplight Page Yellow&quot;
        src=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/b9e4f/stoplight-yellow.png&quot;
        srcset=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/cf440/stoplight-yellow.png 148w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/d2d38/stoplight-yellow.png 295w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/b9e4f/stoplight-yellow.png 590w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/f9b6a/stoplight-yellow.png 885w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/4909f/stoplight-yellow.png 957w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: GREEN on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/f4b04/stoplight-green.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.11053180396247%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABHklEQVQ4y62T0UrDMBSG9wDi0iZpp7CtbmNNqmB1W9rF6d0qiCBeC76DN76E3uj7yr+TwLxQo2K9+Aj8Ofn5zyGnw7lATPAvYCxGvz/AYmFg7RmyYeY1Hqh3dOKYI4riTzi922UYkImpatjVCqODkddCbxzvhu78CGMRprmCLU9hj0+glA7WbvnRUJPJ1dzgmjjUhddaGeaU8NwYXBCaDKO2hq7NZr3EZbNEUfxDQkUJ19UMDVH4llvOMJ/kqJ7vUL3e0zzbJORkuMugyiPUb0+o8QJdlWA7zN/9LWFECcc5zMMNzOMt9FST1qJlpwuZopdk6MkhZJL+/h8GoXUSYw05oS8jku9r3ab4XSZTHpgL5xIi3SP2wYUMJtvu8gaZeUzBPYvSeQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Green&quot;
        title=&quot;Stoplight Page Green&quot;
        src=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/b9e4f/stoplight-green.png&quot;
        srcset=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/cf440/stoplight-green.png 148w,
/static/b699ce1935b93c6a20e25005a33c8a8e/d2d38/stoplight-green.png 295w,
/static/b699ce1935b93c6a20e25005a33c8a8e/b9e4f/stoplight-green.png 590w,
/static/b699ce1935b93c6a20e25005a33c8a8e/f9b6a/stoplight-green.png 885w,
/static/b699ce1935b93c6a20e25005a33c8a8e/f4b04/stoplight-green.png 959w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 2: Server Output (via Serial)&lt;/h4&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/dfa95aad6c1fa60070410995feda1226/b5f89/SerialServerOutput.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 35.75615474794842%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABGklEQVQoz32QW2+DMAyF+f9/DBV4aAXt1D30EsbKpQVCChRCe2ZbYq2mbZaOnBj74zjOYX/AbreHOh6RpinyPEdRnJFnOcpLiaqqUNW1ZGMMTGPQdZ3IXPneoKbvWmtkWQZHKSXDjW6QEVBTbtsO1loUeQFdazweD9QVQcv6e7gh0DRNeA2uOWma4UJO7ve7uLjdBnQEHIaBXCtxPY4jYhWLkiQhfeJ0SglgBMSzHPwz5yNOaM0zDVmUZYm+72UtbmJnv8ezzj1znwB5peu1FQDDeI1hGPFfzJCnXhzODbMjBk505mztJG/5U38FP5Pj+z4WCw+e58F1XYRhiPV6jSiKJL9qs9lguVxJ/3b7LmffD6j+hiAI6L7EF+afFgAc6QcgAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Serial Server Output&quot;
        title=&quot;Serial Server Output&quot;
        src=&quot;/static/dfa95aad6c1fa60070410995feda1226/b9e4f/SerialServerOutput.png&quot;
        srcset=&quot;/static/dfa95aad6c1fa60070410995feda1226/cf440/SerialServerOutput.png 148w,
/static/dfa95aad6c1fa60070410995feda1226/d2d38/SerialServerOutput.png 295w,
/static/dfa95aad6c1fa60070410995feda1226/b9e4f/SerialServerOutput.png 590w,
/static/dfa95aad6c1fa60070410995feda1226/b5f89/SerialServerOutput.png 853w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 3: Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/it441-arduino-stop-light&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Lab 1 - Raspberry Pi Stop Light 🚦]]></title><description><![CDATA[Objective The purposes of this lab are to: Learn to enumerate requirements from use cases and user stories Learn to utilize the general…]]></description><link>https://blog.rbrtson.com/lab-1/</link><guid isPermaLink="false">https://blog.rbrtson.com/lab-1/</guid><pubDate>Tue, 17 Sep 2019 00:00:00 GMT</pubDate><content:encoded>&lt;h3&gt;Objective&lt;/h3&gt;
&lt;p&gt;The purposes of this lab are to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn to enumerate requirements from use cases and user stories&lt;/li&gt;
&lt;li&gt;Learn to utilize the general purpose input/output (GPIO) pins on the Raspberry Pi to control LEDs.&lt;/li&gt;
&lt;li&gt;Learn to develop a minimum viable product, and deliver new functionality through subsequent updates until the requirements are met, and all of the deliverables are acceptable.&lt;/li&gt;
&lt;li&gt;Learn to use Github for progressive code commits and version tracking.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Materials&lt;/h3&gt;
&lt;p&gt;The materials used for this lab were&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Personal computer (MacBook Pro)&lt;/li&gt;
&lt;li&gt;Monitor, keyboard, mouse, and necessary cables to develop on the pi&lt;/li&gt;
&lt;li&gt;1 x Raspberry Pi 3 Model B+&lt;/li&gt;
&lt;li&gt;1 x Breadboard&lt;/li&gt;
&lt;li&gt;1 x Stop light LED component with built in resistors&lt;/li&gt;
&lt;li&gt;4 x Female to male jumper cables&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.instructables.com/id/Install-Nodejs-and-Npm-on-Raspberry-Pi/&quot;&gt;Installing Node on a Raspbery Pi&lt;/a&gt; - This site has a wonderful walk through on how to get NodeJS installed on a Raspberry Pi. Node is what runs the server for this project&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3schools.com/nodejs/nodejs_raspberrypi_blinking_led.asp&quot;&gt;Basic Blink Tutorial for NodeJS&lt;/a&gt; - This is a great tutorial and intro to manipulating GPIO pins on a Raspberry Pi through NodeJS.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/rpi-gpio&quot;&gt;NPM rpi-gpio&lt;/a&gt; - This is the package reference to a great library for manipulating GPIO pins on a Raspberry Pi.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.lucidchart.com/&quot;&gt;Lucidchart&lt;/a&gt; - A wonderful piece of online software that all the state diagrams were made through&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/facebook/create-react-app&quot;&gt;Create React App&lt;/a&gt; - A wonderful wrapper to quickly create a ReactJS frontend application&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://expressjs.com/&quot;&gt;ExpressJS&lt;/a&gt; - The documentation for the library used to create the API in NodeJS&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/express-promise-router&quot;&gt;NPM express-promise-router&lt;/a&gt; - A useful package for having the Express API be asynchronous &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/onoff&quot;&gt;NPM onoff&lt;/a&gt; - The package used in this lab to manipulate GPIO pins&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/path&quot;&gt;NPM path&lt;/a&gt; - A necessary tool for grabbing relative paths to server up certain files from NodeJS&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Procedures&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Follow the guide in &lt;a href=&quot;https://www.instructables.com/id/Install-Nodejs-and-Npm-on-Raspberry-Pi/&quot;&gt;Reference 1&lt;/a&gt; to install NodeJS onto a Raspberry Pi&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Ensure Node installed by running the following command&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;node --version&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure npm installed by running the following command&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; --version&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;If either of these don’t return a version number, run through the above tutorial again and try to install it again. Also try and check that npm and node were both successfully added to your PATH variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once that is installed follow the documentation on how to set up a simple NodeJS server &lt;a href=&quot;https://expressjs.com/en/starter/hello-world.html&quot;&gt;here&lt;/a&gt;. The simple NodeJS + ExpressJS server they provide for you is&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; express &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;express&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; port &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3000&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;Hello World!&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;port&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Example app listening on port &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;port&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once that is installed, it is time to create the frontend part of the application. Do this by using the following command &lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;npx create-react-app ./&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Once it has been installed in the directory you want, you are ready to start creating your server to serve up the React app and the API server that will manipulate the GPIO pins.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Follow the following logical state diagrams to model the data flow on the server side
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 573px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b44c052239aa9546f6f8909a84bad2c1/65025/state-diagram-1.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 81.50087260034904%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACOUlEQVQ4y5VU227TQBD1L4MQ74D4CB6aByQu5aVcJCQiBJHa8lCp5bFIiZM4sR3bsR3H92sOc1ycpghIsDTa2d3ZMzNnj1ep6xpVVeHQsWkaLMMIph+glLX6txiFzp+sC6KVZdnOCVaI7w36sE5eIbAtbABUstbFKodUtNlsUOQ50rpBcHGO4skDlI/uIXl/jETWmrraX2EXEMcxXNdFuF5jneXQv3xC9fQhysf34b7uwYsTxGF4W+G+li3Lgu/74FcUBVarFez+BzgnL+GbBkJJmIgxMbtROo52wThnmwzKpVV+oVSxXC5bUM1yobtBux5HEdIsQyRjC8hKeJiTzjgnkOd5ME0TQRAgk0M3cYA+vsR8eI7JeAzbcba0EFRJkgS2bbdtcYEHCbAWzlgp9+lnWYoozuDb18j058j1HhztKyzbk7O3iRW2YhhGm4GgBHAkK8eOAgYbho65bsGafhOwI0TTZ0jtz1iHKRbCJZOSDqWTBlvvtMZxMpm0GQm2WCzatoqiFC4DeLM+VtpbJKElCRvZi7bdKbsC3jUGkENyyTn9FlRo0DRTErnI8qLdj3/dMv2/yqaTCalgIC+EbeWiRU1Xoc6uhZa0Tcx97u0VNo2A1GKaJvLfNpiaQ5xqbzDQXuCHcSUaFMlIy+R8q8N/CZuV3dx2jDCI8V09RV89Qn/Yw9noHVxHLjJNDv9TOmsa0Wsjbcc+LuYfMVCPMXOGgOjyzmvzv88XnxfKaqSOUGQF6qa+E/MTxSvKgKvU/dwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;State Diagram of Manual Mode&quot;
        title=&quot;State Diagram of Manual Mode&quot;
        src=&quot;/static/b44c052239aa9546f6f8909a84bad2c1/65025/state-diagram-1.png&quot;
        srcset=&quot;/static/b44c052239aa9546f6f8909a84bad2c1/cf440/state-diagram-1.png 148w,
/static/b44c052239aa9546f6f8909a84bad2c1/d2d38/state-diagram-1.png 295w,
/static/b44c052239aa9546f6f8909a84bad2c1/65025/state-diagram-1.png 573w&quot;
        sizes=&quot;(max-width: 573px) 100vw, 573px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;This diagram shows how the data will flow as far as turning the lights on and off through the API and in turn the front-end of the application.
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 349px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/74b9ed8e4afa3201675a5b52e31c9fc4/31569/state-diagram-2.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 148.13753581661894%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAACXBIWXMAAA7DAAAOwwHHb6hkAAADk0lEQVRIx41VWWsTURTuXxbEBxUXEKFKCz6oiA+2ttaatoIgigruVkHQFqs2bZqtWWa7mckkk8yaz3NuvJpMJtGBy5m7ffd8Z52L4xhZI0kSRFGEfr8P3/cRBAF6vd7YGd4flTzm1MLoJg8GZIBms4l8Po+dnR3oug5N0+ReGlD9z6lJevAmAxqGIQcD27aNUqkk1xk0DEN5Vkkec7PUTz/AF03TnDg7QXkWoJIDkl7HRUsIDAaD6YBKg1H1s/4TACVNR8BgGXcmKE/zMsuA5ubXz8ivL0Ps7SKgNbU/VcNMx0Sk4QAwHm8ivHQSuHoGPknjxWNEpHFEofRfTpE2Yw2Inn50iP78aQwWz8OZPwuQ9BYvwDF0aYZ4xGljTknTtVstWE4b9W+7iK+chr9wHuVzJxATWLhwDqJSxiALcNT4PHjRsiy0CFAGN2WKeWsRuHwKuHYRIMrm0g30mGaG88Yoczh0Oh0ICg3++ALTcg0NVm4Z1vV5WA/X0GkJqV30W4GpccgacXpx3o6lFN12en18ofTrJwNEnHqpdJ3wMk88z5PaqZBgGkN7ChQO8qhUKjg6PCBziNmpp+i22224rjueCbxH9Pp+jNpxDX6Q0D5mZ4p6gR3BNlSHwpCp00O2DrP8FHZ5g+RzuG2BmKjz/tQ4ZK3Yu/yp8sTS83qwiptAaxVobwBiBWbpEdXIcCLnpYbDSx6KxeKfIWQBIFBysTDKiLQViMIdVHdvQt+/TfP7EGYNiaQ+JQ7Zfo1GQ9a8YWWOJC1bNNA7vksga3ArKwgaK+jV1uDYptyfSVl5WFFm0CBMYJRfI6jfIXXvkVyCUd1GFFMcRuH0FsAgjuNITf+W+PB3YY3R0vMo7D1BWxQRRvzoP1oAgzAYg47GIR/qdjvQdAvffx7CEg7Nu38q+Mx6qEr8aBNSTmvU62g2mtLObmcYq2pfacf/Y/WQFxiQAfiCepkT2nYFDqp7cLttcKSne80EZUWPezC3SnWAogf54128LKziVWWV5BqO6j/k+szAHlWbbcRFwu8TuNnE6+J9bGs5vK/l8EF7gDfFnKSd7s+ZLUBpGgQ+DM3Epy/vJdizH0tYf3cNz/eXsd3YQF2vDrWMwv9vUvx1vQ5eFdbx0czhk76FD/o63h5tSTunNZxwSrqxB2SjhIpDRTskkE28qz7A28IWapSO7BjFJtMpWWN4MJTUuKwZraasRjyf1pd/AdZj+xPuPdJ2AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;State Diagram of Auto Mode&quot;
        title=&quot;State Diagram of Auto Mode&quot;
        src=&quot;/static/74b9ed8e4afa3201675a5b52e31c9fc4/31569/state-diagram-2.png&quot;
        srcset=&quot;/static/74b9ed8e4afa3201675a5b52e31c9fc4/cf440/state-diagram-2.png 148w,
/static/74b9ed8e4afa3201675a5b52e31c9fc4/d2d38/state-diagram-2.png 295w,
/static/74b9ed8e4afa3201675a5b52e31c9fc4/31569/state-diagram-2.png 349w&quot;
        sizes=&quot;(max-width: 349px) 100vw, 349px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;In this diagram we see the logic of the automatic timer function. This is what the logic should be when the light will act as a normal stoplight would; cycling through its lights on specified intervals.&lt;/li&gt;
&lt;li&gt;The way these two diagrams talk is that whenever the cycle-on signal is triggered, the lights are turned off and the start point of the cycle is triggered. Whenever any other action is taken, it will then transition back to that state. Here is what the diagrams together look like.
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/1b1b51c5308e9f09c39f1ecd392d048d/db2b8/state-diagram-3.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 82.93577981651377%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAA7DAAAOwwHHb6hkAAACXklEQVQ4y31UuY4TQRD1JxOTkJIhIX6AAERAgMhIEAFISIgVq+Xwar2w2F6vPVcfc/Uc5lGvxz2MF0TQM91dVa9eXT3rug5h9X3v/3Vdw1qLsixRVZU/c8+7pmlGvbZtcdt+Nj3QUGsNY4zsK7RiTAAaEpByOuD6LyA3NCQDKjfO4ReA/X7vF3WKovAAPDuRV7K6A9N/MvRAAupZyDJx7FmRsVLKO/MyuWvoQGUeuD84PAIMQAzR1g7Z1zOk9+4g+fgeTqgWApZlmZd3crabNbL7d2HfvEIrkfST0GchFwTM8xy5MEi+XyJ99hj26gdKAdmLZzItJexC5EWWInn+FOr0ROStTxHZeYb8MC/MEVk0TljmFuubBVKVwpohVIZXViWyVO5EN9Eb2NLKfePTRVIeMORnKEiJNDNIt3Ok8wfYrU4QxQpG2JFhHEfY7iLkJkL07RGS9Vtx7iRlzud7DJnsYimC1gpKDK2RkJYfxJB3FlqcUk6WKRlaA7U9g06uoY31974GwnIW+o8H9l9VSS9ahS+rU+hcSVWHvgtGQx/WuNjMsU6uvLx29ajjAUOjOqHeuA7LaIEXnx/ifPUJdTnkKPQq91obvL54gneXL1HklR+C0McjwzBSg6HDz+0CSRqPzqaj2UhlY32D690SXduNA+EZhrZhUoMB/9hLf/WHqTiMGx0PjS/7yvkKU5eArMPR6AXDwLLr2iNW/NPxOL/9n5FlwUKER4+D7zWOFidiAjbVmS7qcRgCkbFtpgZkMA0xgE9fl1AcOg8Pxl+vzW0WVBwfi4ODqaMAftv2N52dIRVZPg+/AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;State Diagram of Both Auto and Manual Modes&quot;
        title=&quot;State Diagram of Both Auto and Manual Modes&quot;
        src=&quot;/static/1b1b51c5308e9f09c39f1ecd392d048d/b9e4f/state-diagram-3.png&quot;
        srcset=&quot;/static/1b1b51c5308e9f09c39f1ecd392d048d/cf440/state-diagram-3.png 148w,
/static/1b1b51c5308e9f09c39f1ecd392d048d/d2d38/state-diagram-3.png 295w,
/static/1b1b51c5308e9f09c39f1ecd392d048d/b9e4f/state-diagram-3.png 590w,
/static/1b1b51c5308e9f09c39f1ecd392d048d/f9b6a/state-diagram-3.png 885w,
/static/1b1b51c5308e9f09c39f1ecd392d048d/db2b8/state-diagram-3.png 1090w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Once you have your server up and running, you are ready to get your GPIO pins wired up and ready to go. This can be done using the following diagrams (remember, the lights in these diagrams have resistors built into them and that is why they are not on the layout diagram but still show up on the logical one. For the sake of the diagram, the fancy 4-pronged light represents a component that has 3 resisted lights on it and a ground pin all on a integrated board.
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/c039fa3dcaa60181b5718acacf6b68ce/b582c/rpi-physical-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 119.78193146417443%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAYAAAD6S912AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEr0lEQVQ4y31UfUyVVRg/t9DIREEJuKPNsjFzy9ZsdGfmxkhnY6suY/mHrRFjSl8yFDKQYClqWIhJBU0nA6fDwFKGBeOCA/nwfr33viAXLx/3XgLUDIESLlzgfe+vc879QIh6t2fnOc85z+/+fs9znkskWQY3ScacJGGpb3ZmbsHevcQdmQYlmk8YELPZOU9Sq70N+Y0ncLKpEBf15WjvasC5ilKU1JWgTFOGqzVXUXOlBpXNlShq/Q7mPhGd/TqM/fUH3BR0HpCxk4Hy+vPIKEvH/vID2HD4Wbxb9AYq6ioQ9X4UonZFofhcMarOVkFdoAZJIXg5fzN2FqhwzfgTJ0R8cmXKeXrGhV6xFyM9Ixi2DmPD8RdA9hFkV2fjlfc2Y92uddhatBVxhXFQ5ipBDhAoMhQgewkOa/I8gHPe2s14JefX5mNb4Taoi9VYmbkSZD8BySQISwhDeHw49xkQs8CDgQjMDgRRE3xTXeBluKiGX1zKQXRuNL9M0iiDdMrgM4KAlAAsT1qO1TtWI/jVYISmhCLmxxioSlQIig3CqdJvFwJ66jiH+isaXL98HaoTKs4i5PUQrIleA3KQcLaRkZFQLlNiU/ImpP6aiqSfkxC2MwwnzxQuljzLAxmXMrA+az2CMoNA0gmCY4IR/Fow9xVpCqzasQpPbVmBtR+vRcL5BKiKVXhsuwKFFaceaYo8L/no5aOIPRaL8JxwT/0oEPmccNncsgie/HIFwo48DeURJSKPPwOSSJBXd+zfkhnT6qpqVF+sxsa8jbyGkdmhIB8SPE6fiIKuT3yyDKFpIYg4pEREZgSez3oOAakERU0LJMv+Lp9pOIv40/F48euX8GZxDL6vzEVichyS9qjxwd53sCf5LexOfhtb9h2C+qMk7E7cjq+KP0XvsHmhZMaOv0XJhRHnAzhnpuB0TWFyehIu+j6nZqcx5ZqGLM3Afv8hfqgdgmXwbzpyM3BOT/HBYDh+hmzjZrPjxn9+bu+Z9Y4TF27cRe89J99Lkhu+5npqSMEmJl0YHZvE2LgTo+OT3PevXn9kdAITD6egt47g9DU7rIPj7G+BAzFjWBxQpj89NPA7dC2tEA1G3BLM0LW2ocssQtDquDFf29IOq2hCVa0JOaVGdFusHiDZq1LikiUOOOBwwCwI6BDNEE0mz2o2cb9TFGE2Cdzv7hRx9jctCn65idvd3fy58RcyJ3FQzpCVxm63Q28wwGg0QqvVwkSTdXo9N+azGDszGgU0Ck1o6riBLouFAy1iKPNi2212GGiyQBP0Oh0HYXtmJsETY4DsvEGnQaOhEZYFgNJCyTabzZ/sW42MMTVfTKCAzG9o0ECjqac1tFDJ0v9Ipkk+yYJAJVNWzJjPYgYKLlDA5qZmtLS0+BnK8vzT8zIEHA47lSnATBvBWHV0iJyRIBi5bzDoIdJGsTtsb7F0cVuSIZNsdwyhrc1AEztgFDrR3k7BTLeg1TGmZu633zTyM71BpL5AAa2eLj9aQx/gg/t/or/bioE+Gwb77bDd7sGQzQF7Tx8c1JjfT2ODtHkDff38/N6du96RXdRlz0bis+Wm+tkFVljZP46+GDuX+R1fzDMl8+s/bPgEVunvsKwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Physical Diagram of Raspberry Pi LED Wiring&quot;
        title=&quot;Physical Diagram of Raspberry Pi LED Wiring&quot;
        src=&quot;/static/c039fa3dcaa60181b5718acacf6b68ce/b9e4f/rpi-physical-diagram.png&quot;
        srcset=&quot;/static/c039fa3dcaa60181b5718acacf6b68ce/cf440/rpi-physical-diagram.png 148w,
/static/c039fa3dcaa60181b5718acacf6b68ce/d2d38/rpi-physical-diagram.png 295w,
/static/c039fa3dcaa60181b5718acacf6b68ce/b9e4f/rpi-physical-diagram.png 590w,
/static/c039fa3dcaa60181b5718acacf6b68ce/b582c/rpi-physical-diagram.png 642w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/05f1643abf2ba5dbde62291ca74aed64/993a7/rpi-circuit-diagram.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 65.73604060913705%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAACHVAAAh1QEEnLSdAAACBUlEQVQ4y11Ti5LaMAzM/39dC3PQTguEchTydGLHzjtbrRI6d+cZjRzHWu1KcjTPCz7bjGVZsACYl/WbNm3GO3KsNo4TxmFEVuQ4Xy9o2w7RvF16BXLf9z18CBiGYQVh9JZgGEcE+WetRWEKpGmG+HZFUZd6J/oExsxy2EhAXpToul4vDcLEuQbGGBRliVKsqmq8/Tqg7TqM06SeWMqQIJQ5ta3aLD8FBS5YXN9j3E4nJEmiIFmeI36/aiJjjSro+0HlKkMCEb2SrMl+j+f3nfp0t8fPP2/4cZb9tx2ssOMqTIl7/lfr10pyVTCNoqpZa8iDUuQ1TYO6roVFpdLyLFfvnFNPZl2/1jS+xUiewripcb/fYSqDc3wWFSmiaZmRmQyT1OG1mJlFJ3s2qBOrigKtALMppV3ZPtIHSjlrgocNbpVceoPf2UnbT4BRAgj+atTlctGSOGEepCw8Y5dZeN95BWEM7zA+om5Kfi0y43jwJ+WSHZcTJkFkU7L3K5D3QZP3w6CqOF1RJ8jP51Nr5wQskX0qHaUlj4f6PE21yxyjafoI6DXB8BGQh5QQ5MBzWA+HzY4ojsf/3762OqecOQ49F+Pmr4CUxRroS+DzEsZfbZSyzAJEeSyBlRiWhZ5NIvMQNsDXuNDzNbhmNesaDaitQyXMjdnGSbrNl0IAesbRCMq6/wOk7OykopVItAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Circuit Diagram of Raspberry Pi LED Wiring&quot;
        title=&quot;Circuit Diagram of Raspberry Pi LED Wiring&quot;
        src=&quot;/static/05f1643abf2ba5dbde62291ca74aed64/b9e4f/rpi-circuit-diagram.png&quot;
        srcset=&quot;/static/05f1643abf2ba5dbde62291ca74aed64/cf440/rpi-circuit-diagram.png 148w,
/static/05f1643abf2ba5dbde62291ca74aed64/d2d38/rpi-circuit-diagram.png 295w,
/static/05f1643abf2ba5dbde62291ca74aed64/b9e4f/rpi-circuit-diagram.png 590w,
/static/05f1643abf2ba5dbde62291ca74aed64/993a7/rpi-circuit-diagram.png 788w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you have your server and your interface to manipulate the lights, you are ready to start your server. You can do this using node. If you file name was server.js you would start it simply by running&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;node server.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;You can connect to the web page you created by going to &lt;code class=&quot;language-text&quot;&gt;http://[IP-ADDR]:[PORT]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You have now completed a simple stop light with some automation! Congratulations!!&lt;/li&gt;
&lt;li&gt;If there are any questions or anything, feel free to go to the github repo up at the top of the page to reference the code or just reference the Appendix which will have more screenshots and code snippets.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Thought Questions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What language did you choose for implementing this project? Why?&lt;/strong&gt;&lt;br/&gt;
I chose to do this project in JavaScript. I know this language very well and develop in it every day. Because of this, I felt that I could utilize this knowledge to focusing on learning about the GPIO pins and not nuances of learning a new language.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the purpose of the resistor in this simple circuit? What would happen if you omitted it?&lt;/strong&gt;&lt;br/&gt;
The resistor takes the load for the circuit so the entire load doesn’t go into the LED’s. The LEDs could probably handle this load but it would shorten the lifespan of the bulb in a big way meaning that it would burn out quicker than if we included the resistors in the circuit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are some practical applications for a device similar to this? What enhancements do you think would make this more valuable?&lt;/strong&gt;&lt;br/&gt;
The obvious would be a stoplight. Although there is much more logic that goes into them, this seemed like a good foundation to go off of. As well, this would be an interesting idea to see if you could have some kind of status or something along those lines where it told that something was happening based on a light being turned on. One I can think of is if at work, the API could hit some DB and see if someone is scheduled to be in or not at that time. If they are scheduled to be in at that time, their light would be lit up so everyone could  know that they should be on the clock and working. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Estimate the time you spent on this lab (from start to finish)?&lt;/strong&gt;&lt;br/&gt;
I spent about 45 minutes setting up my environment and everything. I spent probably 3 hours on the server itself and another hour on the frontend. The wiring of the pi took me under 5 minutes. Overall, I would say that this project took me about 5 hours to complete.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Certification of Work&lt;/h3&gt;
&lt;p&gt;I certify that the solution presented in this lab represents my own work. In the case where I have borrowed code or ideas from another person, I have provided a link to the author’s work in the references, and included a citation in the comments of my code. (I got this statement from the example lab).&lt;/p&gt;
&lt;p&gt;— Matthew Robertson&lt;/p&gt;
&lt;h3&gt;Appendix&lt;/h3&gt;
&lt;h4&gt;Appendix 1: System Interface - Web Page&lt;/h4&gt;
&lt;p&gt;State: Startup, /lights-out
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/f570d/stoplight-off.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 77.5%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABzElEQVQ4y6WTW5OaQBCFeV8FBEE3iwreuKlEZ7hauqwRtSqV/P9/c9IjbqqSrEtVfDh1mJ7uj56btC0rRLzAiuVY8RxhxOHMfAzHLkYT0tgjJ9H4GrvJpthVUx/uPIQbLLH8yiFVlwsOxyMOVYVd+UZ+Jj8gLXKseQaeJNjEMXiaIclzMHKW5IhYfAUkRYEf5Suq0xFxVkByPRdzdwbPF17L9XwEgUffIZKEI01jMM7g+x7lBXD9EM5khqE9wXRGtWGAuRdgOnchyW0FsvyvWq02dL2LvNjidL5gs2F4emrd5mUo5Iqi1mPBaMswDBOSpun4WwLU6WgYDIZYhgusgpA6DmGavTqH5v/Mr73ff4YkCj+Cir+PbAdVkuEnT1AwDoOA9/JF3BQd3ktQb8BXgp3WtPlr1gjs9foNwJGDbZGi3CXgdCiG0QT8ZMmqWgOPb7Tkc4o84+gaj3R4AxZ5iv0uBWcPLlkhoD2yEZdbsPMeG7qLYtMfBDrIvu2Rfi/BqdOHgKragWUNsFxFWEQR3cMFHYrxf8COcIqLOf3FhmG70Mzn37APawTws4v9Hu9aDsyxD71v3e3uPf/Li9UM1HQDWte8PrcmoHh6vwANNaZ7qnb9ywAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Off&quot;
        title=&quot;Stoplight Page Off&quot;
        src=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/b9e4f/stoplight-off.png&quot;
        srcset=&quot;/static/d3e4c54b7531058b67078a58b48e20a4/cf440/stoplight-off.png 148w,
/static/d3e4c54b7531058b67078a58b48e20a4/d2d38/stoplight-off.png 295w,
/static/d3e4c54b7531058b67078a58b48e20a4/b9e4f/stoplight-off.png 590w,
/static/d3e4c54b7531058b67078a58b48e20a4/f9b6a/stoplight-off.png 885w,
/static/d3e4c54b7531058b67078a58b48e20a4/f570d/stoplight-off.png 960w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: RED on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/4909f/stoplight-red.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.03970741901776%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABD0lEQVQ4y62RTW6DMBCFc4AqwTZQIiVAjISNnUTtgr+CCF00qqqepLsepPuetZtXg8SiUtJEkMVoNG+eP82MZ5QyEELR5SGGerGwsFqtUaQZmqpGGIa9durNELP/mpZF4PsBdFFgX9fgUdRrp7xXAyMh8cUTfAcCiVSwzngvApmJuQHuYoEfugHmAUqR4M54GRk5ITFALiU+9o/43D1AKH3We/XK0qzcvJRojiW01kabCBQGeDzkeG1zaHULYCyRHSpkbQV1i5WFuWH21iJ7f4babvu7TgLG5pfTpxxpVSBJ1LQJO912XHh+BG/N4bjeOOBQd5kwG85GwuEK1Hb/9EZNSKkN5i7B7pegBn5pwl9OZErlaIKrmwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Red&quot;
        title=&quot;Stoplight Page Red&quot;
        src=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/b9e4f/stoplight-red.png&quot;
        srcset=&quot;/static/ebaa16bfbc609529750cbc0831e1db5a/cf440/stoplight-red.png 148w,
/static/ebaa16bfbc609529750cbc0831e1db5a/d2d38/stoplight-red.png 295w,
/static/ebaa16bfbc609529750cbc0831e1db5a/b9e4f/stoplight-red.png 590w,
/static/ebaa16bfbc609529750cbc0831e1db5a/f9b6a/stoplight-red.png 885w,
/static/ebaa16bfbc609529750cbc0831e1db5a/4909f/stoplight-red.png 957w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: YELLOW on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/4909f/stoplight-yellow.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.4576802507837%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABH0lEQVQ4y6WTb06DMBiHd4IBbQFnMhYYgQIzgcmfUcIy/WCcHtMDeAJP4AX84A08xM+WuMVMmSb98KTll74P75umE8ZsUCph35DfKrcsgvncQ1lWEK2A7/tD9mvNFxNC6HDoFJUbhgnPW6DebND1PYJgOWRjNYqjUK2nmKaFKIohigIiz8F5Mnr2wFmhIYUJ57hf13goalxlmfyJhtCSwmXIcdc32G9rRHGm2aFhIU043p4FPl46lOsM0ykB1RFyOfLrU4t3Kb3OpdDQEKpLCeXI7U5A3Hb6Iyuh6rDa71A93iBbrYZMSxjHHE3fotkKpKlmhyq3HReXi3DAcS/+L/zBIacMzOewgxSEOUfh2ZcyiiqWQurMQN3ZsCd/dPgJ1rNNyhvfpTQAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Yellow&quot;
        title=&quot;Stoplight Page Yellow&quot;
        src=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/b9e4f/stoplight-yellow.png&quot;
        srcset=&quot;/static/b7f68227c9c8ae787bbae0a97ab3fb3d/cf440/stoplight-yellow.png 148w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/d2d38/stoplight-yellow.png 295w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/b9e4f/stoplight-yellow.png 590w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/f9b6a/stoplight-yellow.png 885w,
/static/b7f68227c9c8ae787bbae0a97ab3fb3d/4909f/stoplight-yellow.png 957w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;State: GREEN on, during cycle or manual
&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/f4b04/stoplight-green.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 66.11053180396247%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABHklEQVQ4y62T0UrDMBSG9wDi0iZpp7CtbmNNqmB1W9rF6d0qiCBeC76DN76E3uj7yr+TwLxQo2K9+Aj8Ofn5zyGnw7lATPAvYCxGvz/AYmFg7RmyYeY1Hqh3dOKYI4riTzi922UYkImpatjVCqODkddCbxzvhu78CGMRprmCLU9hj0+glA7WbvnRUJPJ1dzgmjjUhddaGeaU8NwYXBCaDKO2hq7NZr3EZbNEUfxDQkUJ19UMDVH4llvOMJ/kqJ7vUL3e0zzbJORkuMugyiPUb0+o8QJdlWA7zN/9LWFECcc5zMMNzOMt9FST1qJlpwuZopdk6MkhZJL+/h8GoXUSYw05oS8jku9r3ab4XSZTHpgL5xIi3SP2wYUMJtvu8gaZeUzBPYvSeQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Stoplight Page Green&quot;
        title=&quot;Stoplight Page Green&quot;
        src=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/b9e4f/stoplight-green.png&quot;
        srcset=&quot;/static/b699ce1935b93c6a20e25005a33c8a8e/cf440/stoplight-green.png 148w,
/static/b699ce1935b93c6a20e25005a33c8a8e/d2d38/stoplight-green.png 295w,
/static/b699ce1935b93c6a20e25005a33c8a8e/b9e4f/stoplight-green.png 590w,
/static/b699ce1935b93c6a20e25005a33c8a8e/f9b6a/stoplight-green.png 885w,
/static/b699ce1935b93c6a20e25005a33c8a8e/f4b04/stoplight-green.png 959w&quot;
        sizes=&quot;(max-width: 590px) 100vw, 590px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 2: Server Output&lt;/h4&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 233px;&quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/de59fe45180661b19f529a8448174a27/2d176/server-output.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 158.36909871244634%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAYAAAASYli2AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAD7UlEQVRIx42W2XbiSBBE/QttFrMYGLy0WQxoV2lHgKH7pedhZv7/U2Iik8U2i81DHenAUSgzb1SUbjqdLtrtNu7v79FqtfS+0Wig2Wzqkvv9/7J6vZ5e7+7u9L/jdeP5AVzXwWK5wqIsYaIYeTGHZVmwZjbiLEVZFhgNBsiKEv/+8x9y/lav184LWrYLE0ZwgxCxMbAtG1OuLE2xXv+GY00QmAibX7/x0OuiVq8fHj5XpQomcUrBAFmSIOLDJo6x2awR8CWGL2mxdR0FBVRkfz0jeuP6oQp6fDilkM8RmDjCarlAyPY938fz0yMeHx/58NfVHSqM+aDDBxNefc+D47jwOFfb9eCz8piVWzMLdxfm9knQdjykaYYwTpDzakyMIAwV0Gb9hp+EUS6WaLK6+oU2zwr6oVEQISuybELJEiR5wZY9RBxFyJHUa9XvK9y2nOgME5mhFyChLeZFAZutJ3xJrVK5COFUkBWKoNhGKEslIcm+rZZqF4ezHI9GGA5HF713ZOyPlBNaJdhC8Vwdg1BOOJLxaEwo9e8FZ5aDaEc5jiJSDVWkJJT12wrPLy8KpdVsXAdFZpgmGQLZckJbK3QobmASQjIhvemrya+CIpSzNIfPeeVK2aAo51hxhgIl5W/V21vUarVDdV9WODuiHLAax3VR5Jm+xHbsbVBwXQXFcvyDoFKmqbVligsMERefPj89fdp6FwX9IGJlW9vIXg5IVnZKOZ9jyf08oGUK3nfu26ywfg0Ub0c50L3ssSJpL+AO8Rhrah+CkiqbDZnfNxW6fqQ+FMqy9QyhDOi5xWLBPNzAtacaEqu3NfrdzqHKy8YO4q1tdpQNvRhzBBIOsiZMGfFhrVoh6StalgqlZS/cUw4xnkyQENBm8wvT15ECW65W6B8l9kVBycM9ZUMoM6bNcrnU3WJZU5o7wnAw5AyvCAcTZ4dw+Eh5Pi+Y2ku8MBRKzvO+3bqOsuMZPUfcD5TFh0HgwSIM8aXLFPe4rjL2gTJFM9m7tIokjsxQvDh6negRK+FwTuDkkBLKWboLhyxDRMHJbKYz/PPnb8wmYwIzWBNQh23/4L6uknjlQui+Q9lTZnWT6ZRwAkhw5HnOkRgMuWMmpC+QLNvBjGd361yFMsOtoFHKAY0torY1o7Cl7Yo/+w99neVoNMRo/KpfGO3mGcEwylRQDnqhHFJYQnaxeA/YebmlfKvtVlGt7FsWkc9xxgpD/RRxPKYOwQhliSyh7JtYTz1JcAnZ7bnc/FDR6d5WKEU+59cCqfKkiygivnvjzvD4koIfTu9Cp+F60vLLwwO6vb+4euj3+/rJ0el29drefb41jlL6K2P/D05OqsY8E/HOAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;Server Output&quot;
        title=&quot;Server Output&quot;
        src=&quot;/static/de59fe45180661b19f529a8448174a27/2d176/server-output.png&quot;
        srcset=&quot;/static/de59fe45180661b19f529a8448174a27/cf440/server-output.png 148w,
/static/de59fe45180661b19f529a8448174a27/2d176/server-output.png 233w&quot;
        sizes=&quot;(max-width: 233px) 100vw, 233px&quot;
        loading=&quot;lazy&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 3: Server Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/IT441-Stop-Light&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Appendix 4: Front-end Code&lt;/h4&gt;
&lt;p&gt;Available on &lt;a href=&quot;https://github.com/mattrobertson14/IT441-Stop-Light&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;</content:encoded></item></channel></rss>