Hi,
I have a Pi Zero W stuck to the basement ceiling with a few simple low-power cron jobs:
- read the Tilt hydrometer (bluetooth low-energy beacon about 2 away)
- read a DHT-22 sensor (attached to the GPIO pins)
- email me a summary with plots of the Tilt data (nullmailer is installed and working)
- log the DHT-22 data to a REST API on another machine on the LAN
Every few days it disconnects from the wifi but keeps running (it accumulates Tilt and DHT-22 data, and the emails stay in the nullmailer queue). Because this Pi is headless, I have to cut the power off and on (at the switched socket) to reconnect it.
Stuff I have tried:
(item 1) sudo iwconfig wlan0 power off
(and that happens in crontab @reboot, and I've checked with iwconfig that it is set every time)
(item 2) cron this:
*/2 * * * * /bin/ping -c 2 -I wlan0 [routerIP] >/dev/null 2>>pinger.logI thought it was working for a while but it disconnected last night.
(item 3) I found a "wifi bump script" on the web that someone has used in cron(it used ifdown -a and ifup -a but those don't affect wlan0 on Pi OS now):
# Perform the network check and reset if necessary /bin/ping -c 2 -I $wlan $pingip > /dev/null 2> /dev/null if [ $? -ge 1 ] ; then logger -t wifibump "network is down" #/sbin/ifdown -a /sbin/ip link set wlan0 down sleep 5 #/sbin/ifup -a /sbin/ip link set wlan0 up else logger -t wifibump "network is up" fi
But I tested the commands with an at job as follows:
echo "down" /sbin/ip link set wlan0 down sleep 5 echo "up" /sbin/ip link set wlan0 up
The "down" worked; the "up" didn't produce any error output but it didn't work --- I had to reboot the Pi and the at output email came through afterwards.
Any suggestions?
Thanks.