Python implements the example code of Raspberry Pi WiFi disconnection automatic reconnection, pythonwifi
Enable Automatic reconnection of Wi-Fi disconnection. The principle is to use Python to monitor whether the network is disconnected. If the network is disconnected, restart the network service.
1. Put the Python code autowifi. py in the/home/pi directory:
#! /Usr/bin/pythonimportos, time whileTrue: if '20140901' not in OS. popen ('ifconfig | grep 192 '). read (): print '\ n ***** wifi is down, restart... * ***** \ n' OS. system ('sudo/etc/init. d/networking restart') time. sleep (5*60) #5 minutes
2. The Shell script autowifi. sh is also stored in the/home/pi directory:
#! /Bin/shpython/home/pi/autowifi. py &
3. Start the above script automatically at startup: execute the following command in the terminal window.
Sudocp-f/home/pi/autowifi. sh/etc/init. d/sudochmod + x/etc/init. d/autowifi. shsudochown root: root/etc/init. d/autowifi. shsudoupdate-rc.d autowifi. sh default
The above is a small series of Python Implementation of Raspberry Pi WiFi disconnection automatic reconnection, I hope to help you, if you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!