Pico OTA

by Samuel Fong in Circuits > Arduino

31 Views, 0 Favorites, 0 Comments

Pico OTA

Gemini_Generated_Image_rn8iwsrn8iwsrn8i.png

This project shows how to upload Arduino sketches to a Raspberry Pi Pico W (or Pico 2 W) over Wi-Fi (OTA = Over-The-Air).

After one USB upload, you can update your Pico wirelessly from Arduino IDE - no more unplugging USB cables.


You will do:

1. Install the Arduino-Pico core (RP2040)

2. Install the PICO_OTA library

3. Select a Flash Size that includes FS (LittleFS) - this is critical

4. Upload once via USB

5. Upload later via Network Port (OTA)

Supplies

Hardware

- Raspberry Pi Pico W (or Pico 2 W)

- USB cable (for the first upload)


Software

- Arduino IDE (1.8.x or 2.x)

- Arduino-Pico core (Earle Philhower RP2040)

- PICO_OTA library


Network

- Your Pico W and your computer must be on the same Wi-Fi network (same LAN).

Install Arduino-Pico Core

paste the link (2).png
paste the link.png
paste the link (1).png

1. Open Arduino IDE


2. Go to File > Preferences


3. Add this URL to Additional Board Manager URLs:


https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json


4. Go to Tools > Board > Boards Manager


5. Search for pico and install:


Raspberry Pi Pico/RP2040/2350 by Earle F. Philhower, III

Install the PICO_OTA Library

paste the link (3).png

Two ways to install - choose one:


Method A: Arduino IDE Library Manager (if available)


1. Go to Sketch > Include Library > Manage Libraries


2. Search for PICO_OTA


3. Install the library by wedsamuel1230


Method B: Manual Install (always works)


1. Download from:


https://github.com/wedsamuel1230/Pico_OTA


2. Extract the ZIP file


3. Move the Pico_OTA folder to your Arduino libraries folder:


- Windows: Documents\Arduino\libraries\


- Mac: ~/Documents/Arduino/libraries/


- Linux: ~/Arduino/libraries/


4. Restart Arduino IDE


Verify installation:


- Go to File > Examples


- Look for PICO_OTA - you should see example sketches there

Select the Correct Board Flash Settings (CRITICAL)

paste the link (4).png

1. Go to Tools > Board


2. Select Raspberry Pi RP2040 Boards > Raspberry Pi Pico W (or Pico 2 W)


CRITICAL: OTA requires filesystem space (LittleFS). You must select a Flash Size option that includes FS.


Recommended example setting:


- Tools > Flash Size > 2MB (Sketch: 1MB, FS: 1MB)


Do NOT choose a "No FS" option, or OTA will fail.

Open an Example Sketch

Go to:

File > Examples > PICO_OTA


Recommended for classes / teams:

Pico_OTA_test_with_Dual_Core


Why dual-core? OTA runs on Core 1, while your project logic runs on Core 0. This keeps your application responsive and makes it easier to teach: students can focus on Core 0 only.


Optional: Pico_OTA_test (single-core) is simpler, but OTA shares the same loop and can be impacted by blocking code.

Dual-Core Workflow (Hide OTA in Secret.h, Code on Core 0)

In the dual-core example, all OTA-related setup is intentionally placed in secret.h.


Important (recommended for classes): Treat secret.h as a protected / instructor-owned file. Students/users should not modify OTA logic there. They should only write application code on Core 0 in the main .ino file.


What lives in secret.h (Core 1):


- Wi-Fi credentials (ssid/password)


- OTA hostname / OTA password


- setup1() and loop1() that run on Core 1 to keep OTA alive


What students should edit (Core 0):


- setup() and loop() in Pico_OTA_test_with_Dual_Core.ino


- Their sensors, motors, UI, logic, etc.


Dual-core secret.h example (do not change the OTA parts):


const char *ssid = "Your_SSID";
const char *password = "Your_PASSWORD";
const char *hostname = "pico-ota"; // device name shown in Network Ports
const char *otaPassword = "admin"; // change this for real projects

void setup1() {
otaSetup(ssid, password, hostname, otaPassword);
}

void loop1() {
otaLoop();
}


Core 0 template (this is where you code):


void setup() {
Serial.begin(115200);
// Your setup code here
}

void loop() {
// Your application code here (Core 0)
// OTA is handled on Core 1 in secret.h
}


Why hide OTA in secret.h?


- Prevents accidental edits that break OTA (common in teaching labs)


- Keeps security-sensitive settings (passwords) in one place


- Lets students focus on Core 0 application logic without learning OTA internals first


Security tip: Use a strong OTA password for real projects (avoid "admin").

First Upload Via USB (one Time)

1. Plug your Pico W into your computer via USB


2. Select the USB port: Tools > Port > your COM port


3. Click Upload


Open Serial Monitor at 115200 baud and note the IP address.


You should see logs like:


[OTA] Connecting WiFi...
[OTA] WiFi connected, IP: 192.168.1.100
[OTA] LittleFS mounted
[OTA] Ready for OTA updates

Upload Wirelessly (OTA)

1. In Arduino IDE, go to Tools > Port


2. Look under Network Ports


3. Select your device (it may show as hostname at IP)


4. Click Upload again - now it uploads over Wi-Fi


Tip: Keep the Pico powered during OTA uploads.

Use PICO_OTA in Your Own Sketch

Minimal pattern:


#include <pico_ota.h>

const char *ssid = "YourWiFi";
const char *password = "YourPassword";

void setup() {
Serial.begin(115200);
otaSetup(ssid, password, "my-device", "my-ota-password");
}

void loop() {
otaLoop();
// Your code here...
}


Notes:


- Call otaSetup(...) once in setup().


- Call otaLoop() often in loop() (avoid long blocking delays).

Troubleshooting

LittleFS mount failed / No filesystem


- Re-check Tools > Flash Size and select an option with FS.


- Upload once over USB again after changing the Flash Size.


Device not showing in Network Ports


- Confirm the Pico and your PC are on the same Wi-Fi.


- Check Serial Monitor for the IP address.


- Check firewall rules on your computer.


OTA password issues


- Make sure the password in your sketch matches what you type when uploading.