Skip to main content

Working with Raspberry Pi Pico

This chapter includes the following sections:

Setting Up the Development Environment

1. Installation and Configuration

  • For Raspberry Pi Pico environment setup and basic usage, please refer to the following links:
  • After setting up the environment, connect the sensor and download the example package.

Example

Hardware Connection

Connect as shown in the figure below.

Pico 2

Running the Arduino Pico Example

  • Navigate to TOF-MINIS-Range-Sensor/example/pico/Arduino/TOF_UART_Demo and double-click TOF_UART_Demo.ino to open the project.

  • Select the chip model and port.

    Arduino Pico 2
  • After upload is complete, open the Serial Monitor to view the output.

Running the MicroPython Example

  • First flash the MicroPython firmware to the Raspberry Pi Pico.

  • Navigate to TOF-MINIS-Range-Sensor/example/pico/pico-pico_micropython_example and double-click main.py to open the project in Thonny.

  • Select the development board.

  • Select the Raspberry Pi Pico port, then run the example.

  • The shell will display the relevant output.

    Mpy Pico 2

Running the C Example

  • Navigate to TOF-MINIS-Range-Sensor/example/pico/pico_sdk_example and open this folder in VS Code.

  • Import this project in the Pico tools.

    Pico 2
  • After import succeeds, click "Compile" to build. After compilation, put the Pico into BOOT mode and copy the UF2 firmware to the RP2040 disk.

  • Open a serial debug tool to view the output.

    Pico 2