1.3 Setting up the Pico - naubeeluck/OP-Cansat GitHub Wiki

We will need to be able to programme the Pico by using the USB cable. This connection will also be useful for later should we wish to transfer data using it. In order to do all of this a bit setup is required. The Esero guide does this best. An extract of it is as shown below and can be accessed here.

Install CircuitPython on the Pi Pico

CircuitPython is a Python environment for controlling small computer systems such as the Pi Pico. It allows such boards to be programmed in Python by uploading a main python file (code.py or main.py) that is executed when the Pi Pico is switched on. It contains functions for direct low-level control of the boards pins and hardware interfaces.

Follow the following steps to install CircuitPython on the Pi Pico.

  1. Download the CircuitPython environment for the Pi Pico from CircuitPython

  2. The Pi Pico needs to be started into a different mode to install the CircuitPython environment. To do this, hold down the BOOTSEL switch and plug the USB cable into the Pi and your PC.

  3. The Pi should mount as an USB drive labelled "RPI-RP2", at which point release the BOOTSEL button.

  4. Copy the .uf2 file onto the Pi USB drive. The USB drive will unmount itself and then re-mount as a new USB drive labelled "CIRCUITPY"

  5. If you are using Windows 7 or 8, you will also need to download and install the Adafruit drivers package so that Windows can communicate with the Pi Micro.

Install BMP280, RFM9x and Adafruit Boards libraries CircuitPython provides some built in functionality for managing the Pi Pico, however this can be extended through the use of third-party libraries. These are libraries produced by manufacturers, suppliers and the CircuitPython community for the purpose of using extra devices with the Pi Pico. These libraries reduce the complexity of using external devices by providing high-level functions to interact with the devices they support.

Libraries are installed into CircuitPython by copying across the ".mpy" file associated with the library to the "lib" folder found on the USB drive of the Pi Pico.

For the CanSat primary mission we need to install the BMP280 sensor library and the RFM9x radio library. These are available from the Adafruit CircuitPython library collection .

  1. Download and extract the latest version of adafruit-circuitpython-bundle-7.x-mpy.zip or from the USB stick in the training session.

  2. Find adafruit_bmp280.mpy within the lib folder of the adafruit library collection. Copy this file over to the Pi Pico USB drive (CIRCUITPY).

  3. Find adafruit_rfm9x.mpy within the lib folder of the adafruit library collection. Copy this file over to the Pi Pico USB drive (CIRCUITPY).

  4. Both of these libraries depend on another library to work, this is the adafruit_bus_device library. This library is a collection of .mpy files so look for a folder with that name in the Adafruit library collection. Copy the whole folder over to the lib folder of the Pi Pico.

  5. The contents of your lib folder on your Pi Pico should now look as follows:

Pico Pin Outs