Zuletzt angesehen: • 2r-stromzaehler
Dies ist eine alte Version des Dokuments!
MQTT 2R-Stromzähler (Zweirichtung) / Verbrauchsmessung eines Ferraris-Stromzählers
>D p:zs=0 p:s1=0 p:total=0 p:e2=0 p:e3=0 fl1=0 fl2=0 rt="unbekannt" c1=0 c2=0 c1old=0 c2old=0 c1ts=0 c2ts=0 c1tsold=0 c2tsold=0 zk=75 mu=10 hr=0 dy=0 sec=0 power=0 h1=0 e1=0 >B =>sensor53 l255 >F h1=zs-s1 e1=h1/(2*zk) if fl1==1 and upsecs>(c1ts+mu) then fl1=0 endif if fl2==1 and upsecs>(c2ts+mu) then fl2=0 endif // links if c1!=c1old then fl1=1 c1ts=upsecs if fl2==1 then zs=zs-1 rt="rückwärts" fl2=0 fl1=0 endif endif // rechts if c2!=c2old then fl2=1 c2ts=upsecs if fl1==1 then zs=zs+1 rt="vorwärts" fl1=0 fl2=0 endif endif ' Aktuelle Leistung c1ts=upsecs if c1>c1old and c1ts>(c1tsold+mu) then sec=c1ts-c1tsold power=3600000/(sec*zk) c1tsold=c1ts endif if c1ts>(c1tsold+540) then sec=c1ts-c1tsold power=0 else endif c1old=c1 c2old=c2 ' Historische Werte hr=hours dy=day if chg[hr]>0 and hr==0 then s1=zs e3=e2 e2=e1 endif ' MQTT if upsecs%tper==0{ =>Publish tele/%topic%/main/energytotal %total% =>Publish tele/%topic%/main/actpower %0power% =>Publish tele/%topic%/main/today_kwh %2e1% =>Publish tele/%topic%/main/yd_kwh %2e2% =>Publish tele/%topic%/main/dbyd_kwh %2e3% =>Publish tele/%topic%/json {"energytotal": "%total%", "actpower": "%0power%", "today_kwh": "%2e1%", "yd_kwh": "%2e2%", "dbyd_kwh": "%2e3%",} } >T c1=Counter#C1 c2=Counter#C2 total=zs/zk >W Zählerstand: {m} %total% kWh Richtung: {m} %rt% Leistung: {m} %0power% W Sensor L: {m} %0fl1% Sensor R: {m} %0fl2% ============ Verbrauch: Heute : {m} %2e1% kWh Gestern : {m} %2e2% kWh Vorgestern: {m} %2e3% kWh