{"id":424,"date":"2015-04-24T13:47:14","date_gmt":"2015-04-24T20:47:14","guid":{"rendered":"http:\/\/internetofhomethings.com\/homethings\/?p=424"},"modified":"2015-04-24T13:51:36","modified_gmt":"2015-04-24T20:51:36","slug":"4-reasons-i-abandoned-nodemculua-for-esp8266","status":"publish","type":"post","link":"https:\/\/internetofhomethings.com\/homethings\/?p=424","title":{"rendered":"4 reasons I abandoned NodeMCU\/Lua for ESP8266"},"content":{"rendered":"<p>Like many, I became very excited when first introduced to the ESP8266. Imagine, a complete IoT system on a chip for a couple of USDs! It was very easy to bring a factory-new ESP8266 module up and running from the wealth of information available on-line. The &#8220;OK&#8221; response to the &#8220;AT&#8221; command was the &#8220;Hello World&#8221; for this device, and on you go from there.<\/p>\n<p>With more education, it became obvious that a lot of folks were using NodeMCU to develop Lua scripts for the device. It looked simple enough. And the demo applications to control an LED from a web browser were easy to duplicate. Wow, this really works!<\/p>\n<p>But then I started to develop a larger server, which responded to multiple requests.<\/p>\n<p>And that&#8217;s when the problems started&#8230;<\/p>\n<p>Initially, I blamed the problems I encountered on my coding. And a lack of experience working with the module. But it seemed that every time a problem was resolve, another few reared their ugly head. In the end, I have concluded that the\u00a0NodeMCU\/Lua development environment (at least at this time) is\u00a0not suitable for ESP8266 application development.<\/p>\n<p>Here is why&#8230;<\/p>\n<p><strong>#1. Insufficient memory provided for your application<\/strong><\/p>\n<p>This environment does not compile your application, but rather interprets it while running. And every byte counts, including code comments. They all reduce the available free heap. Anyone that has worked with the NodeMCU\/Lua development has encountered the &#8220;not enough memory&#8221; wall. It does not take much code and you start scrounging for bytes just to get the script to run.<\/p>\n<p>I tried to work around this by creating smaller scripts with limited functionality and switching between them with module resets to start a different lua script. Before resetting, the code would simply write the name\u00a0of the next script to start in a file, which the lua start-up script would read and call upon reset. Each time the device reset, the free heap was freed\u00a0to it&#8217;s maximum size. The code was restarted based on the request received from a web client. Besides being a clumsy way to code, it was also unreliable as the resets did not always start up correctly.<\/p>\n<p><strong>#2.\u00a0Web Server stops replying to client<\/strong><\/p>\n<p>During repeat-ability\u00a0testing, I noticed that at some point, usually within a few web browser requests, the ESP8266 simply stopped replying to &#8220;http GET&#8221; requests. I expected the application to respond to the same request in the same manner every time, but this proved not to be the case. Perhaps this might be related to the well known issue with the memory usage lingering, reducing the free heap until the system stops functioning.<\/p>\n<p><strong>#3.\u00a0Crashes<\/strong><\/p>\n<p>Many times, I would start the application with a restart. The first time an &#8220;http GET&#8221; request was sent, the system would crash. Reset\u00a0it again and it would work. Without changing anything! Ugh&#8230;not very repeatable. One can only endure this so long&#8230;<\/p>\n<p><strong>#4.\u00a0Better options<\/strong><\/p>\n<p>After circling the wagons with NodeMCU\/Lua for over a week, insanity set in. I really was expecting different results. But nooo &#8211; the problems persisted.<\/p>\n<p>So I investigated other options.<\/p>\n<p><em>The Espressif SDK<\/em> offers native ESP8266 support. Your code is developed in C language and compiled. \u00a0There is plenty of space available for your application. It seemed to be a far more robust development option than using NodeMCU. With the SDK, you have direct control of the callback function registration and content. And the make file output provides a clear picture of the memory usage and partitioning. But, unfortunately, I discovered some <a title=\"issues with the ESP8266 SDK\" href=\"http:\/\/internetofhomethings.com\/\" target=\"_blank\">issues with the ESP8266 SDK<\/a> (Version 1.0) that forced me to abandon it as well, at least for now. I really did like this IDE and anxiously await the problem resolving updates.<\/p>\n<p>I am currently using the Arduino IDE for ESP8266 application development. While not as robust as the SDK, this is the only development environment that I have found (at this time) to work. But here, too, this environment is still under development. The <a title=\"Arduino IDE for ESP8266 \" href=\"http:\/\/internetofhomethings.com\/\" target=\"_blank\">Arduino IDE for ESP8266 <\/a>has unique issues of it&#8217;s own.<\/p>\n<h1><\/h1>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like many, I became very excited when first introduced to the ESP8266. Imagine, a complete IoT system on a chip for a couple of USDs! It was very easy to &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],"tags":[],"class_list":["post-424","post","type-post","status-publish","format-standard","hentry","category-alltheposts","category-esp8266"],"_links":{"self":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/424","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=424"}],"version-history":[{"count":2,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/424\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=\/wp\/v2\/posts\/424\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/internetofhomethings.com\/homethings\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}