WiFi and Network Configuration With MicroPython¶
Todo
This article is still a work in progress.
In this article I’ll discuss how to get up and running MicroPython on the
ESP8266 NodeMCU chip, and how to configure the WiFi and accesspoint on it
using the Vial microserver’s boot.py
file.
This article also discusses how to use the webrepl_cli.py
command line
tool to copy files into and out of the ESP.
The NodeMCU is my favourite piece of hardware. It hosts a cheap ESP8266 chip manufactured by the Chinese company, Esperif, and while it can run Lua and Arduino C, I’m a Pythonista.
After a little searching, I discovered that it can run a flavour of Python for microprocessors called MicroPython.
Once you have a nodemcu, it is rather easy to flash MicroPython on the board. Follow the instructions on the introduction page of the official documentation.
The only modification I’d suggest while using the nodemcu is to use a baud rate of 115200.
Once installed, open a tmux
or screen
session, and use the instrutions
here.
This enables you to login to a REPL over the serial port.
You’ll need to use tmux or screen because picocom cannot be exitted easily. It is much simpler to kill the containing terminal session instead.
The first steps you’ll need to now follow is to enable copying files to and from the ESP using WiFi.
Login to the chip over the serial port and run this command.
import webrepl_setup
This will ask you for a password. Choose something simple.
Once you’re done with this step, you can exit the REPL and copy files over the network.
Connect to the ESP’s WiFi (the password will be micropyth0N
). Then, clone the
WebREPL gitub project.
Ignore the interface for now, and use the webrepl_cli.py
file to transfer
files.
webrepl_cli.py --help