0

I am having a problem on my RPi2 (running Raspbian 7 wheezy) and the CanaKit wifi adapter (RT5370 chipset). Currently, I have a script running at startup which sends sensor information to a server. The problem is, after 30 minutes, the wifi adapter turns off (the blue signal light on the adapter turns off and I can no longer ping the pi), and the script exits because it can't send data.

I've searched the forums so far, and have tried a number of things. I tested to see if it was related to the display on the pi turning off, but that happens after 10 minutes rather than 30. I have tried adding "wireless-power off" to /etc/network/interfaces to disable power saver settings. I've tried running the pi with having just the adapter and power plugged in and nothing else, to make sure that it wasn't because the pi couldn't supply enough power to the adapter. I don't think the problem is because of power saving; I wouldn't think that it would turn off as long as the adapter is being used, but I could be wrong. A lot of similar forum answers I've seen have been for disabling power saving on the 8192cu, which I don't have. Everything works fine when I use ethernet, but I need for this project to be as compact as possible, so ethernet isn't really an option.

I know there are a few scripts available to automatically turn the wifi on again if it shuts down, however, once the wifi turns off, my script exits, and I need it to constantly be running.

Thank you to any answers that come in!

0

The Pi 0 I refer to in this answer is using that exact same Canakit wifi dongle -- I do not think there are any problems with the linux driver for it and I would recommend Ralink RT5370 based adapters to Pi users. I've used them for two or three years. I do not disble power saving. That pi's been online unsupervised for more than a month now and has reconnected 5 times (one of which was initiated by me remotely to tweak something). It doesn't use much bandwidth, but gets polled remotely by a server for data every 15 minutes -- plus occasionally more frequent polling if someone accesses it via a web interface, and my occasional visits via ssh.

It's on a decent 5V 2.5 A supply which it shares with an Arduino nano (via the 5V rail) and some sensors, plus the wifi dongle.

I know there are a few scripts available to automatically turn the wifi on again if it shuts down, however, once the wifi turns off, my script exits, and I need it to constantly be running.

Of course it is impossible to say why that might be without looking at the script.

In addition to the infinite wifi reconnect script, I use a further paranoid script that intermittently checks that certain vital services are running. Probably the most foolproof way to do that is via cron. It uses

if [ -z "$(ps -o pid= -C $service)" ]; then

Where in this case $service is one of sshd, openvpn, and network-dual (the wifi monitoring script). If they are not, it restarts the systemd service responsible for them. In some cases I think systemd does this anyway, which is part of why it's paranoid, but might be worthwhile until you debug your wifi script.

The reason to use ps -o pid= -C instead of pidof is that the latter applies to the name of executables, which in in the case of shell scripts is usually bash. But ps -C applies to the command used to invoke the process -- e.g. network-dual is a symlink to a .sh file. The -o pid= ensures it produces no output if no such process is running (if you read man ps there's a subtlety in the =).

running Raspbian 7 wheezy

I would recommend an upgrade to 8 jessie.

  • Thanks! I'll try the script and am upgrading to Jessie now. I might also be able to alter my current script so that it doesn't break on wifi drop and tries to reconnect instead. Was wondering if there was an easier fix that wouldn't require the script to pause and reconnect, but, gotta do what you gotta do. Anyway, thanks again! – Rob Mar 16 '17 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.