Raspberry Pi Pico W example

This example application runs out of the box on the Raspberry Pi Pico W.

It uses the on board WiFi peripheral to send data to Drogue Cloud.

Prerequisites

Hardware

Software

  • To build the example, you need to have rustup.

  • To flash the example using a debug probe, you need probe-run installed (cargo install probe-run).

  • To flash the example using the UF2 bootloader on the pico, you can use the elf2uf2 utility to convert the elf file into a .uf2 file that you can copy to the pico USB drive.

  • A Drogue Cloud instance. See drogue-cloud for how to run that, or use the sandbox (requires TLS).

Configuring

Credentials for your local WiFi network will come from these entries in ~/.drogue/config.toml:

wifi-ssid = "..."
wifi-password = "..."

HTTP authentication will come from these entries in ~/.drogue/config.toml:

username = "..."
password = "..."

For Drogue Cloud, the username/password is stored in this form: device_id@application.

The example config.toml file for connecting to public Drogue cloud sandbox application could look like this:

hostname = "http.sandbox.drogue.cloud" # Replace with your own Drogue Cloud instance if you are not using the sandbox
port = "443"
wifi-ssid = "..."                      # The WiFi network SSID
wifi-password = "..."                  # The WiFi network pre-shared key
username = "device1@wifi-workshop"
password = "mysecretpassword"

Running with debug probe

Procedure
  1. Download the WiFi firmware from https://github.com/embassy-rs/cyw43/tree/master/firmware, and flash them with probe-rs-cli:

    probe-rs-cli download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
    probe-rs-cli download 43439A0.clm_blob --format bin --chip RP2040 --base-address 0x10140000
  2. Connect your debug probe and run:

    cargo run --release

    Once flashed, the device will attempt to join the WiFi network and send telemetry data to Drogue Cloud every 30 seconds.

Running with UF2 image

Procedure
  1. Download the WiFi firmware from https://github.com/embassy-rs/cyw43/tree/master/firmware, and modify main.rs to include it:

    // let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) };
    // let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
    let fw = include_bytes!("../firmware/43439A0.bin");
    let clm = include_bytes!("../firmware/43439A0_clm.bin");
  2. Build the firmware

    cargo build --release
  3. Convert the ELF output to UF2

    elf2uf2-rs target/thumbv6m-none-eabi/release/rp2040-pico-w rp2040-pico-w.uf2
  4. Hold the Pico W button while powering up the board, and copy the uf2 file to the USB partition

    cp rp2040-pico-w.uf2 /mount/point/of/usb/drive

    Once flashed, the device will attempt to join the WiFi network and send telemetry data to Drogue Cloud every 30 seconds.

  5. You can monitor the logs using a terminal emulator on the Pico W TTY

    minicom -D /dev/ttyACM0

Troubleshooting

If you’re experiencing problems, try setting the VID:PID values to that of your probe (you can find that from lsusb once your board is powered).

<ENV> cargo run <ARGS> -- --probe <VID>:<PID>