WiFi disappears after a day?

Yep, looks like the WiFi adapter has lost its IP address. Most likely the WiFi router dropped the connection at some point.

I’ve been running a RPi Zero W for a week on WiFi, hasn’t dropped yet on my network.

What make/model of router are you using? And, are you able to post its web interface logs for the last few days? May provide us with some answers :slight_smile:


I’ve made a script that will monitor WiFi connection every 20 seconds. If no ping is received, adapter is dropped and reinitialized.

  • Save script to /etc/dietpi/dietpi-wifi-monitor.sh
#!/bin/bash
{

URL_PING='www.google.com' #Ideally, change this to your routers IP address
ADAPTER='wlan0'
TICKRATE=20

while true
do

	/DietPi/dietpi/func/dietpi-notify 2 "Checking connnection for: $ADAPTER"
		ping -I $ADAPTER -c 1 $URL_PING
		if (( $? != 0 )); then

			/DietPi/dietpi/func/dietpi-notify 2 "Detected connection loss: $ADAPTER. Reconnecting"
			ifdown "$ADAPTER"
			sleep 1
			ifup "$ADAPTER"
			/DietPi/dietpi/func/dietpi-notify 0 'Completed'

		else

			/DietPi/dietpi/func/dietpi-notify 0 "Connection $ADAPTER"

		fi

		sleep $TICKRATE

	done

	exit 0

}
  • Enable execute:
chmod +x  /etc/dietpi/dietpi-wifi-monitor.sh
  • Install/Start service (copy + paste all):
cat << _EOF_ > /etc/systemd/system/dietpi-wifi-monitor.service
[Unit]
Description=Monitors loss of WiFi connection and automatically reconnects
After=network.target network-online.target

[Service]
Type=simple

ExecStart=/bin/bash -c /etc/dietpi/dietpi-wifi-monitor.sh

[Install]
WantedBy=multi-user.target
_EOF_
systemctl daemon-reload
systemctl enable dietpi-wifi-monitor.service
systemctl start dietpi-wifi-monitor.service
  • You can check status with:
systemctl status dietpi-wifi-monitor.service -l

I’ve tested the above with RPi Zero W, works a treat.

2 Likes