Ampy to transfer files to Pycom microcontroller: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 56: | Line 56: | ||
* Use the '''get''' command to copy files from the pycom. | * Use the '''get''' command to copy files from the pycom. | ||
* The following commands serves as an example to get the boot.py file from the Pycom to the host computer. | * The following commands serves as an example to get the boot.py file from the Pycom to the host computer. | ||
* The get command will always overwrite files on the computer without warning! | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ampy -p /dev/ttyACM0 get /flash/boot.py /home/pi/boot_backup.py | ampy -p /dev/ttyACM0 get /flash/boot.py /home/pi/boot_backup.py | ||
| Line 63: | Line 65: | ||
* The get command without a destination file name will '''print''' the contents of the file. | * The get command without a destination file name will '''print''' the contents of the file. | ||
| Line 72: | Line 75: | ||
[[File:Screenshot 2023-07-29 at 4.18.09 pm.png | 900px]] | [[File:Screenshot 2023-07-29 at 4.18.09 pm.png | 900px]] | ||
= Run code using Ampy = | = Run code using Ampy = | ||
| Line 85: | Line 84: | ||
print(i) | print(i) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[File:Screenshot 2023-07-29 at 4.19.46 pm.png | 900px]] | |||
Revision as of 13:22, 29 July 2023
Ampy to transfer files to Pycom microcontroller
Authors
For more information contact Adam Simankowicz or Edmond Lascaris
References
Installation of Ampy
sudo pip3 install adafruit-ampy
- To check that ampy has installed correct enter the following in the Terminal.
ampy --help
- To upgrade ampy to the latest version enter the code
sudo pip3 install adafruit-ampy --upgrade
Connecting to Pycom using Ampy
- To connect to the Pycom enter the following command:
ampy -p /dev/ttyACM0 ls
- Commands need to be entered one at a time.
- This command list the main directory on the Pycom /flash
- All files on the Pycom are found within this directory.
- -p the Pycom on the Raspberry Pi is always connected to port /dev/ttyACM0
- To list all files and directories on the Pycom enter the command:
ampy -p /dev/ttyACM0 ls -l /flash
Get files from Pycom using Ampy
- Use the get command to copy files from the pycom.
- The following commands serves as an example to get the boot.py file from the Pycom to the host computer.
- The get command will always overwrite files on the computer without warning!
ampy -p /dev/ttyACM0 get /flash/boot.py /home/pi/boot_backup.py
- The get command without a destination file name will print the contents of the file.
Put files onto the Pycom using Ampy
- Put files onto the Pycom with the command:
ampy -p /dev/ttyACM0 put /home/pi/test.py /flash/test.py
Run code using Ampy
- You can copy code to the Pycom and then run the code.
- Save the following code in a file named /home/pi/test.py
print('Hello world! I can count to 100:')
for i in range(1,100):
print(i)