To totally unlock this section you need to Log-in
The following small article will show how to prevent, also after a reboot, to have the WiFi connection in sleeping mode after a while on Raspberry Pi 4. This is quite useful if you establish, for example, a server role on Raspberry Pi 4 and the only connection used, in a LAN environment, is by using WiFi technology and not wired Ethernet.
To prevent Wifi to go on sleeping mode on a Raspberry Pi 4 we can just issue the following command (if our WiFi network module is seen in Linux as wlan0, and usually it will be wlan0 if you will use the embedded module on the device), but take not that :
|iwconfig wlan0 power off|
To be sure that, after each reboot of the Raspberry Pi, it will does not let WiFi module to go on sleep after a while, we can modify the /etc/rc.local file (with root access or by using sudo) in the following way (basically adding the above command in the last part of the file):
| # sudo nano /etc/rc.local|
# Print the IP address
After saving this small change, we can reboot the device to check the Power Management status will be to off by using iwconfig command:
| # iwconfig|
wlan0 IEEE 802.11 ESSID:"Flag5"
Check the connection info
When you have the WiFi up and running, what are the output of iw wlan0 link and iw wlan0 station dump? Then once the wifi is lost, what are the output of both commands?
And once you have lost wifi, are you still able to view your wifi network?
|sudo iw wlan0 scan | less|
Run the above on your RPi when it has lost the connection, and see in the output (might take several seconds to be displayed) if there is your wifi network name.