@opferwurst:
Ich nutze die Firmware aus Beitrag #1.
-> fimware (12.4.0.2) aus #1
-> Script. >UPDATE 27.02.2022 - Fix Stromanzeige aus #1
-> Hardware: ESP 8266 (D1 MINI) und den D1 Mini Pro probiert.
-> Pins siehe Bild unten. Also die wo RX und TX dran steht wurden benutzt.
-> Code
>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%}
#
![]()