Pi 0 W dropping wifi

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.log

I 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.

Reply to
Adam Funk
Loading thread data ...

Same here, I've always had this problem with my Zero based webcams. Tried the same things you did. I have given up, reliable webcams are not possible with Raspberry Pi on wifi, as far as I am concerned. I asked a few times on the official forums but it always gets dismissed as "it works for me, i've never seen that" etc.

Reply to
A. Dumas

I wrote about 6months back about minimising SDcard wear when leaving a Pi Zero W running 24/7. The Pi provides SSH access to my network from the internet.

I mount all the logs etc. on /tmp to reduce SDcard wear and then to stop /tmp filling up I take the simple but drastic fix of rebooting every

24hrs. There are better ways but for what this is used for, a gateway, it works fine.

In those 6 months with a reboot every day the Wifi stays working and I've never had a problem with Wifi connections failing or failing to come up. This may be a less than perfect solution but should keep you from having to intervene manually as long as you can accept the time it takes to reboot in your logging. You could adjust the reboot time to be now plus 24h 1m so the reboot time is different each day.

Not a fix but something to reduce your hassle.

Reply to
mm0fmf

Funny enough, I just thought of something like that (posted a few minutes ago). I'd probably set the reboot time to be the same every day and while I'm asleep.

(I haven't had any problems with wired network connections on Pi 2B or Pi 4 models, but I haven't tried wifi on either.)

Reply to
Adam Funk

My Pi Zero W says on logging onto it via wifi that its been up 26 days and so has the wifi

It may be actually a router or wifi point issue.

For sure the Pi is capable or maintaining a connection but I am not sure it is capable or resetting one on loss of signal.

Im running mine about *3 feet* through a wall to a Netgear router re-configured as an ethernet to wifi bridge. before that I did have problems with the pi going off line and it might have needed a reboot

This is the iwconfig for what is now reliable

$ iwconfig wlan0 wlan0 IEEE 802.11 ESSID:"xxxxxxx" Mode:Managed Frequency:2.457 GHz Access Point:

30:46:9A:A2:89:F6 Bit Rate=65 Mb/s Tx-Power=31 dBm Retry short limit:7 RTS thr:off Fragment thr:off Power Management:on Link Quality=44/70 Signal level=-66 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:5 Invalid misc:0 Missed beacon:0
--
Future generations will wonder in bemused amazement that the early  
twenty-first century?s developed world went into hysterical panic over a  
globally average temperature increase of a few tenths of a degree, and,  
on the basis of gross exaggerations of highly uncertain computer  
projections combined into implausible chains of inference, proceeded to  
contemplate a rollback of the industrial age. 

Richard Lindzen
Reply to
The Natural Philosopher

If the Pi doesn't have a fixed IP address assigned to it, then I'd try that in case it's a problem with DHCP.

Failing that, perhaps you could try unloading then reloading the WiFi driver module occasionally, between toggling the interface down/up.

--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev

Any idea why it can't? (Everything else does!)

That's curious, because one of the most common suggestions I found was to disable power management (and it seemed to work for a few months).

Reply to
Adam Funk

Those are pretty inaccurate, I'd recommend using a HTU21DF instead. It's I2C so plenty of libraries available and no timing issues.

How old is the disc image? I had similar problems with a couple of my first Pi Zero W's but not newer ones, despite having done regular updates to all of them. I created new Raspbian lite images for them, and they've worked perfectly since.

The only discernable difference was the ones which would drop WiFi showed failures of snipped-for-privacy@wlan0.service (systemctl --failed) even just after booting, and the new images don't. I think there must have been some configuration difference between them, but I couldn't find it in any of the obvious places in /etc

---druck

Reply to
druck

Worth trying --- until recently I thought the DHCP by MAC on the router was good enough! I'll have to remember how to remove that on the router though.

So something like this in the wifibump script?

/sbin/ip link set wlan0 down modprobe -r brcmfmac sleep 5 modprobe brcmfmac /sbin/ip link set wlan0 up

--
There?s never enough time to do all the nothing you want. 
                                                ---Calvin
Reply to
Adam Funk

I don't think you should need to actually, just don't run the DHCP client on the Pi and set the IP address manually instead.

Yes, though if this is the same problem that you're having then apparantly reloading the driver module doesn't work every time:

formatting link

--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev

That works for me - I've done this on both RPi and my Fedora systems on my house LAN, which all have fixed IP addresses and hostnames.

/etc/hostname contains one line holding the fully qualified hostname as it will be used locally, e.g.: rpi.local.lan

/etc/hosts contains at least: IP-address fully-qualified-hostname list of aliases, e.g

192.168.5.2 rpi.local.lan rpi

In addition you can add other lines containing the IP, fqn aliases etc. of printers, ADSL gateway, etc which have fixed IPs on your LAN. If all hosts on your LAN have fixed IPs and hostnames then you don't need to run a name service (e.g. named/unbound or DHCP server), and you can still run dhcp if sone devices on your LAN can't be configured to use a fixed IP address and host name.

--
--   
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Or he could configure DHCP server to give "static" fixed IPs to fixed MAC.

Reply to
Nikolaj Lazic

Yeah. That's 1000x easier & more convenient & thus less error-prone.

Reply to
A. Dumas

Reading that I thought "ugh, a systemd timer, I'd put it in crontab" ... then spotted this dig which some here will appreciate:

Yes, with systemd you actually need two files where "cron" can do this in a single line. Don't know why people keep pretending that systemd is so much better.

--
I heard that Hans Christian Andersen lifted the title for "The Little 
Mermaid" off a Red Lobster Menu.                       ---Bucky Katt
Reply to
Adam Funk

That's what I was doing (DHCP "reservation" on the router). I'm now trying a static IP address in the /etc/dhcpcd.conf file on the Pi Zero.

--
You're the last hope for vaudeville. 
                 ---Groucho Marx to Alice Cooper
Reply to
Adam Funk

/etc/dhcpcd.conf I have static address - it doesn't affect 'drop outs' though

/etc/dhcpcd.conf :

interface wlan0 static ip_address=192.168.0.200 static routers=192.168.0.254 static domain_name_servers=192.168.0.100

/etc/wpa_supplicant/wpa_supplicant.conf :

country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1

network={ ssid="LivingRoom" psk="SECRET.SQUIRREL" key_mgmt=WPA-PSK }

--
To ban Christmas, simply give turkeys the vote.
Reply to
The Natural Philosopher

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.