We will install all the dependencies, in both Linux-based and Windows OSs, to play with the MicroPython framework. We have chosen this development environment because it's easy to learn and has a great support from the community.

As for the other on-board microcontroller, there exist several frameworks that support the RP2040. To write firmwares for the RP2040, you can use the official C/C++ SDK, the Rust crate for the Pico board or the Arduino SDK. Choose the one you feel more comfortable with.

We have recorded a video in which all steps described below are directly executed on a PC.

Here a distinction between the Linux-based and Windows OSs is not needed, since MicroPython is host platform agnostic.

First of all you need to install python3 and python3-pip, but they are already installed by following the guide for ESP32 and IDF part.
You also need to install the rshell python package. It s needed to upload the python code and interact with the MicroPython interpreter running on the MCU. In a command line, type:

python3 -m pip install rshell

Now upload the MicroPython firmware into RP flash.
Firstly, download its latest release from this page.
Then put the microcontroller in flash mode: close the jumper JP1 to allow the computer to interact with RP and connect the board to your PC using an USB Type-C cable. Keep pressed the button SW2 labeled as BOOTSEL and push the reset button SW1. After these operations, the board is detected as a removable device by your computer.
Simply copy the just downloaded .uf2 file and paste it into the removable drive. In this way you can program the Raspberry MCU!

Once the MicroPython framework has been loaded, create a file called main.py and copy the following code on it.
It will make the LED attached on pin 25 blink each 750 milliseconds!

from machine import Pin
import time

led = Pin(LED_PIN, Pin.OUT)

while True :
    led.toggle ()
    time.sleep (.750)

To load the script on your board, move to the folder containing the main.py file using a command line (let's call it rp placed in ws folder), and type the following commands:

cd ws/rp
# Invoke the rshell program
# It will automatically find the board, if correctly plugged

# Now you can copy the main.py source file by copying it into /pyboard folder which represent the connected board
cp main.py /pyboard/main.py

To apply changes, close the rshell program and reset the board with on-board button SW1.

At this moment the LED will start blinking!

To implement complex project using MicroPython you can find its official documentation here and the documentation for RP2040 specific functionalities here.

Enjoy with your UDOO KEY!

This page was last updated on Friday, March 15, 2024 at 7:47 AM.