So Easy MicroPython — ESP8266/ESP32 MCU File Management

Yungger
2 min readApr 23, 2021
Using ampy to manage the files of your MCU, for example on ESP8266, ESP32 or Raspberr Pi, …etc

Step 1: Install ampy

  • pip install adafruit-ampy

Step 2: Verify ampy

  • ampy — help
if you saw the message as screenshot means install successfully.

Step 3: Upload your file to MCU

  • ampy —port {your device port} put {path/xxx.py}

As your coding done, confirm your board and port first, plug-in your MCU, then you are ready to upload your file, just using the commands above.

For example, if the serial port of your MCU is /dev/cu.usbserial-11440, and want to upload a file called main.py onto current directory.

Then, the command will be :

ampy — port /dev/cu.usbserial-11440 put main.py

Step 4: Check your file on MCU

  • ampy — port {your device port} ls
Using command “ls” can check if the file has been uploaded to the MCU

Step 5: Execute the file

  • ampy — port /dev/cu.usbserial-11440 run {path/xxx.py}

*** If the file is either boot.py or main.py, it will be run automatically after start-up. So, you just need to press the RST button to reboot it. ***

Step 6: Other commands

  • Download file: ampy — port {your device port} get {path/xxx.py} {local driver path/xxx.py}
  • Remove file: ampy — port {your device port} rm {path/xxx.py}
  • Create directory: ampy — port {your device port} mkdir xxx
  • Remove directory: ampy — port {your device port} rmdir xxx
  • Reboot: ampy — port {your device port} reset

That’s all, so easy right ? Hope this helps !

Posted by Yungger

If it really help you, you are welcome to clap your hands clicking on top-left icon, or want to buy me a coffee to encourage me to write more, I thank you too 😘 😘 !!

--

--