Mining With Solar Power

Here’s a Python script I wrote to check today’s sun rise/set times given a coordinate:

It uses free API to get local sun rise/set time of today. It also takes time zone into consideration as the API only returns times in UTC time zone. It also cache the API result for a day so I’m not abusing the free API.

I have solar power at home however the invertor isn’t API friendly, otherwise it will be best to get solar power output directly from the invertor.

Using this python script I can turn on my Zcash miner when there’s solar power. This saves me money, more importantly the ZEC I mined is carbon free. Here’s a sample bash script to turn on/off the miner according to sun rise/set:

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MINER=<miner's IP>
pushd $DIR
python solar-hours/
# 0 means solar on, 1 means off
if [ $? -eq 0 ]; then
 ping $MINER -c 1 || wakeonlan <miner's MAC address>
 ssh $MINER sleep 1 && ssh -t $MINER 'sudo shutdown -h now'

If you want to try this too please read the Wake On LAN part I’ve done a while ago.


Leave a Reply

Your email address will not be published. Required fields are marked *