Use cron to adjust wifi signal strength

Hi,
just wanted to add to a closed topic (of the same subject) that I found very helpful. I noticed that the solution uses the uci system, and seems to update the config on the flash twice a day. I know it's not a big deal, but I've worn out the flash on several devices by inadvertently writing to them every day. So I thought I'd offer an alternative.

It works just as well to make these ephemeral changes using the low level wireless Utilities talked abut here: https://openwrt.org/docs/guide-user/network/wifi/wireless-tool/wireless.utilities

Here are my updated power control scripts:

cd /root
cat <<EOF > wifidown.sh
#/bin/sh

lowpower=1

# The old way that rewrites the config on the flash card each time
# /sbin/uci set wireless.radio0.txpower="$lowpower"
# /sbin/uci set wireless.radio1.txpower="$lowpower"
# /sbin/uci commit wireless
# /sbin/wifi reload

# The new way, that just changes the driver parameter
iw phy phy0 set txpower limit "${lowpower%%.*}00"
iw phy phy1 set txpower limit "${lowpower%%.*}00"
EOF

cat <<EOF > wifiup.sh
#/bin/sh

hipower=15

# The old way that rewrites the config on the flash card each time
# /sbin/uci set wireless.radio0.txpower="$hipower"
# /sbin/uci set wireless.radio1.txpower="$hipower"
# /sbin/uci commit wireless
# /sbin/wifi reload

# The new way, that just changes the driver parameter
iw phy phy0 set txpower limit "${hipower%%.*}00"
iw phy phy1 set txpower limit "${hipower%%.*}00"
EOF

Now go over to System --> Scheduled Tasks, and add:

# (Crontab for root)
# m h dom mon dow    command

# Turn WiFi power down at night.
30 7 * * * /root/wifiup.sh
0 23 * * * /root/wifidown.sh

Happy Trails!

3 Likes

12 years and this is your only contribution?? :rofl: Welcome Welcome!!
Give a bit more Clif, just an inch further.

The OP joined 2 hours ago.

1 Like

IKR.. but..

I saw it.

More of your razor-sharp wit...as usual.

1 Like

Hey guys,

LoL! Yeah I thought I already had an account, as my password manager hinted at, but I guess not. I have mostly used OpenWRT on Ubiquiti and recently TP-Link products. I am partial to outdoor PoE devices. If you have other favorites please let me know. :slight_smile:

Clif