I have previously written a small guide to getting started programming the ESP8266 development kit with the NodeMCU firmware. This post assumes that you have a fully working setup. Specifically I use the Seeedstudio NodeMCU v2 - Lua based ESP8266 development kit. I will flash to the latest version of NodeMCU.
Update the firmware
- Connect the ESP8266 via a micro-usb cable to the computer
- Make sure no program is using the serial port to the ESP8266
- Download and unpack esptool, either as a zip file or using git clone:
- OS X (Yosemite) already comes with python 2.7, but we need to install the
pySerialdependency. Open a terminal and type
- Download the latest ESP8266 NodeMCU firmware from here. Get the
nodemcu_integer_*.binfile if you are unsure, for this example the newest version was
- Go to the esptool folder, e.g.
- Flash the firmware using the following command. Replace
/dev/tty.SLAB_USBtoUARTwith the name of the serial port you are using and
~/Downloads/nodemcu_integer_0.9.6-dev_20150704.binwith the path to the firmware you downloaded in step 5.
- If everything is done right you should see the following
- Reconnect to the ESP8266 using ESPlorer or any other similar software and confirm that the ESP8266 is updated to the newest version. Using the RST button will restart the device and print the version at the boot
- If unable to connect to the board after successfully flashing it you might try to remove the
-fm dioparameter in step 7 and re-run it. For this particular version of NodeMCU and board from Seeedstudio I needed to add the parameter as explained here (search for DIO in the comments)
- If using python3 you will run into many error messages about invalid print statements. Apparently the introduced stricter enforcement of how to create print statements in python3 and the esptool source code using an invalid version. Downgrade to python 2.7 seems to be the easy way out unless you want to fix the code (should be easy)
- If you can not reconnect after flashing using baud 9600, but you see the boot loader at baud 74880, then sometimes you need to reflash the old AT firmware. Go to https://github.com/esp8266/esp8266-wiki/tree/master/sdk and download esp_iot_sdk_v0.9.5_15_01_23.zip. Unpack the zip file and follow the instruction in the
bin/at/readme.txtfile. Specifically I refreshed the device using the following 4 commands:
Then retry step 7 to 9 in the guide with the selected NodeMCU firmware.
- If unable to flash with the
Exception: Failed to connecterror message, then try to remove all components connected to the ESP8266. I get this error when trying to flash the module with the RST and D2 pin connected which is needed for deep sleep.