1.3 KiB
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
- Insufficient startup delay before WiFi initialization
- Watchdog timeout (60s) conflicting with WiFi connection timeout (60s)
- 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
- Add WiFi connection retry logic instead of panic on first failure
- Further increase watchdog timeout to 120s
- Reduce WiFi timeout to 30s with retry attempts
- Check WiFi module power supply stability