Setup ESP8266

What: Setup a ESP8266 by installing fresh NodeMCU firmware
Why: Update firmware and get cheap Esp’s which come without NodeMCU up and running
How: Use NodeMCU-PyFlasher and Docker to flash Esp, build firmware and put it on the Esp

Install docker

If you have no docker installed already, install it. You can use the script below (execute as root, see here).

apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
add-apt-repository "deb https://apt.dockerproject.org/repo/ debian-$(lsb_release -cs) main"
apt-get update
apt-get -y install docker-engine

Build the firmware

Clone the NodeMCU firmware from github (see here):

git clone https://github.com/nodemcu/nodemcu-firmware.git

Edit the file app/include/user_modules.h. Here you can enable further modules, for example http-module for http requests. For enabling a module, remove the comment markers at the beginning of the line.

Edit the file app/include/user_config.h and enable ssl. As above, this is done by removing the comment markers at the beginning of the line.

Change to the directory and start docker for NodeMCU build (see here):

sudo docker run --rm -ti -v `pwd`:/opt/nodemcu-firmware marcelstoer/nodemcu-build

You should now have two bin-files (for example nodemcu_float_master_20170228-2105.bin) in the bin-folder: One for the integer version and one for the float version.

Flash the firmware to the ESP

Connect the ESP to the USB port of your computer and start the NodeMCU-PyFlasher. Select the correct serial port (you can find it in the device manager, com ports; USB-SERIAL). Select the image file created above. Select the erase flash option and click on Flash NodeMCU.

It should take some time (approx. 1 min). You should see the message „– verify OK (digest matched)“. Now, you have a freshly installed NodeMCU on the Esp. Enjoy!