Connecting MT681 (energy meeter from enbw) to fhem with a esp8266

Begonnen von immi, 30 April 2016, 11:56:40

Vorheriges Thema - Nächstes Thema

immi

MT681 has an optical interface in the front, transmitting SML telegrams every 500..1000 ms.
A smal circuit board can be fixed with a ring magnet.
You can buy a professional board from Udo or DIY
http://wiki.volkszaehler.org/_media/hardware/controllers/ir_schreib_lesekopf_ttl_neu_v1_stromlaufplan.png

I chosed DIY for 2 boards ( I have 2 meeters).
You only need the receiving part (top part of the image). I changed the components like this.

  • fototransistor BPW40 (it has 2 pins like a diode)
  • 2 resistors 30kohm
  • 1 npn transistor bc546
  • 1 or 2 capacitor 1µF; the 1µF capacitor is very important.

  • You can (should) skip the schmitt trigger. The slow signal from MT681 is clean enough for the esp8266.
For power supply, I use the 3.3V of the esp8266.

The esp8266 has only one native hardware serial port available, which can be used with ser2net.
If you have 2 meeters, you need a simulated software serial port. I uploaded the sketch here.
http://www.esp8266.nu/forum/viewtopic.php?f=6&t=1087#p5915
pinout of esp8266
for _P020_Ser2Net.ino use IO01(D10) and IO03(D9)
for my _P030_swser.ino use IO14(D5) and IO12(D6)

Assuming your esp82266 has 10.0.2.22 as IP, test with
nc 10.0.2.22 1234 | hexdump -C

start fhem with
define PowerMeter OBIS 10.0.2.22:1234
attr PowerMeter event-aggregator power:120:linear:mean,total_consumption:300:none:v,total_consumption_Ch1:300:none:v
attr PowerMeter event-on-change-reading .*
define PowerMeterDouble OBIS 10.0.2.22:4321
attr PowerMeterDouble event-aggregator power:120:linear:mean,total_consumption:300:none:v,total_consumption_Ch1:300:none:v,total_consumption_Ch2:300:none:v
attr PowerMeterDouble event-on-change-reading .*

immi

sprudelverduenner

Hallo immi,

ich habe den gleichen Zähler und würde gerne in FHEM die Daten meines eHZ mit einem ESP8266-01 übertragen.
Ich habe die Schaltung nach dem Plan und Deinen aufgeführten Bauteilen aufgebaut.
Den ESP mit ESPEASY geflasht und in FHEM ein Device angelegt.

Bei mir scheint es allerdings noch nicht zu laufen. Kannst Du mir Tipps für eine Fehlersuche geben?
Im Anhang mal meine Konfiguration von ESPEASY und FHEM.
Ich werde mir morgen auch nochmal meine Platine anschauen, ob ich dort evt, in der Hardware einen Fehler verbaut habe...

Würdest Du bitte mal über meine Konfiguration drüber schauen, ob das alles stimmig ist.

Vielen Dank vorab.

LG, Sprudelverduenner
FHEM @ RaspberryPi 3, HMLAN, HMUART + HMRS485, Homematic, ESPEasy @ Sonoff / Shelly / ESP8266, ZigBee @ CC2531
Echo Dot, Dreambox, Yamaha MusicCast, Logitech Hub, LW-12, LD382
FRITZ!Box 7590 AX, Mesh @ FRITZ!Repeater 2400, FRITZ!Fon, iPhone 13, iPad Air 5, AppleWatch 8

immi

Zitat von: sprudelverduenner am 16 Februar 2017, 22:30:16
Bei mir scheint es allerdings noch nicht zu laufen. Kannst Du mir Tipps für eine Fehlersuche geben?
as I wrote above start by testing if something comes out of your esp8266
in your case execute from command line
nc 192.168.1.102 23 | hexdump -C

sprudelverduenner

Danke für Deine Antwort,

es läuft bei mir nachdem ich den Fototransistor an die richtige Stelle des Stromzählers positioniert habe.

LG, Sprudelverduenner


Thank you for answering,

from now it's working. I choose the wrong position for the ir-receiver.

Best regards, Sprudelverduenner
FHEM @ RaspberryPi 3, HMLAN, HMUART + HMRS485, Homematic, ESPEasy @ Sonoff / Shelly / ESP8266, ZigBee @ CC2531
Echo Dot, Dreambox, Yamaha MusicCast, Logitech Hub, LW-12, LD382
FRITZ!Box 7590 AX, Mesh @ FRITZ!Repeater 2400, FRITZ!Fon, iPhone 13, iPad Air 5, AppleWatch 8

immi

Hi Sprudelverduenner
maybe you want to upload a picture of your circuit and/or explain in german what you have done
immi

cs-online

Hallo Sprudelverdünner,

ich habe einen Lesekopf an RX vom ESP angeschlossen und die R120 vom Espeasy installiert. Habe in der Config unter Devices das so eingerichtet, wie in Deinem Screenshot. Mein ESP hat die IP 192.168.2.61. Im FHEM habe ich das Device so definiert:


define Stronzaehler SML 192.168.2.61 23


und er legt dann auch ein Device an. Dieses bleibt aber bei INITIALIZE stehen.

Wie hast Du denn die anderen Reiter im Espeasy configuriert ? Was hast Du denn als Protocol ausgewählt ? Unter Controler habe ich mal angenommen,daß der FHEM-Raspi mit gemeint ist oder ? Ich habe leider keine brauchbare Anleitung für das ESPeasy gefunden :-(

Kannst Du mir da ein wenig Schützenhilfe geben ?

Grüße

Christian
FHEM auf RPI 4 4GB, HM-WLAN-Gateway, einige HM-Aktoren,2x EBUSD an Heizung+Solar, ESP8266 am Strom-,Gas-,Wasserzähler, in WLAN-Steckdosen und Relaisleisten, Sonoff S20, Shelly1,2 und 2.5,Lacrosse-Gateway und Sensoren,Sduino,Alexa-Fhem,Huawei PV mit Speicher, alles auf einem RPI und da geht noch mehr

cs-online

Ha, ich hab's... wenn man den ersten Post liest, dann klappt das auch. Das Device ist ein OBIS, keine SML... :-) Cool wäre das, wenn man neben dem Zählerstand und der aktuellen Last auch noch andere schöne Werte auslesen könnte, die der Zähler so noch mit ausgibt... aber das wäre Luxis, erstmal bin ich bunnig zufrieden, Danke Euch allen !!!

Grüße

Christian
FHEM auf RPI 4 4GB, HM-WLAN-Gateway, einige HM-Aktoren,2x EBUSD an Heizung+Solar, ESP8266 am Strom-,Gas-,Wasserzähler, in WLAN-Steckdosen und Relaisleisten, Sonoff S20, Shelly1,2 und 2.5,Lacrosse-Gateway und Sensoren,Sduino,Alexa-Fhem,Huawei PV mit Speicher, alles auf einem RPI und da geht noch mehr

immi

Zitat von: cs-online am 12 März 2017, 17:16:54Cool wäre das, wenn man neben dem Zählerstand und der aktuellen Last auch noch andere schöne Werte auslesen könnte, die der Zähler so noch mit ausgibt... aber das wäre Luxis, erstmal bin ich bunnig zufrieden, Danke Euch allen !!!
Ich bekomme auch der aktuellen Last

cs-online

Hallo Immi,

ja die aktuelle Last und den Zählerstand bekomme ich. Aber der Zähler kann ja noch viel mehr, z.B. Wochen- oder Monatsverbrauch, aktuelle Last auf den Phasen 1,2 und 3 u.s.w. Aber erstmal ist das super, daß die beiden Werte schon mal gehen, das ist ein riesen Schritt voran :-)

Grüße

Christian
FHEM auf RPI 4 4GB, HM-WLAN-Gateway, einige HM-Aktoren,2x EBUSD an Heizung+Solar, ESP8266 am Strom-,Gas-,Wasserzähler, in WLAN-Steckdosen und Relaisleisten, Sonoff S20, Shelly1,2 und 2.5,Lacrosse-Gateway und Sensoren,Sduino,Alexa-Fhem,Huawei PV mit Speicher, alles auf einem RPI und da geht noch mehr

immi

Zitat von: cs-online am 12 März 2017, 21:01:01
ja die aktuelle Last und den Zählerstand bekomme ich. Aber der Zähler kann ja noch viel mehr, z.B. Wochen- oder Monatsverbrauch, aktuelle Last auf den Phasen 1,2 und 3 u.s.w. Aber erstmal ist das super, daß die beiden Werte schon mal gehen, das ist ein riesen Schritt voran :-)
HI Christian
I do not need "Wochen- oder Monatsverbrauch" because I just compute it in fhem.
But the power on the different phases could be interesting.
The OBIS module from Icinger is decoding all SML-info, which my meeter MT681 sends automatically.
Do you know how to get the further information? do you have to actively query the meeter?
immi

p.s. the esp8266 is almost always idle; therefore I use it to read 2 meeters and measure temperature humidity at the same time

p.s.2 sometimes you will lose the wifi-connection between the esp8266 and fhem. In this case fhem needs up to 1h before realizing it and reconnect. There is some potential for improvement :)

cs-online

Hi Immi,

how do you compute the values for day, week or month in FHEM ? And how can you read 2 meters with an ESP8266 ? I have ESPeasy with Serial_Server on it and the IR-Reader on RX. I tried to write a program in LUA on ESP for the meter to calculate the values I needed, but I had problems with the RX-connector to access with LUA...

Now I read in FHEM with OBIS-modul and from time to time it hangs up... Therefor I have a timer (AT), which reads the readingAge and if it's greater then 300 I let it write the defmod again, it seems, the device starts up again... with the same timer, every minute, it writes the values "power" and "total_consumption" to a dummy on which a log runs. So I get the values in realtime and a log every 60s, on which the charts run...

greetings Christian

FHEM auf RPI 4 4GB, HM-WLAN-Gateway, einige HM-Aktoren,2x EBUSD an Heizung+Solar, ESP8266 am Strom-,Gas-,Wasserzähler, in WLAN-Steckdosen und Relaisleisten, Sonoff S20, Shelly1,2 und 2.5,Lacrosse-Gateway und Sensoren,Sduino,Alexa-Fhem,Huawei PV mit Speicher, alles auf einem RPI und da geht noch mehr

immi

Zitat von: cs-online am 18 März 2017, 14:19:09
Hi Immi,
how do you compute the values for day, week or month in FHEM ?
Hi christian
https://wiki.fhem.de/wiki/Statistics

Zitat
And how can you read 2 meters with an ESP8266 ?
please read first post above
If you have 2 meeters, you need a simulated software serial port. I uploaded the sketch here.
http://www.esp8266.nu/forum/viewtopic.php?f=6&t=1087#p5915
pinout of esp8266
for _P020_Ser2Net.ino use IO01(D10) and IO03(D9)
for my _P030_swser.ino use IO14(D5) and IO12(D6)


Zitat
Now I read in FHEM with OBIS-modul and from time to time it hangs up...
It does not hang-up; fhem loses the connection and does not realize it for more than 60 min.
The OBIS module has to be improved.

immi

immi

Hi Christian
today I went further with the connection host issue in OBIS module.

I send to the esp8266 a "new-line-feed" every 60 second. The esp8266 does not care in normal case.
If there is no connection, fhem understand very fast and reestablishes the connection immediately.

just make the following change at about line 140
change

"Unknown"       =>      ["",                        -1,    ""],
"SML"             =>      ["",                        -1,    ""],

with

"Unknown"       =>      ["/?!".chr(13).chr(10),    60,    chr(6)."0".$hash->{helper}{SPEED}."0".chr(13).chr(10)],
"SML"             =>      ["/?!".chr(13).chr(10),    60,    chr(6)."0".$hash->{helper}{SPEED}."0".chr(13).chr(10)],


I would appreciate a feedback if it fixes also your issue
immi

cs-online

Hi Immi,

I'll try as fast as I can, but it can take a few days...

Meanwhile I createt a timer (AT) which writes power, total_consumption and the age of the reading into a Dummy and if the Age is greater then 60 (s) then it sends a "modify Stromzaehler....." to FHEM and FHEM starts the connection again and I get within seconds new values from the meter... Since then I don't have the problem, but it "modifies" a few time a day...

But maybe, your idea is better. I'll try and will tell you afterwards,

thank you for your help,

Christian
FHEM auf RPI 4 4GB, HM-WLAN-Gateway, einige HM-Aktoren,2x EBUSD an Heizung+Solar, ESP8266 am Strom-,Gas-,Wasserzähler, in WLAN-Steckdosen und Relaisleisten, Sonoff S20, Shelly1,2 und 2.5,Lacrosse-Gateway und Sensoren,Sduino,Alexa-Fhem,Huawei PV mit Speicher, alles auf einem RPI und da geht noch mehr

AlfAb

Hallo immi, cs_online,
ich schreibe in deutsch da ich in englisch schreiben nicht kann, lesen geht aber. Ich hoffe das ist ok.
Ich habe auch einen Mt681 mit  esp8266 (D1-Mini) und FHEM auf einem RPi3. Ich verwende eine ser2net-Anwendung von Daniel Parnell (https://github.com/dparnell/esp8266-ser2net) und die Konfiguration, die immi im Beitrag "OBIS_V2-mit SML-Unterstützung" vorgeschalgen hat. Ich lese alle Werte, die mein MT681 liefert (consumption total/HT/NT/, power total/Phase1..3).
Bei mir treten die Verbindungsverluste ebenfalls auf, auch nachdem ich von immi vorgeschalgenen Intervall-Timer mit 30 s im OBIS-Modul eingetragen habe.
Ich bin TCP-Laie, meinem Sohn ist aufgefallen, dass FHEM auch nach Verbindungsverlust weiter versucht die Nachricht (2F3F210D0A) zu senden.
Im Log-File "SW: 2F3F210d0A" durch DevIo-Modul und "WROTE /?!" durch Obis-Modul. Selbst " syswrite($hash->{TCPDev}, $msg);" (aufgerufen von DevIo_SimpleWrite() liefert als Returncode 5 (5 Bytes gesendet), (wird aber von den FHEM-Modulen nicht verwendet).
"tcptrack" auf dem RPi "sieht" aber keine TCP-Nachricht. Wie auch, ohne Verbindung.
Mein Sohn stellte fest, dass erst ein Read, initiiert durch wen/was weiß ich nicht, dazu führt, dass FHEM den Verbindungsverlust erkennt (und sofort einen reconnect durchführt).
Mir fehlen die Kenntnisse um in diesen Ebenen etwas zu finden. Vielleicht helfen diese Infos euch eine Lösung zu finden, dass FHEM den Verbindungsverlust sofort bemerkt wie dies in FHEM-WEB ja perfekt fu nktioniert.
Gruß
Alfons