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.

NodeMCU

Flashing the firmware

Flashing the firmware helps in making sure that you have the latest one.

  1. Download the latest version of NodeMCU , a .bin file say 0.9.6-dev_20150704 ,from here
  2. 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
    
  3. Note : For esptool to work you need Python- Serial installed.For installation try
    sudo apt-get install python-serial
  4. Change directory
    cd esptool
  5. Install the tool
    sudo python setup.py install
    Note:You can also install the stable version via pip using
    pip install esptool
  6. Plug in NodeMCU Dev kit and identify its address (CP210x address) using the following command.
     dmesg | grep tty 
  7. To ensure that we have the right permissions.
     sudo chmod 777 /dev/ttyUSB0 
  8. 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
  9. 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
  10. Reconnect the device. Identify the device and set permissions as mentioned in steps 4 & 5.
  11. 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 
  12. To run the app
    sudo gtkterm 
    Alternatively you may search for Serial Port Terminal in the launcher.
  13. 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.
  14. After connecting type enter key a few times untill you see Lua interpreter with ">".
  15. 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

>