{"id":1698,"date":"2016-09-23T14:29:00","date_gmt":"2016-09-23T21:29:00","guid":{"rendered":"http:\/\/internetofhomethings.com\/homethings\/?p=1698"},"modified":"2016-10-17T11:12:40","modified_gmt":"2016-10-17T18:12:40","slug":"continuous-esp8266-operation","status":"publish","type":"post","link":"https:\/\/internetofhomethings.com\/homethings\/?p=1698","title":{"rendered":"Continuous ESP8266 Operation"},"content":{"rendered":"<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/esp8266.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1703\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/esp8266.png\" alt=\"esp8266\" width=\"130\" height=\"130\" \/><\/a><\/p>\n<p>Many ESP8266 enthusiasts still struggle with unwanted resets and non-recoverable system crashes. That comes from my recent review of the most often expressed issues noted on-line. After investing significant time with this module, many have simply given up and moved on with other options.<\/p>\n<p>That is too bad&#8230;<\/p>\n<p>And while I have written several articles on the subject, I have to admit that my long-term ESP8266 reliability test also failed months ago. But the test had not been revisited. That is. not until now. The problem was that the original tests were using an older, less reliable sketch structure.<\/p>\n<p>Now, with some much-needed improvements, my basic setup now provides a reliable and stable platform for IoT projects. That is the point of this writing. The following information should prove useful for anyone wanting to use the ESP8266 on a 24\/7 basis with minimal or no down-time&#8230;<\/p>\n<p>Here&#8217;s a reference to my past writings on this topic:<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/?p=396\" target=\"_blank\">4\u00a0ways to eliminate ESP8266 Resets<\/a><\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/?p=605\" target=\"_blank\">A cleaner ESP8266-12 hardware setup<\/a><\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/?p=631\" target=\"_blank\">ESP8266 WIFI dropout-proof connectivity<\/a><\/p>\n<h2 style=\"text-align: center;\"><strong>Past Monitoring the Esp8266 Performance<\/strong><\/h2>\n<p>My original reliability test used a\u00a0ThingSpeak channel\u00a0to monitor the ESP8266 performance. This same channel will now be reused to evaluate \u00a0the updated sketch structure. The longest run-time recorded during the original test was 28 days. Then, the ESP8266 crashed fatally and could not recover. Yet every 24 hour period\u00a0\u00a0in the 28 day span recorded at least 10 ESP8266 resets. Fortunately, the sketch was structured to recover from a reset. That is, until the fatal crash occurred during day 28.<\/p>\n<h2 style=\"text-align: center;\"><strong>This Time Should Be Better<\/strong><\/h2>\n<p>The original sketch used polling to check for http server requests. This was executed each loop() cycle. I used this structure based on project examples found on-line. But the design is flawed. A much more reliable approach is to setup a separate event-driven callback function outside the sketch loop() function to respond to http requests. <a href=\"http:\/\/internetofhomethings.com\/homethings\/?p=1190\" target=\"_blank\">This post<\/a>\u00a0presents more detailed description of this http server sketch structure using the ESP8266. Operating in a separate thread, the responsiveness of the callback is not dependent upon the\u00a0time required to execute the sequential steps in the loop() function.<\/p>\n<p>I also discovered that my USB to serial device was causing frequent ESP8266 resets. It also was failing frequently during sketch uploads.<\/p>\n<p>This was replaced, and then removed once the final sketch was installed. The operating unit now only uses the 5V and Gnd wires from a USB cable. \u00a0The 5V is fed through a voltage<\/p>\n<p>regulator to provide the 3.3v for ESP operation.<\/p>\n<h2 style=\"text-align: center;\"><strong>Monitoring the ESP8266<\/strong><\/h2>\n<p>In this case, the ESP8266 functions as an http server. In addition, it periodically reads any attached sensors. These sensor values are returned as an http reply to a request. The current ESP8266 system time (seconds since the last reset) and the number of WIFI disconnect\/reconnections are also returned; all within a <a href=\"http:\/\/www.json.org\/\" target=\"_blank\">JSON<\/a> string.<\/p>\n<p>So the ESP8266 simply waits for requests and monitors sensors.<\/p>\n<p>I have set up a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cron\" target=\"_blank\">CRON<\/a>\u00a0script, written in php, to request and record the current values from the ESP8266. The script also records the values both to the ThingSpeak channel and a separate mySQL database. This is repeated once every hour, on the hour. A description of this process and the ThingSpeak channel is detailed in <a href=\"http:\/\/internetofhomethings.com\/homethings\/?p=555\" target=\"_blank\">this post<\/a>.<\/p>\n<h2 style=\"text-align: center;\"><strong>The Results<\/strong><\/h2>\n<p>So far, the ESP8266 has been running continuously for almost 8 days without a single WIFI\u00a0drop-out or ESP8266 reset. There is no reason to doubt that this system will run indefinitely. That is, until the power company delivers a disruption in service or my internet connection goes down.<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/uptime.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1705\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/uptime.jpg\" alt=\"uptime\" width=\"476\" height=\"326\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/uptime.jpg 476w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/uptime-300x205.jpg 300w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/a><\/p>\n<h2 style=\"text-align: center;\"><strong>In Closing<\/strong><\/h2>\n<p>I hope this experiment offers encouragement to anyone using the ESP8266 that has been frustrated with unreliable performance. Check back periodically to see how long this module performs with crashing with a reset. Here is a <a href=\"https:\/\/thingspeak.com\/channels\/33251\" target=\"_blank\">quick link<\/a> to the ThingSpeak channel monitoring the unit.<\/p>\n<p>2016-Sep-23 Update:<\/p>\n<p>The Santa Ana winds kicked up this afternoon and with rising temperatures, \u00a0ACs were cranking everywhere here in Southern California. \u00a0This triggered a one-minute power outage which also shut down the ESP8266 after a bit over 8 hours of continuous operation. \u00a0A UPS on the ESP8266 per source is needed to prevent this from happening again.<\/p>\n<p>2016-Oct-17\u00a0 Update:<\/p>\n<p>Five days ago I discovered that the ESP8266 data feed into the ThingSpeak channel was no longer updating values. After some troubleshooting, the root cause was isolated to my 24 port Cisco Ethernet Switch. The problem was not with the switch, but rather one of my devices connected to it. I removed all the connections and re-introduced the essential devices, one-by-one with the system restored to full operational capability. One of the devices was a WIFI access point. This device is used in my home network to extend the range of my WIFI coverage. And that device is what the ESP8266 connects to for network access. Unfortunately, while troubleshooting, a disturbance to the ESP8266 power source occured, reseting the device after 17 days of continuous operation. I used this opportunity to install my new UPS unit to power the ESP and the network modem\/router during power outages. This will hopefully eliminate this disruption source to my on-going ESP8266 up-time stress test.<\/p>\n<p><a href=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/oct17_update.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1712 size-full\" src=\"http:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/oct17_update.jpg\" alt=\"oct17_update\" width=\"718\" height=\"486\" srcset=\"https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/oct17_update.jpg 718w, https:\/\/internetofhomethings.com\/homethings\/wp-content\/uploads\/2016\/09\/oct17_update-300x203.jpg 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many ESP8266 enthusiasts still struggle with unwanted resets and non-recoverable system crashes. That comes from my recent review of the most often expressed issues noted on-line. After investing significant time &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,10,132],"tags":[145,143,144,142],"class_list":["post-1698","post","type-post","status-publish","format-standard","hentry","category-alltheposts","category-esp8266","category-web-server","tag-esp8266-buggy","tag-esp8266-crashes","tag-esp8266-stability","tag-esp8266-unreliable"],"_links":{"self":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1698"}],"version-history":[{"count":8,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1698\/revisions"}],"predecessor-version":[{"id":1713,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/1698\/revisions\/1713"}],"wp:attachment":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}