How to upload files to MicroPython using WebREPL using webrepl_cli.py
First, clone the webrepl repository:
clone_webrepl_repo.sh
git clone https://github.com/micropython/webrepl.gitNow 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):
setup_webrepl.py
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
upload_with_ampy.sh
ampy -p /dev/ttyUSB0 put main.pyYou 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_dir.sh
cd webreplNow you can upload main.py using
upload_with_webrepl_cli.sh
./webrepl_cli.py -p Rua8ohje ../main.py espressif.local:/main.pyYou 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:
webrepl_upload_output.txt
op:put, host:espressif.local, port:8266, passwd:Rua8ohje.
../main.py -> /main.py
Remote WebREPL version: (1, 12, 0)
Sent 329 of 329 bytesNow, reset your board using the *reset button,*so your updated main.py will be executed.
Check out similar posts by category:
Embedded, MicroPython
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow