First steps with Micropython on a NodeMCU
My NodeMCU arrived so I went right ahead and installed Micropython on it.
Install the Micropython firmware
To copy the firmware onto the board, you can use esptool. It can be installed with pip, so I created a virtualenv for installing it. Esptool requires Python 2.
$ mkvirtualenv -p $(which python2.7) esptool
Install esptool in the virtualenv:
$ pip install esptool
Plugging in the nodemcu gives me
Erase any existing firmware:
$ esptool.py --port /dev/ttyUSB0 erase_flash
Downloaded the pre-built micropython firmware, then write the firmware to the device:
$ esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=8m -fm dio 0 esp8266-20160809-v1.8.3.bin
Now replug the device (or hit the RST button).
Enter the REPL
I used picocom.
$ picocom -b115200 -ep /dev/ttyUSB0
picocom v2.1 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 stopbits are : 1 escape is : C-p local echo is : no noinit is : no noreset is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, Type [C-p] [C-h] to see available commands Terminal ready
Press enter to see the prompt:
Specify the baudrate of 115200. Without this it said Terminal Ready, but there was no prompt and I couldn’t communicate at all. Once I specified the baudrate with the
-boption, the prompt appears (after pressing enter).
I changed picocom’s escape command to
C-aclashed with my tmux setup.
To exit use