Installing MicroPython on your RP2040 Raspberry Pi Pico and setting it up to run a script automatically on power-up involves a few steps. Once setup check out Pico Micropython Examples

Here's a general guide to help you through the process:

1. Downloading MicroPython for RP2040

  1. Go to the official Raspberry Pi Pico website or MicroPython's download page for the RP2040/Pico.
  2. Download the latest MicroPython UF2 file for the Raspberry Pi Pico.

2. Installing MicroPython on the Raspberry Pi Pico

  1. Connect your Raspberry Pi Pico to your Ubuntu machine while holding down the BOOTSEL button. This will mount the Pico as a Mass Storage Device.
  2. Release the BOOTSEL button once the Pico is connected.
  3. Copy the UF2 file you downloaded to the Raspberry Pi Pico. The Pico will automatically reboot, and MicroPython will be installed.

3. Accessing the Pico via Serial Interface

To interact with your Pico, you can use a serial communication program like minicom, picocom, or screen. Here's how to do it with minicom:

4. Running a Script Automatically on Power-Up

  1. Writing Your Script: Write the Python script you want to run automatically. Let's say your script's filename is main.py.
  2. Uploading Your Script to the Pico: You can use a tool like rshell, ampy by Adafruit, or Thonny (a Python IDE that supports MicroPython and has a built-in file manager for devices like the Pico).
    For example, using ampy, you can upload your script with:
    ampy --port /dev/ttyACM0 put main.py

5. Additional Notes

reset your Pico or disconnect and reconnect it after uploading your script. This ensures the new script runs on the next boot.

With these steps, you should be able to run MicroPython on your Raspberry Pi Pico and have a script automatically execute on power-up. This setup is great for a wide range of projects, from simple automation tasks to complex IoT devices. If you encounter any issues during setup, the documentation for MicroPython and the Raspberry Pi Pico provides extensive information and troubleshooting tips.