Raspberry wifi auto reconnect when possible

Raspberry wifi auto reconnect when possible

I am regularly loosing the WiFi connection with as only solutions:
1. Reboot the system
or
2. Unplug and plug the WiFi dongle
All attempts to put the wlan0 interface down and up doesn’t solve the problem

Is it a way to ensure the WiFi reconfigure it-self if the WiFi signal was lost for a while?
Thanks in advance
Robert

Here some configuration details

[17:02:41] openhabian@HA_Broker2:~$ cat /etc/debian_version
9.9

[17:04:27] openhabian@HA_Broker2:~$ /opt/vc/bin/vcgencmd version
Mar 27 2019 15:46:32
Copyright (c) 2012 Broadcom
version 2e98b31d18547962e564bdf88e57b3df7085c29b (clean) (release) (start_cd)

[17:08:26] openhabian@HA_Broker2:~$ cat /sys/firmware/devicetree/base/model
Raspberry Pi 2 Model B Rev 1.1[17:09:22] openhabian@HA_Broker2:~$

[17:11:15] openhabian@HA_Broker2:~$ lsusb
Bus 001 Device 007: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 004: ID 07ab:fc88 Freecom Technologies
Bus 001 Device 006: ID 6901:2701
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

[17:13:51] openhabian@HA_Broker2:~$ ifconfig
eth0: flags=4099 mtu 1500
ether b8:27:eb:c2:ff:6d txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 28712 bytes 4663517 (4.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28712 bytes 4663517 (4.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163 mtu 1500
inet 192.168.0.252 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::4e51:3708:f1ac:98b prefixlen 64 scopeid 0x20
inet6 2a02:1811:437:e700:7101:11cb:e58d:303d prefixlen 64 scopeid 0x0
ether 1c:bf:ce:3c:dd:03 txqueuelen 1000 (Ethernet)
RX packets 883 bytes 143781 (140.4 KiB)
RX errors 0 dropped 81 overruns 0 frame 0
TX packets 341 bytes 58722 (57.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[17:16:48] openhabian@HA_Broker2:~$ sudo more /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=BE
network= ssid=»HomeT»
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=»xxxxxx»
>

Re: How to auto reconnect wifi after signal lost

Re: How to auto reconnect wifi after signal lost

There is no problem with the power supply, (5V 2Amps, most of the time without display and keyboard, but well with USB disk) the system is still running without log message even when the WLAN is down
The command I am using to restart it is:
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up

Next time I will try
sudo service dhcpcd restart
sudo systemctl daemon-reload

Читайте также:  Угадать пароль от вай фай

In fact the WLAN connection is well automatically restarted after SSID disconnection , so it looks that the interface driver is dead from time to time

The frequency is once or twice per week.
I have a similar dongle running on a debian system (see below) without problem.

Re: How to auto reconnect wifi after signal lost

These ifconfig commands should reactivate dhcpcd, I don’t think restarting it will change anything, neither would reloading systemd.

If the combined power to be sent to the USB devices is too high the adapter might stop working. When I want to be sure there is no problem with a PSU I try switching to another one.
If the USB gets disconnected due to lack of power, I think there should be a USB related message in syslog, or perhaps dmesg.
A driver problem for that specific WiFi adapter is a possibility.

To be clear, in normal conditions a WiFi client will reconnect automatically. This is the default behavior.

Re: How to auto reconnect wifi after signal lost

After reading a lot of comments regarding this issue, I can’t find a solution.

Trying to simulate the problem I did the following:
1. Verify WLAN after boot
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4163 mtu 1500
inet 192.168.0.253 netmask 255.255.255.0 broadcast 192.168.0.255
.
2. shutting down WLAN
pi@HABroker1:~ $ sudo ifconfig wlan0 down
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4098 mtu 1500
ether 00:1d:43:30:27:8d txqueuelen 1000 (Ethernet)
.
3. Starting WLAN
pi@HABroker1:~ $ sudo ifconfig wlan0 up
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4099 mtu 1500
ether 00:1d:43:30:27:8d txqueuelen 1000 (Ethernet)
.
4. looking at WAP_CLI
pi@HABroker1:~ $ wpa_cli
wpa_cli v2.8-devel
Copyright (c) 2004-2019, Jouni Malinen and contributors
.

CTRL-EVENT-SCAN-STARTED
CTRL-EVENT-SCAN-RESULTS
WPS-AP-AVAILABLE
Trying to associate with 38:43:7d:3f:3f:d5 (SSID=’HomeT’ freq=2437 MHz)
Association request to the driver failed

All attempt to restart DHCP o the wpa_supplicant don’t solve the issue, ONLY a Reboot helps.
Why si the driver not responding?

Example:
sudo wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
Successfully initialized wpa_supplicant
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: Trying to associate with 38:43:7d:3f:3f:d5 (SSID=’HomeT’ freq=2437 MHz)
wlan0: Association request to the driver failed

Any Idea how to restart the interface with the SSID (38:43:7d:3f:3f:d5is the MAC address of my Access Point)
Thanks in advance
Robert

neilgl Posts: 6195 Joined: Sun Jan 26, 2014 8:36 pm Location: Near The National Museum of Computing

Re: How to auto reconnect wifi after signal lost

What WiFi dongle are you using on that Pi2? — my WIfi dongle works fine (Ralink Technology, Corp. RT5370 Wireless Adapter) on a pi2.
If you have time, I would backup your openhab, then install standard Raspbian on a separate SD card, check wireless, then install openhab2 and restore the backup.

Re: How to auto reconnect wifi after signal lost

I did start from a clean installation of NOOBS 3_2_1 lite with same problem.
Wlan stops to work after a random number of days without a way to just reset the interface.
A Reboot is the only solution
The WiFi adapter I am using is a :
Ralink Technology, Corp. MT7601U Wireless Adapter
I have the same issue with a :
Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Читайте также:  Hvostyilapki wi fi ru hvostyilapki

There is a lot of discussions about this issue, which looks to be related to a new Broadcom driver, unfortunately I could not find the way to fix it
An I hope there is one because I can’t work with a such unstable Raspberry

uname -a
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux

cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 1
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 2
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 3
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

Hardware : BCM2835
Revision : a01041
Serial : 00000000a5c2ff6d
Model : Raspberry Pi 2 Model B Rev 1.1

lsusb
Bus 001 Device 005: ID 07ab:fc88 Freecom Technologies
Bus 001 Device 007: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 006: ID 6901:2701
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hu

Re: How to auto reconnect wifi after signal lost

OK last feedback after long debugging sessions.
After changing the power supply and the cables, the situation is now becoming stable.
I am currently waiting for a new set of cables to determine if the problem was the cables or the power supply.
So I must admit that the first reply was right and that this is nothing to do with the WIFI driver or the software.
Robert

amcdonley Posts: 207 Joined: Mon Jan 26, 2015 5:56 pm Location: Florida, USA

Dongle not reachable, WiFi looks fine — was: How to auto reconnect wifi after signal lost

I have similar issue — WiFi Dongle address stops responding (ssh pi@X.0.0.X .. Host is down)
and when I connect with WiFi built-in address X.0.0.Y, everything looks fine in ifconfig — up, no RX or TX errors.

I’m wondering if the issue might be in my WiFi router (Xfinity SCIENTIFIC ATLANTA DPC3941T), not the dongle.

pi@Carl:~/Carl $ packet_write_poll: Connection to X.0.0.X port 22: Host is down Mac$ ssh pi@X.0.0.X ssh: connect to host X.0.0.X port 22: Host is down Mac$ ssh pi@X.0.0.Y pi@X.0.0.Y's password: Linux Carl 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sat Jan 18 00:44:42 2020 from X.0.0.Z pi@Carl:~ $ ifconfig eth0: flags=4099 mtu 1500 ether b8. 86 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 3112 bytes 186720 (182.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3112 bytes 186720 (182.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163 mtu 1500 inet X.0.0.X netmask 255.255.255.0 broadcast X.0.0.255 inet6 fe80. 1 prefixlen 64 scopeid 0x20 inet6 26..ff prefixlen 128 scopeid 0x0 ether b4..b txqueuelen 1000 (Ethernet) RX packets 2173 bytes 907969974 (865.9 MiB) RX errors 0 dropped 258 overruns 0 frame 0 TX packets 3675 bytes 106031839 (101.1 MiB) TX errors 0 dropped 6 overruns 0 carrier 0 collisions 0 wlan1: flags=4163 mtu 1500 inet X.0.0.Y netmask 255.255.255.0 broadcast X.0.0.255 inet6 26. 9a prefixlen 128 scopeid 0x0 inet6 fe8. ce5 prefixlen 64 scopeid 0x20 inet6 26. aa prefixlen 64 scopeid 0x0 ether b8. d3 txqueuelen 1000 (Ethernet) RX packets 245090 bytes 26383152 (25.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1873 bytes 403869 (394.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 pi@Carl:~ $ 

Источник

Читайте также:  Вай фай инфо нет

Raspberry wifi auto reconnect when possible

I have found with experience that in spite of my best intentions, sometimes when setting up a Raspberry Pi to maintain a WiFi connection, if it disconnects for whatever reason it may not reconnect automatically.

To solve this problem we’re going to write a short script that automatically reconnects our Pi to a WiFi network. The script will check to see if the Pi is connected to our local network and, if it’s off-line, will restart the wireless network interface. We’ll use a cron job to schedule the execution of this script at a regular interval.

Let’s write a script

First, we’ll need to check if the Pi is connected to the network. This is where we’ll try to ping an IP address on our local network (perhaps our gateway address?). If the ping command succeeds in getting a response from the IP address, we have network connectivity. If the command fails, we’ll turn off our wireless interface (wlan1) and then turn it back on (yes, the timeless solution of turning it off and on).

#!/bin/bash # The IP address of our gateway on our local router GATEWAY=10.1.1.1 # Send two pings, with the output going to /dev/null ping -c2 $GATEWAY> > /dev/null # Check to see if the returned value from ping ($?) # is not 0 and then act to restart wlan1 if necessary if [ $? == 0 ] then # Restart wlan1 (the wireless interface) ifconfig wlan1 down ifconfig wlan1 up fi 
sudo nano /usr/local/bin/wifistart.sh
sudo chmod +x /usr/local/bin/wifistart.sh

Источник

Оцените статью
Adblock
detector