After using ESPHome, I want to experiment more with the Picos without going back to programming in C. So it is MicroPython or CircuitPython. I chose MicroPython because it seems to have more features (i.e. Bluetooth).
First download a current Firmware from https://micropython.org/download/RPI_PICO/ and install via pressing the button on the Pico while connecting to USB. Copy the file on the device and it restarts when done.
On my ArchLinux I need sudo to write to
To fix this add the group
uucp to your user:
This is ArchLinux specific. For Ubuntu/Debian it is typically the group
Next step is to get a REPL and type in some Python. For this I used screen because of old habbit from years ago:
This small snippet copied into there will let the LED blink every second:
More on the timer in the MicroPython docs.
Writing in the REPL is nice but actual files are the way to go. But how to get the files on the Pico? Because I am late here and the MicroPython hype was years ago, the Internet is full of now dead instructions. One that seems to be still active is rshell. This can be pip installed, but I installed the Archlinux package.
When started with
rshell it connects automatically to
To start the same REPL as before with screen type
repl in the rshell.
Positive here: Ctrl-X to exit the REPL, which was more trouble in screen.
After REPL success lets use a file to do the same.
Copy the code into a file on your PC and name it
In rshell copy the file to the Pico:
main.py is started when the Pico is started.
boot.py is started before, but this may interfere with the REPL, so I chose not to add my own
Verify if the file is there (still in rshell):
When disconnected and reconnected again the Pico will now let the LED blink. After reconnecting with rshell the blinking will stop again and the filesystem can be changed again.
Thanks to https://blog.martinfitzpatrick.com/using-micropython-raspberry-pico/ for a good rshell/Pico introduction.