Kent Nguyen's Lab #indatawetrust
← All posts

Building a Power-Cut-Resilient Home and CI HUD with Rust on ESP32-S3

Building a Power-Cut-Resilient Home and CI HUD with Rust on ESP32-S3

If you live in Central Vietnam long enough, you learn one thing fast: the grid will blink when you least want it to. Most people buy a UPS for their router and call it a day. I wanted to know, in real time, whether my house lost grid power, whether my local build machines were still breathing, and whether a CI run on my self-hosted Gitea server just broke, all without opening a browser tab.

Long story short, I ended up building a small power-cut-resilient home and CI HUD out of an ESP32-S3, a few spare Android phones, a ZeroTier mesh, and a single Bun + SQLite server running in Vietnam.

The problem with normal home dashboards

Like everyone else who plays with homelabs, I started years ago with Home Assistant, Grafana, Docker stacks, and a pile of YAML files. They look great in screenshots. Then the power goes out at your house, your local server dies with it, and the dashboard that is supposed to tell you the power is out is... also dead.

Even when the power stays on, I don't want to keep five browser tabs open just to check if a Mac mini runner dropped off the network or if a production deploy failed. I wanted a tiny physical screen sitting on my desk that updates itself over a persistent socket, backed by an out-of-band hub running outside the house.

How the setup works (the 30-second version)

If you strip away the jargon, the trick is straightforward: keep the monitoring brain outside the house, and let battery-powered phones inside the house act as witnesses when the wall power cuts out.

1. AT HOME IN HOI AN Home Computers Ubuntu PC, Mac mini, MacBook Wall power: go silent if grid drops Spare Android Phones vivo X70 Pro+, TCL, mini phone Built-in battery: report power cuts, run CI jobs & act as home cameras Desk Screen (ESP32-S3) Small battery / UPS backup Live status grid + build alerts 2. OUTSIDE THE HOUSE Always-On Hub Small Vietnam VPS (Bun + SQLite) Stays online when Hoi An goes dark. Spots power cuts & failed deploys Code & Build Server Self-hosted Gitea VPS Sends pass/fail build alerts straight to the Hub 3. WHAT I ACTUALLY SEE One-Screen Web UI All 12 devices, battery levels, camera feeds & live build log Check from laptop or phone Glanceable Desk Alerts Green tiles = everything healthy Red tile / banner = power cut or broken build, zero tabs open heartbeats live push SSE
Simplified view of the setup: wall-powered machines and battery-backed spare phones check in with a small server outside the house, which pushes live status back to the web dashboard and desk HUD.

The hardware on the desk (and giving older devices a second life)

Nothing fancy here, mostly stuff I already had lying around plus one cheap Espressif board:

  • ESP32-S3 (on UPS): Dual-core Xtensa LX7 at 240 MHz, 8 MB PSRAM, 16 MB Flash. Running custom Rust firmware built on ESP-IDF v5.2.3. It holds a persistent TLS WebSocket (wss://) to the remote hub and renders status banners and alerts directly on its screen.
  • UPS Canaries & Spare Phones (vivo X70 Pro+, TCL 60 NXTPAPER, and a Magisk-rooted mini Android phone): Why old Android phones? Because a phone already has a built-in battery, Wi-Fi, cellular fallback, charging-state telemetry, a camera, and ADB over USB. When grid power drops, wall-powered nodes go quiet while the battery-backed phones immediately report discharging state to the hub. Instant power-cut correlation with zero extra AC relay wiring.
  • Local fleet: An Ubuntu i7 workstation (dmz002, 32 GB RAM) running the host telemetry agent and ADB bridge, a Mac mini M4 (dmz003) handling heavy CI runs, and my MacBook Air M2.
  • Remote servers: A Hetzner VPS hosting Gitea 28.3.0 and CI runners, plus a Vietnam VPS (4 vCPU, 6 GB RAM, Ubuntu 24.04) running the out-of-band hub so it stays online even when Hoi An goes dark.
Desk hardware setup showing the ESP32-S3 HUD, a mini keypad Android phone, and a vivo X70 Pro+ with vertical screen lines running as a home node
The desk line-up: the ESP32-S3 HUD on the left, the rooted mini phone in front, and a vivo X70 Pro+ with a broken screen that still pulls serious weight.

Take that vivo X70 Pro+ in the photo above. Its OLED screen has vertical lines running down it, so nobody would carry it in a pocket anymore. Under the glass, though, it is still a flagship Snapdragon phone with 12 GB of RAM and 256 GB of storage. Plugged in on the desk, it runs CI jobs and background workloads without breaking a sweat, and its Zeiss camera doubles as an excellent home surveillance feed whenever I want to check on the place remotely.

Honestly, my favourite part of this whole project is being able to utilise these older devices and give them a real new purpose instead of letting them collect dust in a drawer. Between a few retired phones, a Mac mini, and a couple of cheap VPS boxes, I get a resilient home lab and CI pipeline without spending a ton on cloud infrastructure anymore.

Why Bun, Hono, SQLite and vanilla JS

I kept the hub stack deliberately boring, following the same 1995 web primitives idea I wrote about last month.

The entire hub runs as one Bun process: Hono for routing, server-rendered hono/jsx, SQLite in WAL mode for telemetry storage, and pure uncompiled vanilla CSS + JS on the frontend with native EventSource SSE for live updates. Zero React, zero Webpack, zero container orchestration. Memory footprint stays tiny, deploys take seconds, and Caddy sits in front with Basic Auth for the web UI while machine endpoints (/api/ingest, /api/webhooks/gitea, /ws/device) use token and HMAC-SHA256 auth.

Three tabs cover everything I actually look at:

  1. Home Power & Infra HUD: Host heartbeats, battery/UPS canary state, camera snapshots, and a one-click push endpoint (/api/esp32/push) to send alerts straight to the ESP32-S3 screen.
  2. ZeroTier Mesh: Pulls Central API state plus local port :9993 peer status so I can see right away if a link fell back from DIRECT P2P to RELAY and what the RTT looks like.
  3. Gitea CI Activity: Combines live HMAC-verified Gitea webhooks with a 45-second read-only API poller, so a red build shows up on the desk HUD within seconds.
AIoT Hub web dashboard showing VPS nodes, local workstations, Android UPS canary phones, ESP32 devices, and live Gitea CI events
The out-of-band AIoT Hub web UI: remote VPS nodes, local build machines, Android UPS canaries, ESP32 telemetry, and live Gitea CI events in one screen.

The surprising part: Rust firmware with AI in the loop

A couple of years ago, writing stable TLS WebSocket firmware in Rust on ESP-IDF v5.2.3 alongside a Bun backend and a Magisk Android boot agent would have eaten three weeks of evenings. With AI coding agents helping across the firmware, the host agent, and the Hono server, the whole loop came together in a fraction of that time.

Having said that, AI still cannot plug in a USB-JTAG cable or tell you why your mini phone dropped off port 1-5.2 when you bumped the hub. You still need to read the serial monitor at 115200 baud, verify the memory budget on the 8 MB PSRAM chip, and test an actual breaker pull at home. The hardware keeps you honest.

Next up, I want to add a few more ESP32 gadgets around the house in Hoi An, starting with humidity and power-draw sensors feeding into the same hub. If anyone else is running Rust on ESP32-S3 for desk HUDs or repurposing old Android phones for homelab monitoring, I'd love to compare notes.