electronut Programming & Embedded Systems - by Mahesh Venkitachalam

Preventing Raspberry Pi WiFi from going into Sleep Mode

I keep logged into my Raspberry Pi from my Mac. The Pi is connected to my network using a USB WiFi adapter. But when I leave the login idle for a while, I find it to be (a) frozen and (b) I cannot login via a new ssh session - in fact, I can't even ping the Pi anymore.

I found the solution for problem (b) above in a StackOverflow post.

This is what you need to do:

sudo nano /etc/modprobe.d/8192cu.conf

Add the following:

# Disable power management
options 8192cu rtw_power_mgnt=0

Thanks to user Herohtar at SO - I tried this, and it seems to work very well. I still need to figure out problem (a) - prevent a login session from freezing on long periods of inactivity.

If you liked this article, please consider supporting my efforts by purchasing my book.

Python Playground, published by No Starch Press, USA, is a collection of imaginative programming projects that will inspire you to use Python to make art and music, build simulations of real-world phenomena, and interact with hardware like the Arduino and Raspberry Pi. Do check it out!