DEV Community

Cover image for Mining When the Sun is Out
howbotnik
howbotnik

Posted on

Mining When the Sun is Out

Beginning

For my first post I will introduce you to a piece of software I have been working on for the past few weeks.

Since getting into mining (in a purely recreational way) I have been trying to come up with a way to automate my miner. I live in a house with solar panels on the roof but no way to store the electricity generated. So I have been trying to solve the problem of turning on my mining software only when the weather is acceptable, therefore, generating your choice of cryptocurrency from free electricity!

Problem

I started with the idea that my software needed to follow these requirements:

  • Check to see if the sun is up
  • Check to see if the weather is acceptable
  • Start or stop the miner depending on the conditions

Project

Head over to https://github.com/howbotnik/sunmine to grab a copy and see how this could run on your system.

The config file needs building first and the project runs using Python:

[Location]
# for local weather information
country_code = GB
location = London

# for the sunrise / sunset api
latitude = 51.5074
longitude = 0.1278

[Tokens]
open_weather = **OpenweatherAPIKey**

[Communication]
# Emails user when turning mining on or off
recipient_email = test@test.com
sender_email = test@test.com
password = password

smtp_server_address = smtp.gmail.com
smtp_port = 587

[Miner]
# read the documentation for best practice
program_location = **path to your executable miner**

[Weather_types]
weather_codes=["800","801","802"]

This config file makes a lot of the program customisable and the program is set up to email when the miner switches on and off.

The Weather_types section allows the user to adjust the types of weather that are acceptable for mining using the https://openweathermap.org weather codes.

As for scheduling, I have had this running successfully as a Scheduled Task on Windows and you can also run it as a cron task on Linux systems.

Do you have a use for this? Have you found any problems with the code? Could you suggest any further improvement?

Other Uses

This program could be used to initiate any program and is not only limited to mining. Certain home-automation processes may only need to run during sunny periods. The rest is up to you!

Top comments (1)

Collapse
 
totonyparis profile image
totony

Very interesting, I was thinking about making something similar, once I install solar panels.
What I was thinking of though was to estimate the unused power. For exemple, even if the sun is out and bright, I might not want to mine if my electric water heater is on and I'm washing clothes.
On the contrary, on a very cloudy day, if I'm away and nothing runs, it makes sense to mine.
If the solar controler is not intelligent enough to provide this info, it could be done with a current clamp on the feed in line (where you send current back to the grid). If that current is above a specified value, then toggle on the mining. If it is below another threshold, then stop it.
Do you know of any existing such solution?