howto:wechselrichter_sma
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
howto:wechselrichter_sma [2014/05/29 12:14] – modifiziertes script mit variablen und funktionen wf_bitplan.com | howto:wechselrichter_sma [2018/04/01 15:56] (aktuell) – Titel jau | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ===== SMA Wechselrichter ===== | + | ===(verschobene |
- | Der Hersteller SMA bietet Solarwechselrichter [[http:// | + | #redirect hardware:channels:solar_inverters:sma |
- | deren Daten über verschiedenen Schnittstellen ausgelesen werden können. SMA bietet zum Auslesen die | + | |
- | Software "Sunny Explorer" | + | |
- | Für die Nutzung mit der Volkszähler Lösung ist die Quelloffene Software SMASpot besser geeignet, die platttformübergreifend genutzt werden kann, und sich in die Volkszaehler Infrastruktur auf unterschiedliche Weise | + | |
- | einbinden lässt. Auf dieser | + | |
- | + | ||
- | ==== SMAspot ==== | + | |
- | Die Software SMASpot ist inzwischen bei [[https:// | + | |
- | befinden sich unter [[https:// | + | |
- | === Kompilieren von SMAspot unter Linux === | + | |
- | Die folgenden Punkte wurden unter Ubuntu 12.04 LTS getestet sollten aber auch in anderen Debian-kompatiblen | + | |
- | Distributionen funktionieren: | + | |
- | + | ||
- | - Herunterladen des Sourcecodes z.B. als SMAspot_SRC_244_Linux_Win32.tar.gz z.B. / | + | |
- | - Anlegen eines Verzeichnisses z.b. " | + | |
- | - Wechseln in dieses Verzeichnis | + | |
- | - Auspacken mit ../tar xvfz SMAspot_SRC_244_Linux_Win32.tar.gz | + | |
- | - Installieren der nötigen Libraries sudo apt-get install libbluetooth-dev libcurl4-openssl-dev libboost-all-dev | + | |
- | - Übersetzen mit sudo make | + | |
- | - Kopieren des Ergebnisses sudo cp bin/ | + | |
- | + | ||
- | === Anpassen der Konfiguration für Bluetooth === | + | |
- | == Bluetooth Adapter prüfen == | + | |
- | Beispiel: Cambridge Silicon Radio Bluetooth Adapter | + | |
- | < | + | |
- | lsusb | grep -i blue | + | |
- | Bus 002 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) | + | |
- | </ | + | |
- | == SMA Geräte mit Bluetooth suchen | + | |
- | XXXX verdeckt die Angaben des konkreten Beispiels | + | |
- | < | + | |
- | hcitool scan | grep -i SMA | + | |
- | 00: | + | |
- | 00: | + | |
- | </ | + | |
- | + | ||
- | == Ergebnisse in SMASpot.cfg eintragen == | + | |
- | Wenn mehrere Inverter vorliegen einfach mehrere cfg Dateien erstellen z.B. 4000Watt.cfg, | + | |
- | + | ||
- | == SMASpot testen == | + | |
- | < | + | |
- | SMASpot -v | + | |
- | </ | + | |
- | oder | + | |
- | < | + | |
- | SMASpot -v -cfg4000Watt.cfg | + | |
- | </ | + | |
- | + | ||
- | ==== Beispiele ==== | + | |
- | === Beispiel STP 9000 TL-20 mit SMASpot per Ethernet / Perl-> | + | |
- | + | ||
- | + | ||
- | Ich besitze den Wechselrichter STP 9000TL-20 [[http:// | + | |
- | SMAspot -sp0 -v | + | |
- | + | ||
- | Ich möchte den Gesamtertrag, | + | |
- | Hierzu habe ich für den Gesamtertrag einen Kanal | + | |
- | El. Energie (Zählerstände) | + | |
- | und für den Ertrag je String | + | |
- | El. Energie (Leistungswerte) | + | |
- | angelegt. Die UUID sind später im Script einzutragen. | + | |
- | Anbei das Script: | + | |
- | + | ||
- | <code perl |sma.pl> | + | |
- | #!/ | + | |
- | use LWP::UserAgent; | + | |
- | open STATUS, "/ | + | |
- | or die " | + | |
- | while (< | + | |
- | if (/ETotal:[ ]*(.*)kWh/ | + | |
- | & | + | |
- | + | ||
- | } | + | |
- | if (/String 1 Pdc:[ ]*(.*)kW/ | + | |
- | $value = $1; | + | |
- | $value =~ s/\.//g; | + | |
- | & | + | |
- | + | ||
- | + | ||
- | } | + | |
- | if (/String 2 Pdc:[ ]*(.*)kW/ | + | |
- | $value = $1; | + | |
- | $value =~ s/\.//g; | + | |
- | & | + | |
- | } | + | |
- | } | + | |
- | close STATUS or die "bad netstat: $! $?"; | + | |
- | + | ||
- | #------ | + | |
- | sub submitt | + | |
- | { | + | |
- | $uuid = $_[0] ; | + | |
- | $val = $_[1] ; | + | |
- | print $uuid . " : " . $val . " | + | |
- | + | ||
- | + | ||
- | my $server_endpoint = " | + | |
- | # get(" | + | |
- | #print " | + | |
- | + | ||
- | # set custom HTTP request header fields | + | |
- | my $req = HTTP:: | + | |
- | $req-> | + | |
- | $req-> | + | |
- | + | ||
- | # add POST data to HTTP request body | + | |
- | $req-> | + | |
- | + | ||
- | my $ua = LWP:: | + | |
- | my $resp = $ua-> | + | |
- | if ($resp-> | + | |
- | my $message = $resp-> | + | |
- | print " | + | |
- | } else { | + | |
- | print "HTTP GET error code: ", $resp-> | + | |
- | print "HTTP GET error message: ", $resp-> | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | Das Script wird dabei einmal pro Minute mit cron aufgerufen. | + | |
- | < | + | |
- | * * * * * / | + | |
- | </ | + | |
- | + | ||
- | Um den Eigenverbrauch zu bestimmen bilde ich die Differenz zwischen der Einspeisung, | + | |
- | + | ||
- | == Originalscript von Markus == | + | |
- | <code bash|eigenverbrauch.bash> | + | |
- | # | + | |
- | echo ' | + | |
- | delete from `data` where `timestamp` = (select * from (select max(timestamp) from data where channel_id = 7) x) and channel_id = 7 | + | |
- | ' | mysql --user=vz --password=fdfdfdfdf volkszaehler -T | + | |
- | echo ' | + | |
- | INSERT INTO `data`( `channel_id`, | + | |
- | SELECT | + | |
- | max(case when `channel_id` | + | |
- | max(case when `channel_id` | + | |
- | FROM `data` where channel_id in (2,4) | + | |
- | and timestamp > (select max(timestamp) from data where `channel_id` = 7) | + | |
- | group by floor(`timestamp`/ | + | |
- | inner join data data_4 on timestamp_4 | + | |
- | ' | mysql --user=vz --password=fdfdfdfdf volkszaehler | + | |
- | + | ||
- | echo ' | + | |
- | delete from `data` where channel_id = 8 | + | |
- | ' | mysql --user=vz --password=fdfdfdfdf volkszaehler -T | + | |
- | #and timestamp > (select max(timestamp) from data where `channel_id` = 8) | + | |
- | + | ||
- | echo ' | + | |
- | INSERT INTO `data`( `channel_id`, | + | |
- | SELECT | + | |
- | max(case when `channel_id` | + | |
- | max(case when `channel_id` | + | |
- | FROM `data` where channel_id in (1,7) | + | |
- | group by floor(`timestamp`/ | + | |
- | inner join data data_1 on timestamp_1 | + | |
- | ' | mysql --user=vz --password=fdfdfdfdf volkszaehler | + | |
- | + | ||
- | </ | + | |
- | auch diese Script wird mit cron gestartet, aber nur ein mal die Stunde. | + | |
- | < | + | |
- | 1 * * * * bash / | + | |
- | </ | + | |
- | + | ||
- | == Modifiziertes Script (Versuch von Wolfgang) == | + | |
- | <code bash|eigenverbrauch.bash> | + | |
- | # | + | |
- | # calculate own PV usage | + | |
- | # Author: Markus 2014-05-20 | + | |
- | # latest version: | + | |
- | # $Header: / | + | |
- | + | ||
- | # | + | |
- | # get the delete query for the given channel | + | |
- | # | + | |
- | deletequery() { | + | |
- | local l_channel=$1 | + | |
- | cat << EOF | + | |
- | DELETE | + | |
- | FROM `data` | + | |
- | WHERE `timestamp` = | + | |
- | | + | |
- | AND channel_id = $l_channel; | + | |
- | EOF | + | |
- | } | + | |
- | + | ||
- | # | + | |
- | # get the insert query for the given channels | + | |
- | # l_chanel the channel to insert into | + | |
- | # l_c2 - the channel to substract | + | |
- | # l_c3 - the channel to substract the value from | + | |
- | # | + | |
- | insertquery() { | + | |
- | local l_channel=$1 | + | |
- | local l_c2=$2 | + | |
- | local l_c3=$3 | + | |
- | cat << EOF | + | |
- | INSERT INTO `data`( `channel_id`, | + | |
- | SELECT $l_chanel, | + | |
- | FROM ( | + | |
- | SELECT | + | |
- | MAX(CASE WHEN `channel_id` = $l_c2 then timestamp else 0 end) timestamp_2, | + | |
- | MAX(CASE WHEN `channel_id` = $l_c3 then timestamp else 0 end) timestamp_3 | + | |
- | FROM `data` | + | |
- | WHERE channel_id in ($l_c2, | + | |
- | AND timestamp > ( | + | |
- | SELECT MAX(timestamp) FROM data WHERE `channel_id` = $l_channel | + | |
- | ) | + | |
- | GROUP by floor(`timestamp`/ | + | |
- | INNER JOIN data data_2 | + | |
- | ON timestamp_2 | + | |
- | AND data_2.channel_id = $l_c2 | + | |
- | INNER JOIN data data_3 | + | |
- | ON timestamp_3 | + | |
- | AND data_3.channel_id = $l_c3 | + | |
- | EOF | + | |
- | } | + | |
- | + | ||
- | # modify according to your volkszaehler mysql database settings | + | |
- | user=vz | + | |
- | password=fdfdfdfdf | + | |
- | db=volkszaehler | + | |
- | + | ||
- | # debug setting | + | |
- | debug= | + | |
- | # uncomment to debug sql | + | |
- | #debug=-T | + | |
- | + | ||
- | # modify to suite your channel settings | + | |
- | # channel 7 is calculated from channel 2 and 4 | + | |
- | deletequery 7 | egrep -v " | + | |
- | insertquery 7 2 4 | egrep -v " | + | |
- | # channel 8 is calculated from channel 1 and 7 | + | |
- | echo " | + | |
- | insertquery 8 1 7 | egrep -v " | + | |
- | + | ||
- | </ | + | |
- | Und so sieht es aus: | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | == Beispiel SB 4000 TL-21 + SB 1300TL-10 mit SMASpot und PHP == | + | |
- | + |
howto/wechselrichter_sma.1401358441.txt.gz · Zuletzt geändert: 2014/05/29 12:14 von wf_bitplan.com