Skip to content

Add RP2040/RP2350 (Raspberry Pi Pico W) build support (Arduino IDE + PlatformIO)#339

Open
wedsamuel1230 wants to merge 13 commits intos00500:masterfrom
wedsamuel1230:master
Open

Add RP2040/RP2350 (Raspberry Pi Pico W) build support (Arduino IDE + PlatformIO)#339
wedsamuel1230 wants to merge 13 commits intos00500:masterfrom
wedsamuel1230:master

Conversation

@wedsamuel1230
Copy link

Summary

This PR adds full RP2040/RP2350 (Raspberry Pi Pico W) build support to ESPUI, with verified compilation on both Arduino IDE and PlatformIO.

What changed

Core library

  • src/ESPUI.cpp/.h
    • Unify async code path and remove ESP32/ESP8266-only conditional branches where possible
  • src/ESPUIclient.cpp/.h
    • Standardize on AsyncWebSocketClient and add semaphore guards for RP2040 compatibility

Examples (12 total)

All Arduino IDE and PlatformIO examples now include RP2040 platform guards:

  • gui.ino — WiFi, DNS, hostname guards
  • tabbedGui.ino — RP2040 adjustments across WiFi/DNS/hostname/MDNS-related paths
  • completeExample.cpp — MDNS guards, WiFi .c_str() fixes
  • completeLambda.ino — MDNS guards, WiFi .c_str() fixes
  • gui-generic-api.ino — Fix #else logic bug
  • prepareFilesystem.ino — RP2040 guards

PlatformIO

  • Added [env:rpipicow] to all 6 platformio.ini files
  • Platform: maxgerhardt/platform-raspberrypi.git with earlephilhower core

Metadata / housekeeping

  • library.json
    • Add raspberrypi platform
    • Depend on ESPAsyncWebServer (>= ^3.7.9)
  • library.properties — Add RP2040/RP2350 architectures
  • .gitignore — Add .pio/, pio_build_*.log

Compile verification

System Target Status
Arduino IDE rp2040:rp2040:rpipicow ✅ 6/6 pass
PlatformIO rpipicow ✅ 6/6 pass

Technical notes / limitations

  • Platform detection:
    • #if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RP2040) || defined(PICO_RP2040)
  • RP2040 WiFi: WiFi.begin() requires .c_str() for SSID/password strings
  • Not supported on RP2040 (guarded/disabled): DNSServer, WiFi.hostname(), MDNS
  • Chip ID: rp2040.getChipID()
  • Async stack: ESPAsyncWebServer + RPAsyncTCP (RP2040)

Acknowledgements
Thanks to the original ESPUI project: https://github.com/s00500/ESPUI
This PR extends the ESP8266/ESP32 async webserver framework to Raspberry Pi Pico W while maintaining the same developer experience.

- Updated version to 2.3.4 in library.json and library.properties
- Enhanced .gitignore to exclude additional files
- Refactored ESPUI.cpp and ESPUI.h for platform-specific handling
- Introduced pico-gui and rp2040Example for Raspberry Pi Pico W
- Updated platformio.ini for Pico W and RP2040 examples
…o 2.3.4 in library.json and library.properties - Enhanced .gitignore to exclude additional files - Refactored ESPUI.cpp and ESPUI.h for platform-specific handling - Introduced pico-gui and rp2040Example for Raspberry Pi Pico W - Updated platformio.ini for Pico W and RP2040 examples
…uards to all examples

Core library fixes:
- Set ESPUI_USING_FREERTOS=0 for RP2040/RP2350 (no FreeRTOS on arduino-pico)
- Guard xSemaphoreTake/Give behind ESPUI_USING_FREERTOS macro
- Remove corrupted preprocessor fragment in ESPUIclient.cpp
- Unify ESPUIclient to use AsyncWebSocketClient* on all platforms
- Remove duplicate RP2040 sync begin() code path

All examples (Arduino IDE + PlatformIO) updated with:
- Platform detection: ESP32 / ESP8266 / RP2040 WiFi includes
- DNSServer/captive portal guarded (#if !defined(ARDUINO_ARCH_RP2040))
- Hostname handling per platform (setHostname/hostname/skip)
- ChipID per platform (getEfuseMac/getChipId/rp2040.getChipID)
- MDNS guarded for RP2040 (not available on arduino-pico)
- WiFi.begin uses .c_str() on RP2040 (same as ESP32)

Deleted separate pico examples (merged into existing):
- examples/pico-gui, examples/pico-all-controls, examples/rp2040Example
- pio_examples/pico-gui, pio_examples/rp2040Example

Updated library metadata:
- library.json: RP2040/RP2350 keywords, raspberrypi platform
- library.properties: RP2040 in architectures and dependencies

Tested: All 6 Arduino IDE examples compile for rp2040:rp2040:rpipicow
Add RP2040 Pico W build environment to all 6 PlatformIO example
platformio.ini files using maxgerhardt/platform-raspberrypi with
earlephilhower arduino-pico core and ayushsharma82/RPAsyncTCP.

All 6 PIO examples compile successfully for rpipicow:
- gui: 528KB Flash, 74KB RAM
- tabbedGui: 477KB Flash, 73KB RAM
- completeExample: 485KB Flash, 73KB RAM
- completeLambda: 485KB Flash, 73KB RAM
- gui-generic-api: 477KB Flash, 73KB RAM
- prepareFilesystem: 202KB Flash, 72KB RAM

Also add .pio/ to .gitignore to exclude PIO build artifacts.
clean up .gitignore by removing unnecessary entries
@s00500
Copy link
Owner

s00500 commented Feb 24, 2026

Hey there Claude =P

This looks interensting, I will get back to reviewing but I am generally low on time for this project, hope to get to it in 1-2 weeks

@wedsamuel1230
Copy link
Author

Hi there! Actually I used AI to help the PR description and the code changes were AI-assisted.
I've compiled and tested the modified library on Pico W and it works fine!
I'm a student working on IoT projects using Pico W and needed ESPUI to run on Pico W.
That's why this PR exists! :3
And this is my first time to PR, so please let me know if anything could make the PR better!

@s00500
Copy link
Owner

s00500 commented Mar 8, 2026

Hm, somehow this fails to build for me...

https://github.com/earlephilhower/arduino-pico.git does not have a platform.json even, feels like there might be a mistake here...

I guess the plan was rather using something like https://github.com/maxgerhardt/platform-raspberrypi.git ?

did you run the pico gui successfully ?

@wedsamuel1230
Copy link
Author

wedsamuel1230 commented Mar 10, 2026

Yeah I did run the pico gui successfully using arduino ide.

Update:
I have seen the arduino pico docs https://arduino-pico.readthedocs.io/en/latest/platformio.html and discover earlephilhower/arduino-pico repo isn't a PlatformIO platform (no platform.json) - it works as a core loaded via maxgerhardt/platform-raspberrypi platform.
Here is the correct platform.ini configuration. I have updated to the examples
[env:pico] platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino board_build.core = earlephilhower

This should resolve your build failure.

Set ESPUI_USING_ASYNC to 0 for RP2040 and RP2350 and conditionally compile async-only APIs. Wrapped beginSPIFFS, beginLITTLEFS and the memory-mode begin() implementations behind #if ESPUI_USING_ASYNC in src/ESPUI.cpp, added appropriate #endif adjustments, and gated the onWsEvent declaration in src/ESPUI.h. Also added WebServer.h and WebSocketsServer.h includes for the non-async path so RP2040/RP2350 build with the synchronous server/websocket implementation. These changes ensure the project builds correctly on RP2040/RP2350 platforms that don't use the async stack and avoid exposing async APIs where not supported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants