以下の内容はhttps://lipoyang.hatenablog.com/entry/2025/08/29/233431より取得しました。


PlatformIOでRaspberry Pi Pico 2W

PlatformIOで Raspberry Pi Pico 2W を Arduinoフレームワークで開発するには、非公式の野良プラットフォームを導入する必要がある。

手順

PlatformIOの「PIO Home」→「Platforms」→「Advanced Installation」で以下のGitHub URLを入力する。

https://github.com/maxgerhardt/platform-raspberrypi.git

platformio.ini に下記のように設定する。

[env:rpipico2w]
platform = raspberrypi
board = rpipico2w
framework = arduino

トラブル

以下のようなエラーが発生した。

UnknownBoard: Unknown board ID 'rpipico2w'

解決

platformio.ini に下記のように修正した。

[env:rpipico2w]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = rpipico2w
framework = arduino

WiFiの動作確認

アクセスポイントをスキャンするプログラム。

#include <Arduino.h>
#include <WiFi.h>

void setup()
{
  Serial.begin(115200);
  delay(1000);

  Serial.println("WiFi scanning...");

  int n = WiFi.scanNetworks();
  Serial.println("scan completed");
  if (n == 0) {
    Serial.println("AP not found");
  } else {
    Serial.printf("%d AP(s) found\n", n);
    for (int i = 0; i < n; ++i) {
      Serial.printf("%d: %s (%ddBm)\n", i + 1, WiFi.SSID(i), WiFi.RSSI(i) );
      delay(10);
    }
  }
}

void loop()
{
  // do nothing
}

注意

ESP32系の WiFi ライブラリとは微妙に仕様が異なる。上の例でもESP32用のソースをコピペしたら下記のエラーが発生した。

  • 定数 WIFI_AUTH_OPEN が未定義。WiFi.encryptionType( i ) が暗号化種別を判定してくれない。
  • WiFi.SSID(i) の戻り値がString型ではなく const char*型なので、余計な .c_str() を付けるとエラー。



以上の内容はhttps://lipoyang.hatenablog.com/entry/2025/08/29/233431より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14