balcony_weather_station/WIFI_FIX_NOTES.md

1.3 KiB

WiFi Initialization Fixes - 2026-01-18

Problem

Intermittent WiFi connection failures on Raspberry Pi Pico running node1.c

  • Error: "Failed to connect to WiFi"
  • Followed by panic: "WiFi initialization failed!"
  • Issue only occurred sometimes, not consistently

Root Causes

  1. Insufficient startup delay before WiFi initialization
  2. Watchdog timeout (60s) conflicting with WiFi connection timeout (60s)
  3. No retry logic if initial connection fails

Solution Applied

Modified node1.c main() function:

Change 1: Increase Watchdog Timeout

  • Line 157: watchdog_enable(60000, 1);watchdog_enable(90000, 1);
  • Changed from 60 seconds to 90 seconds
  • Prevents watchdog from triggering during WiFi connection attempts

Change 2: Increase Startup Delay

  • Line 158: sleep_ms(2000);sleep_ms(5000);
  • Changed from 2 seconds to 5 seconds
  • Gives WiFi module more time to power up before initialization

Testing

After rebuilding and flashing with these changes, test for stability over multiple boot cycles.

Next Steps if Still Unstable

  1. Add WiFi connection retry logic instead of panic on first failure
  2. Further increase watchdog timeout to 120s
  3. Reduce WiFi timeout to 30s with retry attempts
  4. Check WiFi module power supply stability