Software:Solar Power

From HiveTool
Revision as of 02:48, 5 February 2014 by Paul (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

These scripts save significant power by shutting down HDMI, Ethernet, USB ports and connected USB devices.

To use them call buspower_up at the beginning of hive.sh and call buspower_down at the end of hive.sh.

WARNING! These scripts are in alpha testing and not for production release.

Oops, after running 24 hours, there were lots of hung processes:

root     32701 31654  0 05:32 ?        00:00:00 /bin/sh /lib/udev/ifplugd.agent                                                                                                     
root     32702  2203  0 05:32 ?        00:00:00 /bin/sh /lib/udev/ifplugd.agent                                                                                                     
root     32704  5655  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32705 14264  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32706 13018  0 05:32 ?        00:00:00 /bin/sh /lib/udev/ifplugd.agent                                                                                                     
root     32707 24847  0 05:32 ?        00:00:00 /bin/sh /lib/udev/ifplugd.agent                                                                                                     
root     32708 31793  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32709 29075  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32714 32152  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32729 31424  0 05:32 ?        00:00:00 /bin/sh /lib/udev/ifplugd.agent                                                                                                     
root     32732 22459  0 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      
root     32743 28808  2 05:32 ?        00:00:00 /bin/sh -e /lib/udev/net.agent                                                                                                      

Is this the problem: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718281 ?

A work around?

pkill ifplugd.agent
pkill net.agent

buspower_up

Turns on the Ethernet and USB ports. Sets up networking.

echo 0x1 > /sys/devices/platform/bcm2708_usb/buspower                                                                                                                               
sleep 3                                                                                                                                                                             
/sbin/ifconfig wlan0 down                                                                                                                                                           
echo "search domain_not_set.invalid                                                                                                                                                 
nameserver 166.102.165.11                                                                                                                                                           
nameserver 68.238.112.12" > /etc/resolv.conf                                                                                                                                        
                                                                                                                                                                                    
/sbin/ifconfig wlan0 192.168.0.11 up                                                                                                                                                
/sbin/iwconfig wlan0 mode Managed                                                                                                                                                   
/sbin/iwconfig wlan0 essid dlink                                                                                                                                                    
/sbin/route add default gw 192.168.0.1 wlan0                                                                                                                                        

buspower_down

/sbin/ifconfig wlan0 down                                                                                                                                                           
echo 0x0 > /sys/devices/platform/bcm2708_usb/buspower                                                                                                                               
sleep 10                                                                                                                                                                            
pkill ifplugd.agent                                                                                                                                                                 
pkill net.agent                                                                                                                                                                     

sync_clock.sh

Syncs the clock. Called by cron and rc.local.

/home/hivetool/buspower_up                                                                                                                                                          
timeout 20 /usr/sbin/ntpd -qg                                                                                                                                                       
/home/hivetool/buspower_down                                                                                                                                                        

rc.local

  • Turn off HDMI (saves about 20 ma.)
  • Set the clock on boot up. (Note ntpd must be disabled.)
/opt/vc/bin/tvservice -off
timeout 60 /home/hivetool/sync_clock.sh                                                                                                                                             

crontab

Syncs the clock four times a day. (1:07, 7:07, 13:07, and 19:07)

# Synch the clock                                                                                                                                                                   
7 1,7,13,19 * * * /home/hivetool/sync_clock.sh