~nora/rpi-pico

MicroPython on Raspberry Pi Pico
Add days 10 to 12
Add days 1 to 9
Add mpremote module

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~nora/rpi-pico
read/write
git@git.sr.ht:~nora/rpi-pico

You can also use your local clone with git send-email.

#MicroPython on Raspberry Pi Pico

#Resources

#Install MicroPython

  1. Push and hold the BOOTSEL button and plug your Pico into the USB port of your computer.
  2. Release the BOOTSEL button after your Pico is connected.
  3. It will mount as a Mass Storage Device called RPI-RP2.
  4. Download the MicroPython UF2 file for the pico: https://micropython.org/download/rp2-pico/
  5. Copy the MicroPython UF2 file onto the RPI-RP2 volume.
  6. Your Pico will reboot. You are now running MicroPython.
  7. You can access the REPL via USB Serial on /dev/ttyACM0.

On Arch Linux you need to be in uucp group:

udisksctl mount -b /dev/sda1
# download and copy UF2 file
udisksctl umount -b /dev/sda1
doas usermod -aG uucp nora

#Run Python code

#mpremote

Install mpremote module.

Access REPL on the device:

mpremote
mpremote a0
mpremote connect /dev/ttyACM0 repl

Run a command on the device:

mpremote eval 1+1
mpremote exec "print(1+1)"

Run a script on the device:

mpremote run app.py

Run a filesystem operation on the device:

# ls, cat, touch, cp, rm, mkdir, rmdir
mpremote cp main.py :
mpremote ls

Show memory usage:

mpremote df
mpremote exec "import micropython; micropython.mem_info()"

Mount the local directory on the device:

mpremote mount .
mpremote umount

Reset the device:

mpremote soft-reset
mpremote reset

Install packages from micropython-lib:

mpremote mip install ssd1306

#pyboard.py

Download pyboard.py and install pyserial module.

Run a command on the device:

python pyboard.py --device /dev/ttyACM0 -c 'print(1+1)'

Run a script on the device:

python pyboard.py --device /dev/ttyACM0 app.py

Run a filesystem operation on the device:

# ls, cat, touch, cp, rm, mkdir, rmdir
python pyboard.py --device /dev/ttyACM0 -f cp main.py :

Reset the device:

python pyboard.py --device /dev/ttyACM0 -c 'machine.reset()' --no-follow

#PyCharm MicroPython

Install the plugin and create a new project with a virtual environment.