{"id":1889,"date":"2017-01-03T20:42:13","date_gmt":"2017-01-03T20:42:13","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=1889"},"modified":"2017-01-08T20:16:24","modified_gmt":"2017-01-08T20:16:24","slug":"evolution-of-led-lighting-hardware-and-tools","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2017\/01\/03\/evolution-of-led-lighting-hardware-and-tools\/","title":{"rendered":"Evolution of LED Lighting &#8211; hardware and tools"},"content":{"rendered":"<h2>Flashback<\/h2>\n<p>I wanted to buy home automation electronics, nothing really fancy just a WiFi controller for a led strip. \u00a0When shopping for things like this <em>Pay attention<\/em>. \u00a0I\u00a0saw something that spoke about WiFi and was really quite cheap so I just bought it.<\/p>\n<p>Unfortunately a number\u00a0of personal issues came up and that particular project ended up on the windowsill for weeks. \u00a0When I actually did get around to look at it, I would say that this particular manufacturer meant that wireless really meant radio frequency with a remote control.<\/p>\n<p>Eventually I did make the determination that this device although pretty wasn&#8217;t going to work as I wanted. I only\u00a0wanted to be able to control the lights in the children&#8217;s room from my computer, perhaps dim them once everyone is asleep and turn them off before I go to bed.<\/p>\n<p>One of my friends loves technical bits and bobs and suggested that I simply purchase another devices that would do what I wanted. This was actually good advice but didn&#8217;t want to end up with another white elephant.<\/p>\n<p>A number of the devices were deceptively cheap but I couldn&#8217;t really guarantee they would do the job. \u00a0I did see a few devices but they were essentially a two part device, a hub to control the devices and the actual device connected to the led strip.<\/p>\n<h2>Now<\/h2>\n<p>Rather than follow my friends sage advice I took a route less traveled. \u00a0The new plan was build a small control board that I could add to my\u00a0existing &#8220;light fixture&#8221; so it would be possible to turn on and off the led strips via WiFi.<\/p>\n<p>The parts I\u00a0purchased\u00a0to create my control board is as follows.<\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Item<\/th>\n<th>Name<\/th>\n<\/tr>\n<tr>\n<td>WiFi capable<br \/>\nmicrocontroller<\/td>\n<td><a href=\"https:\/\/www.amazon.de\/gp\/product\/B018E741G4\/ref=oh_aui_detailpage_o01_s01?ie=UTF8&amp;psc=1\">Elegiant Nodemcu Lua ESP8266\u00a0ESP 12E WiFi Development Board<\/a><\/td>\n<\/tr>\n<tr>\n<td>Controllable relay<br \/>\n(ie switch)<\/td>\n<td><a href=\"https:\/\/www.amazon.de\/gp\/product\/B00AE1P8KM\/ref=oh_aui_detailpage_o02_s00?ie=UTF8&amp;psc=1\">2 Kanal 5V Relay Relais Module for Arduino\u00a0<\/a><\/td>\n<\/tr>\n<tr>\n<td>Small bread board<\/td>\n<td>\n<p id=\"title\" class=\"a-size-large a-spacing-none\"><a href=\"https:\/\/www.amazon.de\/gp\/product\/B00LO32MBM\/ref=oh_aui_detailpage_o04_s00?ie=UTF8&amp;psc=1\"><span id=\"productTitle\" class=\"a-size-large\">TOOGOO(R) 5x Breadboard Steckboard<\/span><\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>Tiny bread board<\/td>\n<td>\n<p id=\"title\" class=\"a-size-large a-spacing-none\"><a href=\"https:\/\/www.amazon.de\/gp\/product\/B00J2SUY7U\/ref=oh_aui_detailpage_o05_s00?ie=UTF8&amp;psc=1\"><span id=\"productTitle\" class=\"a-size-large\">Experimentierboard 2&#215;1,5cm<\/span><\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>Temperature sensor<\/td>\n<td>\n<p class=\"parseasinTitle\"><a href=\"https:\/\/www.amazon.de\/gp\/product\/B00STWHUMW\/ref=oh_aui_detailpage_o06_s00?ie=UTF8&amp;psc=1\"><span id=\"btAsinTitle\">TMP 36 Temperatursensor<\/span><\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>Development environment<\/td>\n<td><a href=\"https:\/\/www.arduino.cc\/en\/main\/software\">The open-source Arduino Software (IDE)<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The WiFi device that I choose was not exactly an Arduino, but it was indeed a microprocessor that also had a 8266 WiFi board attached. \u00a0This board can also be programmed using the Arduino IDE. \u00a0Well, not without doing a small bit of configuration\u00a0first.<\/p>\n<h2>Preparing the Arduino IDE<\/h2>\n<h3>Unpacking the software<\/h3>\n<p>This actually depends on the platform that you are using and how you like to do things. \u00a0I will leave this as a an exercise to the user. \u00a0I happened to choose windows for this particular task as it was convenient.<\/p>\n<p>I simply unpacked the IDE and added that directory to my path.<\/p>\n<h3>Configure the software<\/h3>\n<p>Once the software is unpacked or installed it is just a matter of running the IDE. All of the configuration will be done there.<\/p>\n<p>In a nutshell this involves adding a new setup file into the preferences window and then using the Board Manager to install the new configuration. \u00a0This was briefly described at the following site<\/p>\n<p><a href=\"https:\/\/github.com\/esp8266\/arduino#installing-with-boards-manager\">https:\/\/github.com\/esp8266\/arduino#installing-with-boards-manager<\/a><\/p>\n<p>The first step is to add the configuration file in our preferences (file -&gt; preferences).<\/p>\n<p><a href=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-preferences.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-1621 size-full\" src=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-preferences.png\" alt=\"arduino-preferences\" width=\"776\" height=\"682\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-preferences.png 776w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-preferences-300x264.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-preferences-768x675.png 768w\" sizes=\"(max-width: 776px) 100vw, 776px\" \/><\/a><\/p>\n<p>The Arduino IDE is a really nice bit of work. \u00a0You simply provide a JSON configuration file which really describes where\u00a0a zip file with all of the code is and which\u00a0additional board entries it supports.<\/p>\n<p>Simply type this same JSON link into your web browser to see this setup. This is an excellent example of how to have a relatively generic IDE and yet have it fully configurable for supporting multiple setups.<\/p>\n<p><em>http:\/\/arduino.esp8266.com\/stable\/package_esp8266com_index.json<\/em><\/p>\n<p>The second step, once the JSON configuration is added to the preferences, is to go into the board manager and to select the configuration you want to install (\u00a0board &#8220;tools -&gt; arduino\/genuino uno -&gt; boards manager &#8230;&#8221; )<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-1622 size-full\" src=\"http:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-boards-manager-install.png\" alt=\"arduino-boards-manager-install\" width=\"800\" height=\"450\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-boards-manager-install.png 800w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-boards-manager-install-300x169.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2016\/10\/arduino-boards-manager-install-768x432.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>The install doesn&#8217;t actually do anything to the device itself but rather uses the JSON file to download the new configuration and libraries\u00a0into the IDE.<\/p>\n<p>For most people it isn&#8217;t so important where exactly the code is installed but for the curious it is not installed into the same directory as the rest of the IDE installation. \u00a0The new configuration is installed underneath the AppData directory for my user.<\/p>\n<blockquote><p>c:\\Users\\ralf\\AppData\\Local\\Arduino15\\packages<\/p><\/blockquote>\n<p>I would expect there is a similar mechanism on Linux, probably a directory in the users home directory.<\/p>\n<h2>Baby Steps<\/h2>\n<p>Being unfamiliar with the ESP8266, well the Arduino as well, I thought that\u00a0I should learn to walk before I run so I did the hello world of the Arduino world. \u00a0This is typically some code to blink a led. \u00a0The good news was that my device actually had two leds on the board, it was just a matter of finding out how to access them.<\/p>\n<p>I did have some initial difficulties, this was because I didn&#8217;t have any previous experience with the Arduino, the Arduino IDE, or the ESP8266. \u00a0If you look long enough on the internet you will find the answers to almost anything. \u00a0I did manage to find a number of different sites with information but perhaps the best starting place is on github. \u00a0They have a picture of the device, the descriptions of the pins as well as the circuit diagram.<\/p>\n<p>The ESP8266 is open sourced so it is actually possible to create your own if you have the interest.<\/p>\n<p><a href=\"https:\/\/github.com\/nodemcu\/nodemcu-devkit\">https:\/\/github.com\/nodemcu\/nodemcu-devkit<\/a><\/p>\n<p>Although the Arduino community has a\u00a0really good eco-system, I still had a few problems. I will not elaborate on most of my problems but one of them was my device was not explicitly listed in the list of board devices.<\/p>\n<p>It turns out that isn&#8217;t really a big problem. \u00a0I ended up using the &#8220;Adafruit huzza&#8221; which proved to be compatible with my device although it is possible that some of the other devices in the boards manager would have also worked.<\/p>\n<p>Once all of the rest of the configuration has been done, simply create a new project, enter the code and compile.<\/p>\n<h3>Blink code<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#define ESP8266_LED1 16\r\n#define ESP8266_LED2 2\r\n\r\nvoid setup()\r\n{\r\n  Serial.begin(74880);\r\n  Serial.println(&quot;begin&quot;);\r\n  pinMode(ESP8266_LED1, OUTPUT);\r\n  pinMode(ESP8266_LED2, OUTPUT);\r\n}\r\n\r\nvoid loop() \r\n{\r\n  Serial.println(&quot;in loop&quot;);\r\n  digitalWrite(ESP8266_LED1, HIGH);\r\n  digitalWrite(ESP8266_LED2, LOW);\r\n  delay(500);\r\n  digitalWrite(ESP8266_LED1, LOW);\r\n  digitalWrite(ESP8266_LED2, HIGH);\r\n  delay(500);\r\n}\r\n<\/pre>\n<p>Uploading the code to the device is just as simple as pressing a button, but it is likely\u00a0that you first need to go in and set the port the Arduino should use. \u00a0In my case the port had to be explicitly set. \u00a0The first time that I attached the device to the laptop with a USB cord a new communication port was created, in my case com6.<\/p>\n<p>The upload process doesn&#8217;t take overly long and when it finishes, it will immediately start flashing the on-board leds.<\/p>\n<p>The code should be fairly obvious to an\u00a0Arduino developer, however, I will clarify a few points for the uninitiated.<\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>code<\/th>\n<th>description<\/th>\n<\/tr>\n<tr>\n<td>Serial.begin<\/td>\n<td>This configures the device to connect to the com port in order for the developer to see any output in the terminal window. The number given is the baud speed that will be used to communicate.<\/p>\n<p>Note: This speed must match the speed set in your terminal window.<\/td>\n<\/tr>\n<tr>\n<td>Serial.println<\/td>\n<td>This will print a message to the serial port.<\/p>\n<p>Note: There is a Serial.print as well that works identically but does not do a carriage return line feed.<\/td>\n<\/tr>\n<tr>\n<td>pinMode<\/td>\n<td>This sets the processor pin to either input or output. \u00a0In my examples it will be as output but it is possible to use the pin as part of a switch setup to get input from the user.<\/p>\n<p>Note: OUTPUT is defined for you in the standard include files.<\/td>\n<\/tr>\n<tr>\n<td>digitalWrite<\/td>\n<td>This changes the output value of the pin to either off or on.<\/p>\n<p>Note: HIGH and LOW\u00a0are defined for you in the standard include files.<\/td>\n<\/tr>\n<tr>\n<td>delay<\/td>\n<td>This is a sleep method that will cause the device to sleep for the given number of milliseconds.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>One thing that might not be intuitively obvious to the casual observer is why the baud speed of 74880 was chosen instead of the faster 115200. \u00a0This stems from my earlier difficulties using these tools.<\/p>\n<p>The ESP8266 E12 board actually sets the port speed to 74880 upon restart. \u00a0If the terminal is set to 115200 instead, you will see some gibberish on the top of your terminal windows before the setup method of the program is called. \u00a0If you use the same speed as the default of the board then\u00a0you see the startup message from the device along with any of your custom messages.<\/p>\n<p>This entire article thus far is not very different from the run of the mill Arduino blink project. \u00a0Unfortunately the setup description took longer than I anticipated and thus the connection to the network via WiFi and controlling the device will be described in the final part,\u00a0 <a href=\"http:\/\/blog.paranoidprofessor.com\/index.php\/2017\/01\/08\/evolution-of-led-lighting-software-solution\/\">Evolution LED Lighting &#8211; software solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flashback I wanted to buy home automation electronics, nothing really fancy just a WiFi controller for a led strip. \u00a0When shopping for things like this Pay attention. \u00a0I\u00a0saw something that spoke about WiFi and was really quite cheap so I &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2017\/01\/03\/evolution-of-led-lighting-hardware-and-tools\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,3],"tags":[84,80,12],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1889"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1889"}],"version-history":[{"count":18,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1889\/revisions"}],"predecessor-version":[{"id":2523,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/1889\/revisions\/2523"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}