How to upload files to MicroPython over USB/serial
In this post we will investigate how to connect to a wireless network on boot
First, install ampy - a tool to modify the MicroPython filesystem over a serial connection.
sudo pip3 install adafruit-ampy
Now prepare your script - we’ll use main.py
in this example.
Upload the file to the board:
ampy -p /dev/ttyUSB* put main.py
This only takes about 2-4 seconds. In case ampy
is still running after 10 seconds, you might need to
- Stop
ampy
(Ctrl+C
), reset the board using theRESET
button and retry the command - Stop
ampy
(Ctrl+C
). Detach USB and ensure the board is powered off (and not powered externally). Re-Attach USB and retry the command. - In case that doesn’t help, try re-flashing your board with the most recent version of MicroPython. See How to flash MicroPython to your ESP32 board in 30 seconds. This will also clear the internal filesystem and hence remove any file that might cause failure to boot properly.