Raspberry Pi ZeroW WiFi Power Management

Every Raspberry Pi Zero W I’ve had has had intermittent connection problems on Wi-Fi. I’ve been able to fix the problems by disabling power management on the Wi-Fi interface each time. This page gave me my preferred solution for taking care of the problem on each machine. I’m duplicating the information here to contribute/prevent webrot.

See the current state of power management:

sudo iw wlan0 get power_save

set power management off:

sudo iw wlan0 set power_save off

Create a systemd unit file to set Wi-Fi power management:

sudo systemctl --full --force edit wifi_powersave@.service

With this as the contents of the unit file:

[Unit]
Description=Set WiFi power save %i
After=sys-subsystem-net-devices-wlan0.device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/iw dev wlan0 set power_save %i

[Install]
WantedBy=sys-subsystem-net-devices-wlan0.device

Then enable the unit file, setting power management to off whenever wlan0 is activated.

sudo systemctl disable wifi_powersave@on.service
sudo systemctl enable wifi_powersave@off.service