Postmortem: Why My Smart Toaster Almost Caught Fire
When building ToastOS, my goal was simple: mathematically achieve the ideal golden-brown crust on sourdough bread using closed-loop PID thermal control.
Here is what went wrong.
1. The Watchdog Failure
The ESP32 was connected via Wi-Fi to a local MQTT broker. In the FreeRTOS heating task, I had this naive logic:
void heating_task(void *pvParameters) {
while (heating_active) {
float temp = read_ir_temp();
if (temp >= TARGET_TEMP) {
gpio_set_level(SSR_PIN, 0); // Turn off
heating_active = false;
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}
When the home Wi-Fi briefly dropped to renew an IP lease, the MQTT logging function blocked on a synchronous reconnect loop inside the main thread. Because the watchdog timer wasn’t fed properly, the SSR pin remained energized in the HIGH state for 43 seconds longer than planned.
2. The Result
The sourdough bread did not brown. It underwent rapid thermal carbonization. Dense smoke filled the kitchen, activating the building’s central alarm at 7:15 AM on a Saturday.
3. Key Takeaway
Always put a hardware thermal fuse in series with software-controlled heating elements. Software will betray you; physics will not.