Hi,
anoybody succesfull atached EMH NXT4 smart meter via smart meter binding 2.5.5 ?
Installed openhab 2.5.5 on RPi4 Buster 4GB
emh.items
Number:Energy EnergyPlus “Energy+ [%.2f kWh]” { channel=“smartmeter:meter:emh:1-0_1-8-0” }
Number:Energy EnergyMinus “Energy- [%.2f kWh]” { channel=“smartmeter:meter:emh:1-0_2-8-0” }
emh.things
smartmeter:meter:emh [port="/dev/ttyUSB1", baudrateChangeDelay=250, refresh=180, mode=“ABC”]
Channels:
Type 1-0:1.8.0 : 1-0_1-8-0 #positive energy
Type 1-0:2.8.0 : 1-0_2-8-0 #negative energy
}
I’m using ttyUSB1 RS485-USB converter.
With python script I can read out answer from NXT4. 300Bd, 7E1,
init string: /?!<0D><0A>
Via Python script I can read out all values:
*!/usr/bin/python
import serial
import sys
import time
-
configure the serial port
port = serial.Serial(
port=’/dev/ttyUSB1’,
baudrate=300,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.SEVENBITS,
timeout=2,
xonxoff=False,
rtscts=False,
dsrdtr=False
) -
Send /?!<0D><0A>
str0 = b’\x2f\x3f\x21\x0d\x0a’ -
write opening string to serial port
port.write(str0) -
loop readline all other data from port (but only with 300Bd !!!)
for x in range(1, 119):
str = port.readline()
print(str)
port.close()
/dev/ttyUSB0 is used to communicate with APC UPS device.
I have also modified /etc/default/openhab2
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyUSB1"
and disabled bluetooth and ttyAMA0
User openhab is in gropus tty and dialout
The problem is that the loop answers are readout correctly but only with 300Bd.
I would prefer to change the speed to 9600Bd for the rest of data.
Via Windows program, transfer beginns with 300Bd 7E1 for opening string
and proceeds next datasets with 9600Bd 7E1.
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 003: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub ### /dev/ttyUSB0 APCUSBD
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
python -m serial.tools.list_ports -v
/dev/ttyUSB0
desc: US232R # SUA1000 APCUPSD
hwid: USB VID:PID=0403:6001 SER=FTGVERLS LOCATION=1-1.2
/dev/ttyUSB1
desc: FT232R USB UART #EMH smart meter
hwid: USB VID:PID=0403:6001 SER=AC02545Z LOCATION=1-1.3
2 ports found
Thanks for help.
Jozef