Using ampy for transferring files with MicroPython
ampy (Adafruit MicroPython tool)
- Normally the connection to MicroPython is done using the serial connection.
- Ampy is a simple little tool for transferring files to, or from, MicroPython.
- Ampy can also execute a script on the MicroPython controller and return the output, which is convenient for development work.
Install
Installation happens on the workstation that connects to MicroPython, not on to the NodeMCU running MicroPython
Install pip
- pip is the Python package installer.
- If pip is not installed, add it to the system:
apt-get install -y python-pipInstall ampy
pip install adafruit-ampyTransferring files
List files on MicroPython
ampy -p /dev/ttyUSB0 -b 115200 lsTransferring files to MicroPython
echo 'print("hello world")' > hello.py
## put local [remote]
ampy -p /dev/ttyUSB0 -b 115200 put hello.pyTransferring files from MicroPython
## get remote local
ampy -p /dev/ttyUSB0 -b 115200 get boot.py boot.py
cat boot.pyRun script on remote MicroPython and display output
ampy -p /dev/ttyUSB0 -b 115200 run hello.py