I recently received a few NodeMCU boards from Ebay. They came with a custom program loaded (not NodeMCU) and were a bit cryptic to figure out. Instead of messing with a custom program that I couldn’t find much documentation for, I tried flashing NodeMCU onto the board. I tried a few different methods and a few different versions and was unsuccessful. During my troubleshooting I ran across a Micropython implementation. I decided, what the heck, might as well give it a try. A few minutes later I was logged into the WebREPL server (more on this later) running python code on my ESP board. As I’m not fixated on using NodeMCU, I’m going to stick with what works easily — Micropython.
At this point you may be asking, “why the heck do I care about an ESP board with Micropython”, well, you might not. But I happen to care and here is why: with the combination of cheap WiFi enabled hardware and an easy to program platform, creating an IOT device is easier than ever. By adding a few custom functions that handle the typical tasks I want my devices to do, I can create wirelessly controlled devices with little effort.
After some messing around, I’ve found that Micropython is extremely stable and has enough functionality to be nearly identical to Python. Functionality is well implemented for writing to/reading from pins (analog and digital) as well as sending messages over WiFi. A handy feature is the WebREPL server hosted on the ESP which allows access to a Python shell running on the ESP. This is extremely handy, and if you generate a static IP for the ESP, it can be easily controlled anywhere in the world without much effort.
What next? Well, I have two applications in mind currently. First, I plan to make a motion sensor that will trigger my SmartThings lights. The device will be mounted in my room with a LiPo battery and a PIR sensor. Whenever motion goes off, the device, depending on the mode, will turn on the lights in the room. Second, I plan to create a WiFi enabled train controller. I’ve recently been given some American Flyer – O gauge model trains and want to move away from manually controlling the speed of the trains and the various switches to wireless control. I’ve already started both of these projects and should have the first one done soon.