How to add connection check to RPi3B+?

I’ve noticed that my wifi has sometimes connection issues and drops down, or I’m updating the firmware and have to reboot the router. If this happens, the RPi3B+ I use for running the ruuvicollector won’t reconnect unless I just power off and on.

Is there some script that could be added to the standard installation to detect if the network is down and force reconnection as needed?

Are you running “buster” or another version?

cat /etc/os-release|grep  PRETTY_NAME

Do you have syslog enabled?

vi /etc/syslog.conf

Do you see log entries like:

dhcpcd[315]: wlan0: carrier lost
dhcpcd[315]: deleting default route via
dhcpcd[315]: wlan0: carrier acquired
dhcpcd[315]: wlan0: rebinding lease of

Yes, the version string is “Raspbian GNU/Linux 10 (buster)”.

I don’t seem to have that logging enabled, the file is not found.

You should edit /etc/syslog.conf and add lines like -/var/log/daemon.log
local0.* -/var/log/local0.log

More details at

/etc/logrotate.conf defines how the files are archived and expired
for example:

{ rotate 9
maxsize 5M
notifempty compress delaycompress missingok create 0660 root staff
invoke-rc.d rsyslog rotate &>> /var/log/logrotate.rotate.log

More details at

After reviewing the documentation let me know if you need more help.

Are there any log messages from your router indicating. a problem?
Are you using a 2.4Ghz or 5Ghz
Use sudo iwconfig wlan0 to display information

Are you having any issues with any other devices near that same location?

The RPi seems to have lots of difficulties keeping the network connection open. Putty reports network closed error quite often and it’s a bit sluggish typing things on the terminal.

Could it be that the Wifi module is actually dying? Today I had one network disconnect in the RPi and it didn’t reconnect until I powered it off and on. I’m unable to do a sudo apt update to start updating packages, it seems to just timeout even if I’ve tried different servers in the config file.

All the other wireless device seem to work fine. It’s been connected to my 2.4GHz all the time I’ve used it. I actually thought it supported only that and not 5GHz. The router doesn’t show any errors in it’s logs.

pi@ruuvicollector:~ $ sudo apt update
Err:1 buster InRelease
  Connection failed [IP: 80]
Err:2 buster InRelease
  Connection failed [IP: 80]
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch  Connection failed [IP: 80]
W: Failed to fetch  Connection failed [IP: 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

I was now able to switch to 5GHz with raspi-config, and everything seems to work much better. Maybe the box is a bit flaky or something, if my 2.4GHz network didn’t work properly, I would have noticed it as most of my gear is using that.