DEV Community

Cover image for ESP32-P4 boot loop (CHIP_LP_WDT_RESET): building a homelab watchdog in ESPHome
Christian Anderson
Christian Anderson

Posted on

ESP32-P4 boot loop (CHIP_LP_WDT_RESET): building a homelab watchdog in ESPHome

My homelab's monitoring has a daft weak spot. Uptime Kuma runs on my NAS. So if the NAS goes down, the thing that's meant to tell me the NAS is down goes with it. I've got a script on another box that restarts Kuma if it dies, but that's still the homelab watching itself.

So I bought a Waveshare ESP32-P4-ETH. Wired Ethernet, can run off PoE, no WiFi at all. My first idea was to move Uptime Kuma onto it. That was never happening, it's a microcontroller, not a Linux box. So on 13 October 2026 I settled on something it can actually do: be a small, dumb, independent watchdog that doesn't rely on any of my servers to send an alert.

What it does

The watchdog board checks 10 targets every 60 seconds and alerts Discord directly, pushes to Uptime Kuma, and pings an off-site dead-man switch

  • Every 60 seconds it checks 10 things: Uptime Kuma, SSH on the NAS, the reverse proxy, both Proxmox nodes, my agent box, Vaultwarden, the router's web page, AdGuard DNS, and the internet (1.1.1.1:443).
  • Most of those are just a TCP connect. DNS is a proper one: it builds a real A-record query for cloudflare.com by hand and sends it straight at AdGuard, then checks the answer has the right ID, no error and at least one record. An open port doesn't mean DNS is working.
  • 3 failures in a row and it posts 🔴 DOWN to Discord, straight from the board. The first good check after that posts 🟢 RECOVERED with how many minutes it was down. Three strikes stops one dropped packet waking me up.
  • If it can't send (say the internet's gone), the alert goes in a queue. It keeps the newest 20 and retries every cycle.
  • Every cycle it also pushes to an Uptime Kuma push monitor with a 120 second heartbeat. So Kuma watches the board while the board watches Kuma. If either dies, the other one says so.
  • All the checks run in their own FreeRTOS task, so a target that hangs on connect never blocks the rest of the board.

I wrote it as ESPHome YAML plus one C++ header. ESPHome gives me OTA updates, a web page and the Ethernet setup for free, and the header does the actual checking.

Compile trap: socket() is ambiguous

First compile failed on something stupid. ESPHome has its own esphome::socket namespace, so a bare socket() call inside my code was ambiguous. You have to use the global ones: ::socket, ::connect, ::close and so on.

After that it compiled clean. RAM 13.5%, flash 695 KB. Tiny.

The boot loop

I flashed it from my Mac late on 13 October and it went straight into a boot loop. Reset every 3.2 seconds or so, no app log at all, just this:

rst:0x10 (CHIP_LP_WDT_RESET)
Enter fullscreen mode Exit fullscreen mode

No app log means it's dying before my code even runs, so it wasn't my watchdog code. It was the build.

I'd copied board: esp32-p4-evboard because that's what you'd reach for. Turns out in ESPHome that board means the engineering sample P4, the pre-production chips before revision 3. My board has a production chip, revision v3.2. So the firmware was built for the wrong silicon, and the chip's low-power watchdog reset it every few seconds.

The fix was to stop naming a board at all and just tell ESPHome the chip:

esp32:
  variant: esp32p4
  engineering_sample: false
  cpu_frequency: 360MHZ   # 400MHz on the P4 is marked experimental in ESPHome
  flash_size: 16MB
  framework:
    type: esp-idf
Enter fullscreen mode Exit fullscreen mode

That set the minimum chip revision to 3.1 in the build config, and it booted fine. If you've got a P4 board in a boot loop with CHIP_LP_WDT_RESET and no log, check you're not building for the engineering sample.

The first live flash sent nothing anywhere

On 15 October it went on the network for real. Kuma push: 404. Discord: 400. The OTA password was, word for word, REPLACE-with-a-long-random-string.

Yeah. The first flash had used the example secrets file with the placeholders still in. Nothing was broken, it just had nothing real to talk to. I rebuilt with proper secrets and pushed it over OTA, then checked the old placeholder password got rejected and the new one got accepted. One false "heartbeat DOWN" from Kuma went out while the old firmware was still running, which fair enough, it wasn't sending real heartbeats.

While I'm on secrets: esphome config prints your Discord webhook in full, because it ends up inside a lambda. Don't paste that output anywhere.

Two false alarms that were actually right

Once it was talking, it straight away said two things were DOWN: SSH on the NAS and the router's web page. Both were fine from my laptop.

The board was right though. I'd plugged it into a router port that's on my IoT VLAN, so it got an IoT address. And my IoT VLAN isn't allowed to reach NAS SSH or the router's admin page. That's the firewall doing its job.

I moved that router port over to the main LAN, bounced the port so it asked for a new address, and it picked up its reserved one. 10 out of 10 up, and it posted RECOVERED for both. Kuma's ping monitor for it went green too.

Worth saying: a watchdog that sits on a different network from the thing it watches is testing the firewall, not the service. Put it where your users are.

What I added after

  • A password on its web page. sieve, my own vulnerability scanner, flagged the open web UI, so it's behind a login now.
  • An off-site dead-man switch. The board can tell me a server is down, but if the power goes or the internet drops, nothing at home can tell me anything. So I've got a free Cloudflare Worker that expects check-ins and posts to Discord if they stop for 5 minutes. Two of my servers already pinged it every minute, and since 16 October the watchdog does too, every cycle. That one's got its own story (the cron trigger didn't fire at first), I'll write it up separately.

How it's doing

This is the board's own state, read off its web page on 18 October 2026:

The watchdog's live state: 0 targets down, 0 alerts waiting, 2061 check cycles, uptime 123665 seconds, all 10 targets up

2,061 check cycles, about 34 hours since its last restart, nothing down, nothing stuck in the queue. Not much to look at, which is the point.

If you're building one

  • On a production ESP32-P4, use variant: esp32p4 and engineering_sample: false, not the evboard.
  • In ESPHome C++ code, call ::socket and friends with the :: in front.
  • Check something real for DNS, not just the port.
  • Put the board on the same network as whoever uses the services, or you're testing the firewall.
  • Have something off-site for the power cut case, because the board goes off with everything else.

What watches your monitoring? I genuinely didn't have an answer to that until this month.


🤖 Drafted with AI assistance from my own homelab notes, logs and repos, and fact-checked against them before publishing.

Top comments (0)