If you buy one on eBay, chances are it will NOT be flashed with NodeMCU firmware (it speaks Lua). This understandably confused the crap out of me. So, this serves as a guide to those running Manjaro (Arch) Linux:
- Download NodeMCU firmware
"integer" versions will NOT understand floating point arithmetic, but save on system resources.
- Install minicom
pacman -Ss minicom
- Install esptool from the AUR:
- Make sure your Linux box recognizes the device
tail -f /var/log/messages.log
- Plug in the NodeMCU device. You should see:
kernel: usb whatever: ch341-uart converter now attached to ttyUSBX
ch341-uart converter detected
If this didn't happen, you cannot proceed and must troubleshoot.
- Flash the firmware. Make sure you have permission to read and write to the device in the command below. When in doubt, run as root:
esptool.py --port /dev/ttyUSBX write_flash 0x00000 nodemcu_whatever.bin
X corresponds to the device from the log file above, and
nodemcu_whatever.bin corresponds to the firmware file in step 1.
- Unplug the USB cable after the flash command from the previous step is completed, and plug it back in.
- Fire up minicom, and talk to the board at 9600 baud:
minicom -D /dev/ttyUSBX -b 9600
- Press the "enter" key a few times. In response, you should see:
- Try "hello world":
> print ("hello world")
- Now you can configure wireless:
> wifi.sta.config("SSID", "PASSWORD")
> ip, nm, gw=wifi.sta.getip()
> print (ip, nm, gw)
this is amazing
- Do some interesting things!