NodeMCU: upgrading firmware and experimenting LUA

As you might already know, I’ve just placed three Arduino MEGAs around my new house and I’m using them to –among other things– turn on/off the lights of the whole house.

I still have to “enter” the new house so… I’m currently “configuring” the “light-switching” system (associating LIGHTs with related Push-Buttons).

After several”upgrades” of the Arduino sketches, I decided to simplify the “update” process, putting in place an “OTA infrastructure”. Basically, I decided to upload the new versions of the sketches, wirelessly (WiFi),  with some ESP8266.

I already bought three NodeMCU boards. Three of this:

As you can see, they are labeled “LoLin NodeMCU v3” and actually, they are not a simple ESP8266, but instead a real “ESP8266 Development Boards”, as they include an USB connection as well as the necessary power regulator (USB is 5V while ESP8266 requires 3.3V). Also, the board expose the ESP8266 PINs in a so-called breadboard-friendly manner.

My first attempt to get “life” from the USB cable were not much succesful so I decided NOT to trust the provided bootloader/firmware and to start flashing my desired firmware, EspLink.

After a preliminary quick look at the official page I decided to double-check my ESP8266 really had 4MB of flash. To do so, as well as to re-flash my ESP8266, I needed the official esptool:

esptool need to be pointed to the serial device interfacing the ESP. To check how my Linux box recognize the FTDI chip of my development board, I just connected the board and, a couple of second later, just fired a dmesg:

As you can see, the board have been recognized as TTYUSB0. Great.

So, finally, to check the flash data, was as simple as:

So my “Device” is recognized as “4016” and, based on the source, it’s:

exactly the same as the one in the official doc. It has 32Mbit of storage, aka: 4MB.

At this point, everything is ready for flashing. I decided to try the pyflasher tool, as it seems quite stable and used among the community, and also with a nice development speed.

So, finally, I simply needed a firmware to flash. Even tough I already choosed Esplink I decided to test also the latest version of NodeMCU.

I was initially worried by the fact that the official page does not provide a binary firmware ready to be flashed… BUT… I was IMPRESSED by the fact that there’s a sort of “official” build-service by which you can simply “ask” for your firmware and… they will build it for you, as you need, based on your own preference! Simply AMAZING! So I checked the module I plan to test:

and submitted the request. A couple of minutes later…. guess what?

Uau! My custom firmware, built for me, in few minutes! Really impressive! Again!

As you can see, the mail mentioned TWO firmwares, and not one. Why?Because –as stated in the official page— “…Firmware available with or without floating point support (integer-only uses less memory)….“.

As I should have enough flash memory and as I want to be open to perform floating point operations…. I choosed the “float” one. I downloaded it:

and, finally, everything is ready for flashing.

I launched the nodemcu-pyflasher tools, pointed it to the right tty interface and firmware image and clicked the “Flash NodeMCU”. One minute later, I got this:

So, hopefully, I should have a brand-new NodeMCU board.

After launching minicom, pointing it to /dev/ttyUSB0 and configuring the terminal 115200/8/n/1, I got:

 

Good news! The message: “lua: cannot open init.lua” is ok as there is no lua script, currently, to launch at boot (init.lua). So we don’t care. About the “garbage” we see on the first line, I think it’s some sort of messages that the ESP dump on the console, right at boot, at a speed different than the 115200 we are operating. Hence, we don’t care as well.

After the all of this, I finally choosed to turn on the integrated LED. A quick search revealed that the PIN number to use is 4 and hence:

is needed, at first, to declare the PIN as an output one.

Than, a simple:

turned the LED “ON”:

Also, a simple:

turned it “OFF”.

So, in the end, IT WORKED!!!! We have a perfectly running NodeMCU development board based on ESP8266-12E.

Now it’s time to switch to ESP-Link but…. this is a topic for another POST 🙂

HTH and… feel free to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *