Restart Wifi

The wifi connection on The Ubuntu MATE raspberry PI is rather buggy and tend sto loose connection once in a while. The easiest way to deal with it is this:

Install WICD

sudo apt install wicd

(Ubuntu previous to version 16.04 uses apt-get instead of apt)

start WICD and make a connection using WIFI to your router.

Then go to SYSTEM / preferences / Personal/ Startup

and disable the normal networkmanager.

Now reboot.

it should be more stable though WICD is more picky in relation to the sort of WPA mode. I needed to check in my router WPAmode: WPA + WPA2 Allthough all my other peripherals work fine with WPA2 CCMP which should be saver.

If you still get trouble of disconnecting the wireless connection read this post: Its about the way of pinging yoiur router every 5 minutes. If no connection is found, and automated proces restarts the PI or restarts the WIFI dongle.

This is a Copy of that article, written by Thijs Bernolet:

make an new file checkwifi.sh

Store this script in /usr/local/bin/checkwifi.sh.

Change the IP on the first line to the IP of your router, or some other device on your network that you can assume will be always online.

First step is to ping your IP.

On line three, the $? represents the exit code of the previous command, in this case the ping.

If it failed (not 0), the script assumes something's wrong with the wireless connection and just reboots.

Make sure the script has the correct permissions to run (thanks for the tip Jason Reibelt)

sudo chmod 775 /usr/local/bin/checkwifi.sh

crontab

SSH into the Raspberry Pi and open up the crontab editor by typingcrontab -e.

Add the following line:

*/5 * * * * /usr/bin/sudo -H /usr/local/bin/checkwifi.sh >> /dev/null 2>&1

This runs the script we wrote every 5 minutes as sudo (so you have permission to do the shutdown command), writing its output to /dev/null so it won't clog your syslog.

Done

Exit the crontab editor, reboot your Raspberry Pi (just to make sure) and from now on it'll reboot when it drops connection. Combine this withrunning your scripts on boot and you have a powerful, standalone system running.

Just restart network instead of reboot

Because many things could have gone wrong with a network loss and our application itself needs to adapt we prefer a full reboot. But after alot of people were shouting "that's just too much", you can also try to just restart the wireless connection: