{"id":4907,"date":"2016-08-21T05:43:08","date_gmt":"2016-08-21T10:43:08","guid":{"rendered":"http:\/\/www.plastibots.com\/?p=4907"},"modified":"2016-08-21T05:43:08","modified_gmt":"2016-08-21T10:43:08","slug":"esp8266-lessons-learned","status":"publish","type":"post","link":"https:\/\/www.plastibots.com\/index.php\/2016\/08\/21\/esp8266-lessons-learned\/","title":{"rendered":"ESP8266 &#8211; Lessons Learned"},"content":{"rendered":"<p>I&#8217;ve gotten enough ESP8266 projects under my belt to have a few lessons learned to share with you. \u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-4908 size-medium\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2016\/08\/qt-300x225.jpg\" alt=\"qt\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2016\/08\/qt-300x225.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2016\/08\/qt.jpg 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>The ESP comes in many flavors. \u00a0One of my favorites is the <a href=\"http:\/\/www.banggood.com\/search\/nodemcu.html?p=R90804949020201412E4\" target=\"_blank\">NodeMCU<\/a>. \u00a0I also like the <a href=\"https:\/\/www.adafruit.com\/products\/2471\">Adafruit Huzzah<\/a><\/p>\n<p><strong>WDT Reset Error:<\/strong><\/p>\n<p>This error was the bane of my existence for quite some time. \u00a0 When experiencing this, you typically see your sketch run and fail. \u00a0Using the Serial Monitor and carefully placed <em>Serial.println<\/em> statements, you can usually find the offending loop. \u00a0The failure is the Watchdog timer. \u00a0In lay terms, the ESP needs time to perform wifi duties, and often code you write may take up too much CPU time and not allow the ESP to perform these duties.<\/p>\n<p>Although there are likely other causes, I find this issue is almost always fixed by finding the offending loop (for, or other while loops) and ensuring I throw a <strong>yield();<\/strong> statement in there. \u00a0The general concept is to ensure that no loop runs without calling yield(); every-so-often.<\/p>\n<p><strong>Power:<\/strong><\/p>\n<p>One thing I have learned is to not even try to run the ESP off USB alone. \u00a0USB at best will give you 500mA of current. \u00a0Most ESP&#8217;s require 300-500mA but it&#8217;s the spikes that will cause issues\/crashes. \u00a0It may connect, and may even\u00a0work, but it will likely cause issues as you add features and functions to your device through code iterations. \u00a0The ESP won&#8217;t tell you it doesn&#8217;t have enough power. \u00a0Instead you will receive all sorts of different errors that are typically unrelated and make you think something else is wrong. \u00a0 The trend I have seen is I typically have project working on USB and start adding features. \u00a0Then, for no reason, I start getting WDT reset errors, but did nothing more than change the way an LED or other sensor works. \u00a0The issue is, the sensor\/LED would have already been working (all powered by USB), but it must be at the threshold of the USB output current limits. \u00a0The first thing I do with any of my ESP projects is hook up a\u00a05 (or 3v3) 3A <a href=\"http:\/\/www.banggood.com\/5Pcs-Mini-DC-Adjustable-Power-Supply-Buck-Module-Step-Down-Module-p-952402.html?p=R90804949020201412E4\">switching power supply<\/a> up to it.<\/p>\n<p><strong>Silent Crashes:<\/strong><\/p>\n<p>I haven&#8217;t quite figured this one out yet, but a common trend I see with my projects is random freezes. \u00a0Seemingly for no apparent reason. To date, I cannot find any common reason for it. \u00a0 What I typically do is force the device to restart itself every few hours or so. \u00a0That tends to clean things up and allow it to keep ticking along. \u00a0 \u00a0I have done this with my outdoor transmitter part of my <a href=\"http:\/\/www.plastibots.com\/index.php\/2016\/06\/18\/wiot-weather-station-iot-notifier\/\" target=\"_blank\">Weather Project<\/a>. \u00a0The device has been running for 4 months now on solar power without a crash.<\/p>\n<p><strong>Blynk:<\/strong><\/p>\n<p>If you are not sure what this is, then no need to read on. \u00a0Otherwise, you have likely discovered <a href=\"http:\/\/www.blynk.cc\/\" target=\"_blank\">Blynk<\/a>. \u00a0I love this product! \u00a0However, one thing I have found is that it can be a bit temperamental with complex projects. \u00a0My <a href=\"http:\/\/www.plastibots.com\/index.php\/2016\/06\/18\/wiot-weather-station-iot-notifier\/\" target=\"_blank\">Weather IoT<\/a> project is the most complex I have done so far. \u00a0It uses Blynk to pass data from an\u00a0outdoor (temp\/humidity) transmitter as well as my <a href=\"http:\/\/www.plastibots.com\/index.php\/2015\/06\/11\/iot-garage-monitor-with-finger-print-sensor\/\" target=\"_blank\">garage door monitor<\/a>, and hot tub temperature monitor\u00a0to the master unit &#8211; and they talk back-and-forth. \u00a0What I find however is that the process Blynk uses for updating data (BLYNK_WRITE) on the receiving device fails &#8211; but for only some features. \u00a0It also crashes in such a way that you get no messaging. \u00a0However, removing the BLYNK_WRITE corrects it. \u00a0To date, I am still dealing with this. Oddly it works fine for data being received from my weather transmitter unit, but using the same approach (getting temp from my hot tub) fails. \u00a0I&#8217;ll update this once I find the solution.<\/p>\n<p><strong>Notes:<\/strong><\/p>\n<p>As I continue to use ESP devices, I will update this post with new information with hopes that it helps others, as well as myself (given I will forget!).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve gotten enough ESP8266 projects under my belt to have a few lessons learned to share with you. \u00a0The ESP comes in many flavors. \u00a0One of my favorites is the NodeMCU. \u00a0I also like the Adafruit Huzzah WDT Reset Error: This error was the bane of my existence for quite some time. \u00a0 When experiencing this, you typically see your sketch run and fail. \u00a0Using the Serial Monitor and carefully placed Serial.println statements, you can &hellip; <a href=\"https:\/\/www.plastibots.com\/index.php\/2016\/08\/21\/esp8266-lessons-learned\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":4908,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[65,57,168,119],"tags":[],"class_list":["post-4907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino-electronics","category-electronics","category-esp8266","category-iot","has_thumb"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2016\/08\/qt.jpg","jetpack_shortlink":"https:\/\/wp.me\/pK41j-1h9","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/4907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/comments?post=4907"}],"version-history":[{"count":0,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/4907\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media\/4908"}],"wp:attachment":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media?parent=4907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/categories?post=4907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/tags?post=4907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}