OpenWrt Forum Archive

Topic: Auto turn off WiFi at night for a better sleep

The content of this topic has been archived on 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

https://www.youtube.com/watch?v=j0ia-1KnzHY
https://scontent-hkg3-1.xx.fbcdn.net/v/t1.0-9/13256243_1220307921327373_890947385804855211_n.jpg?oh=a815229cc1d67642e446cbe3621bd46a&oe=57CB0D71
People said WiFi is the silent killer in your home
And I also want to reduce RF radiation on my children especially at night so they can have good sleep (we donot use WiFi at night anyway)
With OpenWrt we can do it easily even with only cheap router such as TP-LINK WR740N

(Last edited by chiakhoavang.vn on 24 May 2016, 15:26)

Instead of "wifi off" + "sleep 8h" + "wifi off" at 22:30, I would do "wifi off" at 22:30 and "wifi on" at 6:30.

eduperez wrote:

Instead of "wifi off" + "sleep 8h" + "wifi off" at 22:30, I would do "wifi off" at 22:30 and "wifi on" at 6:30.


No, I kind of like the first idea, turn it off and keep it off.  If it's bothering you while asleep, surely its not great while awake either, right?  Go with that.  For best results turn the whole thing off.

just turn off the whole thing, just use a smart plugs or a homebew smart plug with raspberry pi zero or something.

remlei wrote:

just turn off the whole thing, just use a smart plugs or a homebew smart plug with raspberry pi zero or something.

Agree, but we need more equipment, while mine is just config the firmware.

And here is my timer version https://www.youtube.com/watch?v=EYDUr9dxRLs

(Last edited by chiakhoavang.vn on 25 May 2016, 08:45)

chiakhoavang.vn wrote:

People said WiFi is the silent killer in your home
And I also want to reduce RF radiation on my children especially at night so they can have good sleep (we donot use WiFi at night anyway)

do you believe everything you see on youtube? that's just FUD

yeah, I had a AP open 24/7 365days a year for 18 years (probably even longer). Never had any health issues, I regularly go for checkup and never seen any thing bad, not even a spot of cancer.

In short, just live healthy and stop blaming anything to WiFi.

(Last edited by remlei on 25 May 2016, 11:32)

I still feel sleeping better with my WiFi turn off

regardless those non-sense "you will be killed by your WiFI" thing. turning off a wifi at night may be a good idea so your kids can go to bed since they cant access internet with wifi is off. At least that thing make sense.

chiakhoavang.vn wrote:

I still feel sleeping better with my WiFi turn off

Something that is well proven is that using screens late at night interrupts your sleep cycle, sometimes dramatically. I have every belief that forcing you off the internet after 10pm (or earlier) is good for your sleep, but it has nothing to do with the presence of the wifi, it's because you aren't flooding your brain with wake-up cues by looking at a screen.

Everyone has over a thousand different radio waves running through their head every second, so I'm not sure what turning off you 1 watt wifi router is going to do.

(Last edited by davidc502 on 26 May 2016, 04:12)

davidc502 wrote:

Everyone has over a thousand different radio waves running through their head every second, so I'm not sure what turning off you 1 watt wifi router is going to do.

Agree, turn off only so you do not bother checking email at night

A wifi can't really harm you. For referrence, a phone can transmit at over 30 dBm(1W) while near your head. Even relatively powerful routers like 1043nd can't usually go above 24 dBm(=250mw)(unless you have a high powered one).By default a router will transmit at 20 dBm with openwrt.

I think we should stick to the technical aspects of the question, and stop judging OP's lifestyle choices.

I have the following in crontab:

15 23 * * * /sbin/wifi down
10 5 * * * /sbin/wifi

It works fine.

Csarlee

(Last edited by csarlee on 26 May 2016, 20:53)

csarlee wrote:

I have the following in crontab:

15 23 * * * /sbin/wifi down
10 5 * * * /sbin/wifi

It works fine.

Csarlee


I have your 2nd line end with reboot

(Last edited by freewifimarketing.net on 27 May 2016, 05:34)

freewifimarketing.net wrote:
csarlee wrote:

I have the following in crontab:

15 23 * * * /sbin/wifi down
10 5 * * * /sbin/wifi

It works fine.

Csarlee


I have your 2nd line end with reboot

Default action for the /sbin/wifi script is to enable wifi.  There is no reboot option, you can use reload, but if its down it won't make a difference.

jeffmeden wrote:
freewifimarketing.net wrote:
csarlee wrote:

I have the following in crontab:

15 23 * * * /sbin/wifi down
10 5 * * * /sbin/wifi

It works fine.

Csarlee


I have your 2nd line end with reboot

Default action for the /sbin/wifi script is to enable wifi.  There is no reboot option, you can use reload, but if its down it won't make a difference.

There is reboot option, I am using it

freewifimarketing.net wrote:
jeffmeden wrote:
freewifimarketing.net wrote:

I have your 2nd line end with reboot

Default action for the /sbin/wifi script is to enable wifi.  There is no reboot option, you can use reload, but if its down it won't make a difference.

There is reboot option, I am using it

No, there isn't, you are using an option it ignores.

Hi! I write script (maybe not beauty). It disable, enable wifi depending day of week,time (hour) and connected clients via wifi.

#!/bin/sh
#Merkulov Sergey 26.08.2016
#Script for enable disable wi-fi on openwrt TP-Link 842nd
#v 1.0

h=`date +"%H"`  #what hour
d=`date +"%u"`  #what day of week (1-7)
w=`uci show wireless | grep disabled | cut -d"'" -f 2` #get wi-fi status (1-disabled,0-enabled)
c1=`iw dev wlan0 station dump | grep Station | wc -l`  # I have two wi-fi network, and I count connected client 
c2=`iw dev wlan0-1 station dump | grep Station | wc -l` # script personality for wifi chip
cd=$(($c1+$c2)) # sum clients

need_disable=0
need_enable=0

if [ $d -ge 6 ];then #if sunday or saturday
   if [ $h -ge 8 -a $h -le 23 ];then #if hour between 8 and 23
   need_enable=1 
   else
   need_disable=1 
   fi
elif [ $d -le 5 ];then #if monday-friday
   if [ $h -ge 18 -a $h -le 23 -o  $h -ge 6 -a $h -le 9 ];then # if hour between 18 and 23 or 6 and 9
   need_enable=1
   else
   need_disable=1
   fi
fi

 if [ $need_enable -eq 1 -a $w -eq 1 ];then  #if need enable and wifi now disabled
    uci set wireless.@wifi-device[0].disabled=0; uci commit wireless; wifi  #enable wifi
 elif [ $need_disable -eq 1 -a $w -eq 0 -a $cd -le 1 ];then  #if need disable and wifi now enabled and no connected wifi clients
    uci set wireless.@wifi-device[0].disabled=1; uci commit wireless; wifi #disable wifi
 fi
 
 
csarlee wrote:

I have the following in crontab:

15 23 * * * /sbin/wifi down
10 5 * * * /sbin/wifi

It works fine.

Csarlee

Maybe I am missing something, but it looks like the above should work. If you look at the /sbin/wifi script, you will see:

#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
usage() {
    cat <<EOF
Usage: $0 [down|detect|reload|status]
enables (default), disables or detects a wifi configuration.
    exit 1
...

Default action is to _enable_, and using the "down" parameter should disable wifi.

The discussion might have continued from here.