How to upload files to MicroPython using WebREPL using webrepl_cli.py
First, clone the webrepl
repository:
git clone https://github.com/micropython/webrepl.git
Now use ampy
to initially setup your wifi connection and setup both wifi and WebREPL on on boot (see How to autoconnect to Wifi using MicroPython on your ESP32 board):
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect("MyWifi", "MyWifiPassword")
# Start webrepl
import webrepl
webrepl.start(password="Rua8ohje")
Upload via the serial port using
ampy -p /dev/ttyUSB0 put main.py
You should only have to do this once (except if you break you main.py
). If the upload doesn’t work
Go to the directory where webrepl_cli.py
is located:
cd webrepl
Now you can upload main.py
using
./webrepl_cli.py -p Rua8ohje ../main.py espressif.local:/main.py
You might need to use a different host, but espressif.local
seems to work out-of-the-box in many configurations.
The output should look like this:
op:put, host:espressif.local, port:8266, passwd:Rua8ohje.
../main.py -> /main.py
Remote WebREPL version: (1, 12, 0)
Sent 329 of 329 bytes
Now, reset your board using the *reset button,*so your updated main.py
will be executed.