The live PM2.5 monitor was built for phones. I wanted a screen on the wall that shows one sensor forever, with no one touching it. It ended up on two boards with two different browsers.
The Shape of It
No desktop. The board boots to a console, logs in automatically, and starts cage, a Wayland compositor that shows one app full-screen:
getty autologin on tty1
└─ ~/.bash_profile loops: cage -s -- ~/kiosk.sh
└─ ~/kiosk.sh rotate/scale with wlr-randr, park the cursor, start the browser
If the browser exits, cage exits and the loop starts it again. The scripts are shared; each board just has a small config (output, rotation, scale, browser, sensor).
First Attempt: Pi OS and Chromium
- The desktop can't be trimmed. Pi OS starts labwc with
-m, which merges the system autostart with yours, so the panel and file manager always load. I dropped the desktop for console autologin plus cage. - Skip the Chromium wrapper.
/usr/bin/chromiumon Pi OS shows a "less than 1GB of RAM" dialog and adds--force-renderer-accessibility. With it, the page sat onabout:blank. Running/usr/lib/chromium/chromiumdirectly fixed that. - Scale at the compositor.
--force-device-scale-factor=2filled only a quarter of the screen on Wayland.wlr-randr --scale 2works. It's re-applied every 5 s, because the monitor sleeps and comes back unrotated. - Nobody is there to click. The translate bar and the location prompt are turned off in the profile's
Preferences. Thai text neededfonts-noto-core(the only Thai font was FreeSerif). The cursor, which cage draws even with no mouse, gets pushed into a corner by a throwaway virtual mouse created through/dev/uinput.
The Tinker Board, and Colors That Were Off
The Tinker (RK3288, 2 GB) loaded the page in 5 seconds instead of 1–2 minutes, but the light-blue AQI card looked darker than on desktop, and the black background had a blue cast. Counting pixel values in a screenshot showed why:
#111111 #111122 #00aaee
Every channel was a multiple of 0x11, so 4 bits per channel. --enable-low-end-device-mode, a flag I'd added for the Pi, renders tiles as RGBA4444. Without it, the Tinker shows #00b0f0 exactly, with the same memory use.
Back to the Pi: A GPU Chromium Can't Use
I reflashed the Pi with Armbian Minimal. Chromium's log kept saying:
eglCreateContext ES 3.0 failed ... ES version fallback is disabled.
The Pi Zero 2W's GPU only does OpenGL ES 2.0, and Chromium's ANGLE needs 3.0, so it renders in software. cog (WPE WebKit) works with ES 2.0: on the GPU, in full color, in about 125 MB.
cog can't script the page, but it can preset cookies. The app still migrates an old sensorChoice cookie into local storage, so kiosk.sh fetches the sensor from the registry and presets that cookie. (It uses curl: Cloudflare answers Python's urllib with 403.)
The Freeze
Then the data started drifting: the "updated at" time fell over a minute behind, caught up, and fell behind again. The Pi was swapping constantly to the SD card. The boot log showed why:
Memory: 133724K/458752K available (..., 262144K cma-reserved)
The GPU overlay reserves 256 MB of the 413 MB by default; the GPU uses about 112 MB. The fix was cma-192, zram at 100% of RAM, and a WebKit memory limit:
| Pi clock | On screen | Behind | |
|---|---|---|---|
| Before | 01:24:14 | 01:23:05 | 69 s |
| After | 01:46:34 | 01:46:33 | 1 s |
One more fix went into the web app: it kept 7 days of history and only pruned on page load. A wall display never reloads, so history is now 24 hours and prunes itself hourly.
Lessons
- Measure, don't guess. Pixel counts,
vmstatand the boot log found each cause in minutes. - Check what the GPU supports. ES 2.0 versus 3.0 decided which browser could run.
- On 512 MB, check what the kernel reserves. The GPU's 256 MB didn't show up in any process.
The Pi still takes about 90 seconds to show data after boot, mostly the CPU compiling the app's JavaScript. After that, it's live for days.