smilliken
Posts: 32
Joined: Fri Feb 06, 2015 4:04 am
Location: Beautiful BC

Force Network to Rejoin Network

Tue Sep 19, 2023 12:02 am

I have a DAKBoard which I created with the Raspberry Pi Imager. It sits in a room not 20 feet from one of the Wi-Fi Access Points in the house. Every so often, nothing time specific, the Raspberry Pi Zero 2W stops connecting with the Wi-Fi system. The system locks up and is nonresponsive. I have a dongle and a small hand held keyboard attached and can't seem to get to a command prompt to attempt to get the Wi-Fi operational again. I end up having to reboot to get the Pi to rejoin the network. I've placed the IP Address on the static list.

Is there something that I can do to have the Pi attempt to rejoin the network behind the scene?

Thanks

Scott
Raspberry Pi 7" Raspberry Pi Touchscreen x 2
Raspberry Pi 3's, PiPhat, Pi Zero W, Pi Zero 2 W
Raspberry Pi 4, 4 GB, 8GB

pcmanbob
Posts: 13702
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Force Network to Rejoin Network

Tue Sep 26, 2023 8:11 am

So is it just a loss of wifi or is the OS crashing ?

if you can't get a command prompt , I assume you have a screen connected, it sounds more like the OS has crashed.

You could try this short script that is a variation of the script use to keep my pi zero W connected to my wifi network.

Code: Select all

#!/bin/bash

# keep wifi alive

ping -c2 192.168.1.1 # change IP to match your routers IP

 
if [ $? != 0 ] 
then 
  echo " "
  echo "No network connection, restarting wlan0"
  
  sudo ifconfig wlan0 down
  sleep 30
  sudo ifconfig wlan0 up
  
else
    echo " "
    
fi

just call it with cron every few minutes, but I would not call it more than once every 2 min.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Networking and servers”