Skip to content

Instantly share code, notes, and snippets.

@switchtrue
Last active January 6, 2018 06:09
Show Gist options
  • Save switchtrue/8265e69c3623e7e4a456b25e506705e5 to your computer and use it in GitHub Desktop.
Save switchtrue/8265e69c3623e7e4a456b25e506705e5 to your computer and use it in GitHub Desktop.
Notes on flashing MicroPython on NodeMCU from MacOS

NodeMCU mode: Keyes NodeMCU OS: Mac OS X (macOS)

Install a serial driver for the NodeMCU from: http://www.wch.cn/download/CH341SER_MAC_ZIP.html

Plugin the NodeMCU and see if you can see it at /dev/tty.wchusbserialfd120 NOTE: If you can't find it at the above locations try ls /dev/cu.* and see what else is available.

OSX Sierra Important Note: After upgrading to Sierra plugging in my NodeMUC I kept getting Kernel panics and the laptop would restart. To fix this I uninstalled the original drivers with the following commands, restarted and then re-installed from the link above.

sudo rm -rf /Library/Extensions/usbserial.kext
sudo rm -rf /System/Library/Extensions/usb.kext
# Restart computer now

Grab firmware from here: https://micropython.org/download/

Install pyserial:

pip install pyserial

Install esptool:

pip install esptool

Erase:

esptool.py --port /dev/tty.wchusbserialfd120 erase_flash

Flash:

esptool.py --port /dev/tty.wchusbserialfd120 --baud 115200 write_flash --flash_size=detect 0 ~/Downloads/esp8266-20170108-v1.8.7.bin --verify

Connect to the NodeMCU:

screen /dev/cu.wchusbserialfd120 115200

Might need to hit enter a few times at REPL to get >>>

try it:

>>> print('Hello, World!')

Connect to a network:

>>> import network
>>> n = network.WLAN(network.STA_IF)
>>> n.active(True)
>>> n.connect('<SSID>', '<password>')

Note: Don't get SSID and password wrong as it seems to indefinitely reconnect even after re-flashes and log to stdout, you can enter paste mode (ctrl+e) and enter the above code again to retry but its tricky.

Start the Web REPL:

>>> import webrepl
>>> webrepl.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment