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

masl

Ich versuche gerade meinen ISKRA Stromzähler ans FHEM zu bringen.
Jetzt habe ich schon tausend sachen gelesen...
Problem ist dass der Raspi zu weit entfernt ist. Hierfür habe ich einen ESP8266 besorgt. Wollte diesen auf Tasmita flashen Allerdings gibt es die Vorlage der SML wohl nicht mehr.

Mit einem Phototransitor wäre ein Auslesen wohl möglich.
Hat hier irgendwer eine Anleitung oder könnte mir helfen dies einzusetzen?

sprudelverduenner

Hi masl

Der 1. Link im ersten Post zeigt den Schaltplan.
Das ganze habe ich an einem ESP-01 dran.
Der ESP ist mit ESPEASY geflasht.

Im 2. Post - der ist zufälligerweise von mir - ist die Konfiguration von ESPEASY zu sehen.

Die ganze Sache läuft bei mir seit knapp 3 Jahren stabil.

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

cs-online

Ich habe den TTL-IR-Kopf von UDOs Volkszähler über RX/TX an dem ESP8266 und dann ESPLink drauf, weil ESPEasy da nicht stabil lief (ist schon etwas her, ist mit den neuen Versionen evtl. stabiler). Das läuft sehr stabil. Wichtig ist die richtigen Werte (Baud und Co) einzustellen. Dann mit dem OBIS-Modul

define Stromzaehler OBIS <IP des ESP>:23

in FHEM eingebunden

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

Maista

#33
Hallo zusammen,

Alternativ gibt es das
http://forum.creationx.de/forum/index.php?thread/1095-d0-z%C3%A4hler-sml-auslesen-mit-tasmota/&postID=19422#post19422

Sourcen mit SML-Treiber (xsns_53_sml.ino):
https://github.com/gemu2015/Sonoff-Tasmota

Doku wie man es hin bekommt (Doku SML-Treiber WGS Zähler.pdf) :)
http://forum.creationx.de/forum/index.php?thread/1095-d0-z%C3%A4hler-sml-auslesen-mit-tasmota/&postID=26926#post26926

Compiliert & geflasht hab ich das schon mal, aber wie immer mangelt es an Zeit, Lust und Motivation  :o

Gruss Gerd

Heiner

Hi,

I have a similar problem.

I have a Energy Meter 6EHZ0300E which as per manual send with:
9600 bd, Datenbit = 7, Parität = gerade, Stoppbits = 1, Flusssteuerung = kein.
Im Fall des SML-Datentelegramms ist zur Interpretation der Daten ein Parser erforderlich und
die Einstellung ist: 9600 bd, Datenbit = 8, Parität = kein, Stoppbits = 1, Flusssteuerung = kein.

Then I use a IR TTL Platine from Hichi at a ESP 8266 (NodeMcu).

Based on a Ardunio Testscript I can recieve Data from the Meter .

Now I load ESPEasy on the ESP and configure with Serial Server and without FHEM HTTP Controller, but othing seems to be recieved by ESP Easy. There is nothing in the log neither  I recive anything based on nc ip:port |hexdump -c

What could the probem be?

The logical next and final step would be to add into fhem the define Stromzaehler obis ip:port SML line to recieve the data. This one shows opened but receive nothing.

I am not married to espEasy , but like to keep the IR TTL and my ESP8266 as devices to transmit the serial signal into fhem.

Can you help me?

Many Thanks already

Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2

immi

Zitat von: Heiner am 19 Juli 2021, 17:48:15
Based on a Ardunio Testscript I can recieve Data from the Meter .
Now I load ESPEasy on the ESP and configure with Serial Server and without FHEM HTTP Controller, but othing seems to be recieved by ESP Easy. There is nothing in the log neither  I recive anything based on nc ip:port |hexdump -c
Hi Heiner
first hint:
no ":" --> nc ip port |hexdump -c

second hint:
my 2 meeters are on an esp8266 running stable since years (including a temp/humidity). Nevertheless I will change to esp32: I want 2 meters and the thz on the same device.
I helped them in april 2021 to change ESPEasy ser2net in order to support for 3 ser2net connections on esp32.
Have you compiled yourself the espeasy from github and when?

third hint:
are you sure you have the right pin number in espeasy?
immi

Heiner

Hi Immi, good to hear form you.

Sorry you are right the command was in my note written worng I mean "nc ip port |hexdump"

I would have a esp32 for test as well available but prefer to have a usecase for the simpler 8266.

I did take a compiled Version and flashed it. The Version and flashing is now about 1 week ago.
ESP Easy is showing this:
   Firmware
   Build:⋄   20113 - Mega
   System Libraries:⋄   ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support
   Git Build:⋄   
   Plugin Count:⋄   47 [Normal]
   Build Origin:   Travis
   Build Time:⋄   May 3 2021 11:31:57
   Binary Filename:⋄   ESP_Easy_mega_20210503_normal_ESP8266_4M1M
   Build Platform:⋄   Linux-5.4.0-54-generic-x86_64-with-glibc2.29
   Git HEAD:⋄   mega-20210503_aacae49

I tried various PINs exchanged  RX and TX.

I would expect via the webaccess to ESPEasy to see in the log something - but here nothing from the IR-TTL comes in.
MQTT for the 8266 Systeminfo runs perfect.

For my Serial signal I use just the Devices Configuration of a Serial Communication Server.
In there i tried HW Serial 0, 0 swap, 1 and SoftwareSerial
I tried with and without Controller : Fhem HTTP

to be sure the 8266 and the IR TTL and the Meter is working I used a simple Arduino script with SoftwareSerial which showed the reciving characters on the serial connection to the laptop. which means as well that by 9600,8,N,1 must e correct.

I really struggle why the Logfile of ESPEasy is not showing anything...


162626594: SYS : 2710.00,16.40,-65.00
162626603: MQTT : ESP_Easy/SystemInfo/uptime 2710.00
162626605: MQTT : ESP_Easy/SystemInfo/load 16.40
162626607: MQTT : ESP_Easy/SystemInfo/rssi -65.00
162632189: WD : Uptime 2711 ConnectFailures 0 FreeMem 17016 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
162633078: LoopStats: shortestLoop: 483 longestLoop: 8056061 avgLoopDuration: 627.06 loopCounterMax: 62111 loopCounterLast: 47453
162633079: Scheduler stats: (called/tasks/max_length/idle%) 47453/1977/9/83.23
162646957: WiFi : Set TX power to 12dBm sensitivity: -69dBm RSSI: -61dBm
162647085: WiFi : Set TX power to 13dBm sensitivity: -69dBm RSSI: -62dBm
162662188: WD : Uptime 2711 ConnectFailures 0 FreeMem 17016 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
162663078: LoopStats: shortestLoop: 483 longestLoop: 8056061 avgLoopDuration: 625.12 loopCounterMax: 62111 loopCounterLast: 47601
162663078: Scheduler stats: (called/tasks/max_length/idle%) 47601/1983/9/82.75
162686595: SYS : 2711.00,17.25,-64.00
162686604: MQTT : ESP_Easy/SystemInfo/uptime 2711.00
162686606: MQTT : ESP_Easy/SystemInfo/load 17.25
162686608: MQTT : ESP_Easy/SystemInfo/rssi -64.00
162692189: WD : Uptime 2712 ConnectFailures 0 FreeMem 17184 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
162693077: LoopStats: shortestLoop: 483 longestLoop: 8056061 avgLoopDuration: 625.41 loopCounterMax: 62111 loopCounterLast: 47575
162693077: Scheduler stats: (called/tasks/max_length/idle%) 47575/1985/9/82.95




Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2

immi

Hi Heiner
do not worry, we get it working.

ZitatI tried with and without Controller : Fhem HTTP
no need for controllers; it is not related to ser2net
further hint; forget FHEM untill you receive stable data with "nc"

Zitatto be sure the 8266 and the IR TTL and the Meter is working I used a simple Arduino script with SoftwareSerial
ESP8266 has one hardware serial; the second hardware serial should not be accessible.
I have 2 meters therefore I use both software and standard serial on the ESP8266. My software serial is not very stable and loses 30% of the packets.
If you have only 1 meter, stick to the standard serial of the ESP8266.
With ESP32 you have more hardware serial available.

Summary:
start the hardware serial server.
Avoid "swap" and consider turning off log to serial.
Connect with nc from your computer.
Conncet the pins to something reliabe, which deliver a stable serial 3V signal. (5V will kill your pin on the esp)
try different pins untill you get someting in nc

immi

Heiner

Hi Immi,

ok HW Serial configured GPIO3 and 1 or D9 and D10 or better the pins written with RX and TX
ESPEasy, Tools, Advanced Settings, Log Settings, Serial LogLevel: none
ESPEasy, Tools, Advanced Settings, Log Settings, Web LogLevel: Debug more
ESPEasy, Tools, Advanced Settings, Serial Settings, enable Serial Port: yes
ESPEasy, Tools, Advanced Settings, Serial Settings, Baudrate: 9600

still nothing even if exchanging TX with RX.

Next I will bridge TX and RX for some seconds which could do something outside the IR_TTL

Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2

Heiner

Hi, connected TX with RX and opened it again,
connected TX with 3 V then with Gnd then RX with 3V then RX with Gnd

hexdump was the entire time running - no response at all.
:(
Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2

immi

Zitat von: Heiner am 21 Juli 2021, 15:39:01
Hi, connected TX with RX and opened it again,
connected TX with 3 V then with Gnd then RX with 3V then RX with Gnd
When I wrote a stable serial 3V signal, I meant something like a usb2serial interface (or a gpio of a raspi)  sending constantly something at 9600; you will never see a DC

Nevermind, maybe the problem is in the firmware you are using.
If I find time and you do not find a solution, I compile you a working espeasy firmware during the weekend for your esp8266.

immi

immi

Dear Heiner
I compiled right now the espeasy for 8266 and 32 (find enclosed)

The espeasy32 works well (2,5 HardwareSerial possible at the same time)

The espeasy8266 has currently a problem with the HardwareSerial.

I fixed the espeasy8266 HardwareSerial; the SoftwareSerial works also ok 
(see config as picture of both sending to fhem obis at the same time the IR of my 2 meeters)

immi

Heiner

Hi Immi,
I uploaded the 8266, use same ports then you suggeted and nothing  :-\

Now I prepared a old Ardunio Nano just saying Hello over Serial line once per second, upload and as per serail monitor it works, as well the RX LED blinks every second. So I connect this RX pin with my ESP8266 and nothing again, neither on my WebLog which is on debug mode, nor arriving in the fhem OBIS device, nor on fhem event Monitor.
The logfile in fhem shows  this:
2021.07.27 17:03:35 5:  OBIS (Stromzaehler) - Opening device...
2021.07.27 17:03:35 3:  Opening Stromzaehler device 192.168.178.41:23
2021.07.27 17:03:35 5:  HttpUtils url=http://192.168.178.41:23/ NonBlocking via http
2021.07.27 17:03:35 4:  IP: 192.168.178.41 -> 192.168.178.41
2021.07.27 17:03:38 1:  Stromzaehler: Can't connect to 192.168.178.41:23: connect to http://192.168.178.41:23 timed out
2021.07.27 17:03:38 4:  OBIS (Stromzaehler) - error while connecting: connect to http://192.168.178.41:23 timed out
2021.07.27 17:03:58 5:  SW:
2021.07.27 17:03:58 4:  OBIS (Stromzaehler) - Wrote
2021.07.27 17:04:00 5:  SW:
2021.07.27 17:04:00 4:  OBIS (Stromzaehler) - Wrote
2021.07.27 17:04:39 5:  HttpUtils url=http://192.168.178.41:23/ NonBlocking via http
2021.07.27 17:04:39 4:  IP: 192.168.178.41 -> 192.168.178.41
2021.07.27 17:04:39 3:  OBIS (Stromzaehler) - Init done
2021.07.27 17:04:39 1:  192.168.178.41:23 reappeared (Stromzaehler)


Do I have hear a problem with the port I used (23) ?

Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2

immi

Zitat von: Heiner am 27 Juli 2021, 17:14:55
Do I have hear a problem with the port I used (23) ?
Hi Heiner
port 23 is for telnet, therefore I prefer other ports.
I have not understood.
1) have you cofigured your esp8266 like I said and succesfully received the "hello" from the UNO in the "nc 192.168.178.41 1234" ?
if no, try other pins
if yes
2) Have you received the data from your meter via "nc ip port |hexdump -c"?
I receive a long SML sequence starting with 1B1B1B1B01010101..............
if no check your IR2ttl  circuit
if yes
3) go to FHEM check if you need to specify SML in your config "define PowerMeter OBIS 192.168.178.41:1234 SML" 

immi

Heiner

Hi Immi,

you were right, I did not check with "nc ip port |hexdump -c"

so i've done it again:

Exact as per your sample for the 8266 config and same pins, this time based on Port 4321
This time I even not only connect the TX from the Nano, as well the RX and tried it in both ways(TX/RX exchange) to the 8266.

"nc ip port |hexdump -c" deliver now incoming data when Nano RX  connected to D6 -Hurra  ;D
To note, the 8266 WebLog in debug mode shows me incoming data as well, no details but at least that something is coming.

Now I replaced the Nano with the IR Head tried again both connection RX/TX and flipped, and tried same on the Photocell / IR LED from the meter in both directions and.... hurra get some data here as well.

What I receive is this ( extract as constantly data come in):

0000440   ▒   Z   A   ▒   0 215  \n 215  \n   ▒   -   0   :   0 .   0
0000450   .   0   ▒   ▒   5   5   (   ▒   9   ▒   ▒   0   ▒   - 5   0
0000460   ▒   ▒   ▒   5   3   ▒ 215  \n   ▒   -   0   :   ▒   . ▒   .
0000470   ▒   ▒   ▒   5   5   (   0   ▒   6   9   9   ▒   .   6 6   ▒
0000480   9   ▒ 215  \n   ▒   -   0   :   ▒   .   ▒   .   ▒   ▒ ▒   5
0000490   5   (   0   3   ▒   9   5   5   .   ▒   6   ▒   6   ▒ 215  \n
00004a0   ▒   -   0   :   9   6   .   5   .   5   ▒   ▒   5   5 (   ▒
00004b0   ▒   ▒ 215  \n   0   -   0   :   9   6   .   ▒   .   ▒ 5   5
00004c0   ▒   ▒   5   5   (   0   0   0   0   ▒   0   ▒   ▒   ▒ 5   ▒
00004d0 215  \n   ! 215  \n   ▒   H   A   G   5   e   H   Z   0 ▒   0
00004e0   ▒   _   ▒   ▒   ▒   ▒   Z   A   ▒   0 215  \n 215  \n ▒   -
00004f0   0   :   0   .   0   .   0   ▒   ▒   5   5   (   ▒   9 ▒   ▒
0000500   0   ▒   -   5   0   ▒   ▒   ▒   5   3   ▒ 215  \n   ▒ -   0
0000510   :   ▒   .   ▒   .   ▒   ▒   ▒   5   5   (   0   ▒   6 9   9
0000520   ▒   .   6   6   ▒   9   ▒ 215  \n   ▒   -   0   :   ▒ .   ▒
0000530   .   ▒   ▒   ▒   5   5   (   0   3   ▒   9   5   5   . ▒   6
0000540   ▒   ▒   ▒ 215  \n   ▒   -   0   :   9   6   .   5   . 5   ▒
0000550   ▒   5   5   (   ▒   ▒   ▒ 215  \n   0   -   0   :   9 6   .
0000560   ▒   .   ▒   5   5   ▒   ▒   5   5   (   0   0   0   0 ▒   0


Now I take my fhem and add this command:
define Stromzaehler OBIS 192.168.xxx.xx:4321 SML

the only reading I got is the state which is opened.
I tried to add some attributes but no change:
ignoreUnknown    off
resetAfterNoDataTime   30
verbose                  5


Logfile is fhem shows nothing ( i tried based on Standard and SML in the definition)
2021.07.28 11:30:42 5:  OBIS (Stromzaehler) - Opening device...
2021.07.28 11:30:42 3:  Opening Stromzaehler device 192.168.xxx.xx:4321
2021.07.28 11:30:42 5:  HttpUtils url=http://192.168.xxx.xx:4321/ NonBlocking via http
2021.07.28 11:30:42 4:  IP: 192.168.xxx.xx -> 192.168.xxx.xx
2021.07.28 11:30:42 3:  OBIS (Stromzaehler) - Init done
2021.07.28 11:30:42 3:  Stromzaehler device opened
2021.07.28 11:30:46 5:  SW:
2021.07.28 11:30:46 4:  OBIS (Stromzaehler) - Wrote


I tried the "list Stromzaehler" command, which shows thet fhem get something in the buffer:

Internals:
   CFGFN     
   DEF        192.168.xxx.xx:4321 SML
   DeviceName 192.168.xxx.xx:4321
   FD         39
   FUUID      6101217c-f33f-845e-7af3-15abaf529882ad39
   MeterType  SML
   NAME       Stromzaehler
   NR         12581
   PARTIAL   
   STATE      opened
   TYPE       OBIS
   READINGS:
     2021-07-28 13:24:15   state           opened
   helper:
     BUFFER     �55(0000�0���5��
!�
�HAG5eHZ0�0�_��űZA�0�

�-0:0.0.0��55(�9��0�-50���53��
�-0:�.�.���55(0�699�.�0�3��
�-0:�.�.���55(03�95�.�0����
�-0:96.5.5��55(����
0-0:96.�.�55��55(0000�0���5��
!�
�HAG5eHZ0�0�_��űZA�0�

�-0:0.0.0��55(�9��0�-50���53��
�-0:�.�.���55(0�699�.�0�3��
�-0:�.�.���55(03�95�.�09���
�-0:96.5.5��55(����
0-0:96.�.�55��55(0000�0���5��
!�


I read modifying the device would help, but not in my case....


What can i do now?

Many Thanks for your helping hand again.


Heiner
--------------------------------
fhem auf Pi3+
CUL 868MHz, Signalduino 434MHz, HM-CFG-USB
HM, THZ, Kostal, Somfy, Conbee, Pytonbinding, FritzBox, FTUI, MQTT2