Script for saving power by turning off radio(s) when Internet is down

I'm pondering about getting an Opal (small router which allows several of the OpenWrt functionalities), and running it on batteries during ocassional blackouts.

My WISP also suffer those blackouts and the service goes up and down during their manouvers. That's why I wonder how much power would I save by running a periodic script like:

   RET=$(ping -c 4 $WAN_Gateway | awk '/received/ {print $4}')
   [ $RET -eq 0 ] && /sbin/wifi down

Is there a recommended script/method for this, or it would be better to use travelmate for this scenario?
It would really be any tangible power saving by turning off both radios? Has anyone measured it?

I can't speak for your specific device, but as a general rule, when the radios are idling, there isn't particularly high power draw. If you want to test this, you can put a power meter in-line with your power input (either use a "kill-a-watt" type device, or an equivalent that monitors power over your USB-C connection). Then measure the three conditions -- radios running full tilt (like during an iperf/speed test), radios idle (little-to-no traffic), and radios off.

Beyond that, consider how this might impact your devices... in some cases it can be good (forcing phones and other cellular devices off wifi which doesn't have a connection anymore), but in others it can be bad/annoying (local sharing becomes impossible, you can't even login to the device to check the status unless you plug in with ethernet, etc.).

I'm not sure if travelmate has a function for this, but if it does, that is a good package to consider. Otherwise, a script like what you've got could achieve the goal... just make sure that it is predictable and reliable, and be ready with ethernet connected devices to regain access.

1 Like

You mention several valid points. Some doesn't apply to my particular use-case, but it may for other people, nevertheless.

In particular, I don't have much of local traffic, therefore I was considering only the uplink up/down situation. (for other people reading this, some other users may have heavy LAN traffic during a blackout and/or ISP outage). Anyways I'll consider to have a patch cord handy shall I go this way.

I understand a mains wattmeter could be handy for some people, but because I'm starting from a power outage scenario (and battery more than UPS), it's better to have a DC meter (which I do), hence measuring the real router consumption and disregarding the conversion losses.

I don't have the Opal yet, or any other modern 5V router to measure from, and that's why I started this thread. However, the preliminary measurements I've made for a current 12V-powered 3-ports MediaTek showed: 2.3W when idle, 1.2W with both radios off (and 3W under simulated traffic). (side note: a R6700v3 beast measures 7W from mains idling). The power saving looks promissing enough for me, but as I said, I currently don't have any not-legacy 5V unit to test/confirm the margin/ratio.

In the meantime I'll continue polishing the script.

I gave it another thought, and maybe during failures I could switch off wlan1 and reduce tx_power for wlan0. Let's say:

[ $RET -eq 0 ] && iw dev wlan0 set txpower limit 600 # 6dBm from usual 22dBm

For the mt76x8 22.03.3 I'm testing, it doesn't show any error at the terminal, the change goes into memory (iw wlan0 info |grep txpower) but in reality it does nothing. (I have also tried toggling the radio for the change, but it doesn't work either). The actual tx_power and the power consumption remains unchanged.

I'd read that some SOC and/or kernel doesn't support that function (and we don't know much about the Opal SOC). I 'm aware I could use uci instead, but because this script is going to run periodically, I don't want to wear the flash too soon.

Is there any other command I can try to change the power w/o saving to flash?

I got my hands on the Opal (phunny: I was expecting 2 cores, but cat /proc/cpuinfo report 3 processors). wlan0 = phy1 = 5GHz, and wlan1 = phy0 = 2.4GHz.

Idle consumption report:

Vusb = 5.16V - 5.18V
wlan0 up, wlan1 up: 0.44A => 2.27W
wlan0 down, wlan1 up: 0.33A => 1.70W
wlan0 up, wlan1 down: 0.33A => 1.70W
wlan0 down, wlan1 down: 0.23A => 1.19W

The bright side to begin with is the consumption is not too high.

But as with the mt76x8, this sf19a28 doesn't really apply iw set txpower limit, and as I said I don't want to wear the flash quickly, so unless some other suggestion I guess I will have to choose either both radios off, or one radio off to extend battery life when the utility and/or ISP is/are down.

Bottom line:
For a modern and small router, there are important power/battery savings by turning off the radio(s) when not needed. It can be up to 25% or 50% reduction (YMMV).

A simple periodic script for achieving this goal avoinding unnecesary flash wear it could have the following lines:

RET=$(ping -c 4 -w 2 $Gateway | awk '/received/ {print $4}')
[ $RET -eq 0 ] && ifconfig wlan0 down || ifconfig wlan0 up # 5GHz in this case

Other option could be to limit the radio tx_power or enabling power save, but not every SOC/driver support those settings via iw.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.