jasbur/RaspiWiFi

Cannot connect to AP - pizero w 2

Closed this issue · 1 comments

After performing the installation and rebooting the pizero w 2. The AP constantly cycles. I can see the AP. You can connect for 5 seconds then the AP restarts and breaks the connection. This is a loop, you cannot stay connected.

I have tried it with all defaults, no password, no ssl... I have also tried it with 12 character ssid wpa password. Same results every time.

My issue was the pizero w2 would start the AP mode then it would dns blackhole itself with the /etc/dnsmasq.conf file. I wrote 2 scripts to resolve (band-aid fix) this issue. wifi_fix.py is run every startup. If the AP is in 10.0.0.1 mode it will leave it alone and quit the script. If it has a different IP range it will kick off the wifi_dns_fix.sh script. The wifi_dns_fix.sh script tries to ping google. If it can't it will move the dnsmasq.conf file to a backup location restart the dnsmasq service, after which it then restores the dnsmasq.conf file. Best of luck everyone, hope someone else finds this helpful. After adding these 2 scripts to my project, I've had zero issues for 3 months of daily operation.

wifi_fix.sh:
#!/bin/bash`
case $(ifconfig)
in
"inet 10.0.0.1")
echo $inet "IP found in 10 range for AP mode, leaving DNS alone"
;;
*)
echo $inet "Not in AP mode anymore, let's call the next script"
/bin/bash /home/pi/wifi_fix_dns.sh
;;
esac

wifi_fix_dns.sh:
if ping -c 1 google.com &> /dev/null
then
echo "It's working leave it alone"
else
echo "Time for us to fix some DNS"
sudo mv "/etc/dnsmasq.conf" "/etc/dnsmasq_backup.conf"
echo "backup that dnsmasq.conf file"
sudo /etc/init.d/dnsmasq restart
echo "restarting the dnsmasq service, yo"
sleep 2
sudo mv "/etc/dnsmasq_backup.conf" "/etc/dnsmasq.conf"
echo "put that backup back in place yall"
fi