NodeMCU
Node MCU - Beginners Guide
This tutorial features topics on How to get started on NodeMCU firmware for NodeMCU Dev Kit (Version 1.0 /V2) on a Linux PC.
Flashing the firmware
Flashing the firmware helps in making sure that you have the latest one.
- Download the latest version of NodeMCU , a .bin file say 0.9.6-dev_20150704 ,from here
- Download Esptool which is a simple (non GUI )python tool to flash firmware over serial.You may download it from here and extract it.
Alternatively, you may clone the repository using the following command.
git clone https://github.com/themadinventor/esptool
- Change directory
cd esptool
- Install the tool
sudo python setup.py install
Note:You can also install the stable version via pip using
pip install esptool
- Plug in NodeMCU Dev kit and identify its address (CP210x address) using the following command.
dmesg | grep tty
- To ensure that we have the right permissions.
sudo chmod 777 /dev/ttyUSB0
- Flash the firmware
esptool.py --port=/dev/ttyUSB0 --baud 460800 write_flash -fm=dio -fs=32m 0x00000 nodemcu_float_0.9.6-dev_20150704.bin
- Reconnect the device. Identify the device and set permissions as mentioned in steps 4 & 5.
- To communicate with the device you can use minicom, screen or gtkterm. I will be using the later since others are quite buggy. Installing GTKterm
sudo apt-get install gtkterm
- To run the app
sudo gtkterm
Alternatively you may search for Serial Port Terminal in the launcher. - On app navigate to ports in configuration and select device address in drop down menu , which is /dev/ttyUSB0 in my case, set baud rate to 9600 and parity to none.
- After connecting type enter key a few times untill you see Lua interpreter with ">".
Note : For esptool to work you need Python- Serial installed.For installation trysudo apt-get install python-serial
if you have a 512Kb Flash version change "dio" to "qio" and "32m" to "4m". Try reducing the baud to 115200 if error occurs.You can also refer to offical documentation for troubleshooting
If you fail to see the ">" try resetting NodeMCU dev kit using reset button.
Lights Up !
Try the following code in LUA Interpreter
gpio.mode(4, gpio.OUTPUT) gpio.write(4, gpio.LOW)The code will turn on blue LED on ESP 12.
It is worth noting that code will not be saved ie during reboot the chip will be set to its previous state.To know more on setting up init.lua script for permanent storage refer next chapter