Hier also noch eine beispielhafte Erweiterung der Funktionalität per Skript.
In meinem Fall wird tagsüber anfallender PV-Überschuss in den Akku geleitet, nachts wird wieder aus dem Akku per Mikrowechselrichter eingespeist.
Dazu nutze ich zwei Relais (SSR geschalten über normale GPIOs), welche wechselseitig geschalten sind, einmal für die Ladeseite und einmal für die Entladeseite. Zeitlich wird einfach bei Sonnenaufgang resp. Sonnenuntergang umgeschaltet.
Ebenso müssen die Relais eine einstellbare Lade- und Entladeschwellen (SOC) vom Akku einhalten.
Die Tag(Nacht)-Berechnung (Danke Gerhard) sieht dann so aus:
if time>sunrise
and time<sunset
then
tag=1
else
tag=0
endif
Die Ladeseite wird so gesteuert:
if tag==1
and
if coul<socmax
then
spin(ladepin 1)
spin(entladepin 0)
else
spin(ladepin 0)
endif
und so die Entladeseite:
if tag!=1
and
if coul>socmin
then
spin(entladepin 1)
spin(ladepin 0)
else
spin(entladepin 0)
endif
Hier noch das vollständige Skript:
>D 64
;variablen für berechnungen
res=0
rstr=""
label=""
lraw=""
val=0
volt=0
curr=0
temp=0
coul=0
tag=0
;ggf. anpassen:
ladepin=4 ;gpio pin für Lade-Relais
entladepin=5 ;gpio pin für Entlade-Relais
socmax=98 ; maximale Ladeschwelle
socmin=20 ; minimale Entladeschwelle
>B
res=0
res=so(3 1 115200 8N1 1024)
;print open %res%
spinm(ladepin O) ; set GPIO to mode output
spin(ladepin 0) ; Switch off relais on boot
spinm(entladepin O) ; set GPIO to mode output
spin(entladepin 0) ; Switch off relais on boot
>F
res=sa()
if res>0
then
;print res=%res%
rstr=sr(10)
rstr=sb(rstr 1 sl(rstr))
;print read %rstr%
label=sb(rstr 0 7)
lraw=sb(rstr 0 10)
val=st(rstr : 2)
switch label
case "Voltage"
volt=val/1000
case "Current"
if lraw=="Current "
then
curr=val
endif
case "Tempera"
temp=val/1000
case "Coulomb"
coul=val
ends
endif
>S
if upsecs%5==0
then
res=sw("pwr 1\n")
;print write cmd
endif
;print %volt% %curr% %temp% %coul%
;tagberechnung
if time>sunrise
and time<sunset
then
tag=1
else
tag=0
endif
;ladebedingung
if tag==1
and
coul<socmax
then
spin(ladepin 1)
spin(entladepin 0)
else
spin(ladepin 0)
endif
;entladebedingung
if tag!=1
and
coul>socmin
then
spin(entladepin 1)
spin(ladepin 0)
else
spin(entladepin 0)
endif
;print lade %0pin[ladepin]%
;print entlade %0pin[entladepin]%
>T
; sende mqqt-Einzeltopis zusätzlich/anstatt json wie unter ">J)
=>publish iot/%topic%/Voltage %4volt%
=>publish iot/%topic%/Current %0curr%
=>publish iot/%topic%/Coulomb %0coul%
=>publish iot/%topic%/Tag %0tag%
>W
Spannung{m}%4volt% V
Strom{m}%0curr% mA
Temperatur{m}%3temp% C
Ladung{m}%0coul% %%
Lade {m}%0pin[ladepin]%
Entlade {m}%0pin[entladepin]%
>J
,"pylon":{"Voltage":%4volt%,"Current":%0curr%,"Coulomb":%0coul%,"Temperature":%3temp%}
#
Alles anzeigen
UPDATE 27.02.2022 - Fix Stromanzeige
Testaufbau
Das also ein Beispiel, wie einfach man mit dem Scripting eine Erweiterung realisieren kann. Feine Sache!
Schönen 2. Advent!
Gruss ow