Updated 26 august 2019

After being connected to the new system of solar installations, I had a challenge that I need to use the amount of power that is produced within an hour.
So I've made ​​a little system where you can measure the amount of watts generated by the system and in the light of various power consuming thing. I currently have 2 relays that control the extraction and cooling of server space.

It all runs on Raspberry Pi with a relay card connected. Can be bought here 8$
I also use a Bluetooth usb adapter from Hama I bought it here.

My inverter is a SMA SB4000TL-21st
The program to read data from the inverter comes from SMAspot
There are full installation instructions for the program under the downloads page.
Sadly the original site has gone down, so I have put the files on my own site.

The program to control the relays can be found here and the connection to the Raspberry Pi is as follows

Or if the site is gone then here and then just build is

Vcc to pin 2

In1 to pin 16

In2 to pin 18

Gnd to pin 25

My script to read csv file and control the relay via Bash is here.

-------------------------Code start --------------------------------------------------


INPUT=/home/pi/smadata/$(date +%Y)/filnavn-$(date +%Y%m%d).csv

gpio -g mode 24 out

gpio -g mode 23 out



watt=$(tail -n 1 $INPUT | awk -F ';' '{print $3}')

echo $watt

echo $trikker1

echo $trikker2

# switch 1

if [[ "$watt" > "$trikker1" ]]; then

echo "Switch on air flow system"

switch1on="gpio -g write 23 1"

eval $switch1on


echo "Air flow system off"

switch1off="gpio -g write 23 0"

eval $switch1off


# switch 2

if [[ "$watt" > "$trikker2" ]]; then

echo "Switch cooling system on"

switch2on="gpio -g write 24 1"

eval $switch2on


echo "Cooling system off"

switch2off="gpio -g write 24 0"

eval $switch2off


-------------------------Code end --------------------------------------------------

Then you just have to make an entry in crontab which run every 5 minutes.