Skip to content

mthorley/wifimanager-pico

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WiFiManager for RaspberryPi PicoW

This library provides a captive portal similar to ESP32 WiFiManager implementations to allow WiFi credentials to be entered and stored in (simulated) EEPROM so that devices can be configured to local WiFi networks.

Features

  • Basic customisable HTML content
  • Persistent storage of credentials in EEPROM

It does not support OTA nor device configuration outside of WiFi credentials.

Basic Usage

To create a captive portal:

// Connect using saved creds, or start captive portal if none found. 
// Blocks until connected or the portal is closed

WiFiManager wm("ap_SSID", "ap_password");   // Access point credentials for portal
bool success = wm.autoConnect();

By default, the portal appears as below. However, some basic customisation is available for the main (hero) image, title and maker attribution:

const char main_img[] PROGMEM = R"=====(
    data:image/png;base64, ..."
)=====";

String title("Cool device");
String name("DeviceName"):
String shortname("TLA");
String maker("Person");
String version("1.0");
wm.setContentText(title, name, shortname, maker, version);
wm.setContentMainImage(main_img);
bool success = wm.autoConnect();

where main_img is a char* to a base64 encoded image in this case.

Captive Portal

Following a similar approach to the ESP WiFiManager, if no WiFi credentials are found within EEPROM, the PicoW creates an access point with an SSID of and password of chosing. Once connected a captive portal is presented enabling selection of found WiFi networks and password to be entered. Once validated, these credentials are saved in EEPROM and used to connect on next restart.

The portal home page confirms the device attributes including name, maker and firmware version.

Whilst the captive portal has been tested on iOS, Android and macOS, windows has not. If the portal does not show, entering http://picow.local into the browser will pull it up.

Captive Portal Home

The portal WiFi page allows configuration of the target network.

Captive Portal WiFi setup

Content

The templates for the captive portal web assets (e.g. HTML, CSS, images) are defined in WiFiManagerAssets.h where web assets or fragments of HTML are stored as PROGMEM variables within flash. These variables are then consumed within WiFiManager.cpp to hydrate the web assets and perform any dynamic text or style substitutiions using String to replace ${variable_name} with content.

The web assets are derived from web content held under html. These web assets can be extended and tested in isolation before being encoded into PROGMEM variables.

Note the use of EEPROM (used to store WiFi credentials) is simulated, since the Raspberry Pi Pico RP2040 does not come with an EEPROM onboard, it is simulated by using a single 4K chunk of flash at the end of flash space.

Installation

For platformio, add the library as a reference to your main project under lib_deps:

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board = rpipicow
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
monitor_filters = time
monitor_speed = 115200
lib_deps = 
	https://github.com/mthorley/wifimanager-pico.git
    CRC@^1.0.1

Debugging

The library will output logs to Serial, if debug is enabled in the constructor:

bool debug = true;
WiFiManager wm("ap_SSID", "ap_password", debug);   // Access point 

Attribution

Hero image is a nod to the excellent OXRS ecosystem.

About

WiFi captive portal to support configuration of local WiFi networks on RaspberryPi PicoW

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published