I have installed the changes @bwduncan has made to EmonModbusTcpInterfacer.py.
Sys log: syslog.txt (1.6 KB)
emonHub logs below with various options tried, none have been successful unfortuantely.
Settings:
[[ModbusTCP]]
# this interfacer retrieves register information from modbusTCP clients
Type = EmonModbusTcpInterfacer
[[[init_settings]]]
modbus_IP = 192.168.1.60 # ip address of client to retrieve data from
modbus_port = 9999 # Portclient listens on
[[[runtimesettings]]]
# List of starting registers for items listed above
register = 16,18
# nodeid used to match with node definition in nodes section below. Can be set to any integer value not previously used.
nodeId = 9334
# Channel to publish data to should leave as ToEmonCMS
pubchannels = ToEmonCMS,
# time in seconds between checks, This is in addition to emonhub_interfacer.run() sleep time of .01
# use this value to set the frequency of data retrieval from modbus client
interval = 10
[[9334]]
nodename = USR
[[[rx]]]
names = Voltage L1,Voltage L1
datacodes = i,i
scales = 0.1,0.1
units = V,V
Log:
2021-03-27 16:09:24,680 INFO ModbusTCP Not connected, retrying connect
{'modbus_IP': '192.168.1.60', 'modbus_port': '9999'}
2021-03-27 16:09:24,682 INFO ModbusTCP Opening modbusTCP connection: 9999 @
192.168.1.60
2021-03-27 16:09:24,683 DEBUG ModbusTCP expected bytes number after encoding:
8
2021-03-27 16:09:24,684 DEBUG ModbusTCP datacode i
2021-03-27 16:09:24,684 DEBUG ModbusTCP reading register #: 16, qty #: 2, unit #: 1
2021-03-27 16:09:24,749 ERROR ModbusTCP Connection failed on read of register: 16 :
Settings:
[[ModbusTCP]]
# this interfacer retrieves register information from modbusTCP clients
Type = EmonModbusTcpInterfacer
[[[init_settings]]]
modbus_IP = 192.168.1.60 # ip address of client to retrieve data from
modbus_port = 9999 # Portclient listens on
[[[runtimesettings]]]
# List of starting registers for items listed above
register = 0x0010,0x0012
# nodeid used to match with node definition in nodes section below. Can be set to any
integer value not previously used.
nodeId = 9334
# Channel to publish data to should leave as ToEmonCMS
pubchannels = ToEmonCMS,
# time in seconds between checks, This is in addition to emonhub_interfacer.run()
sleep time of .01
# use this value to set the frequency of data retrieval from modbus client
interval = 10
[[9334]]
nodename = USR
[[[rx]]]
names = Voltage L1,Voltage L1
datacodes = i,i
scales = 0.1,0.1
units = V,V
Log:
2021-03-27 16:16:20,400 WARNING MainThread ModbusTCP thread is dead.
2021-03-27 16:16:20,401 WARNING MainThread Attempting to restart thread
ModbusTCP (thread has been restarted 1 times...)
2021-03-27 16:16:20,402 INFO MainThread Creating EmonModbusTcpInterfacer
'ModbusTCP'
2021-03-27 16:16:20,403 INFO MainThread pymodbus installed
2021-03-27 16:16:20,404 DEBUG MainThread EmonModbusTcpInterfacer args:
192.168.1.60 - 9999
2021-03-27 16:16:20,406 INFO MainThread Opening modbusTCP connection: 9999 @
192.168.1.60
2021-03-27 16:16:20,406 INFO MainThread Modbustcp client Connected
2021-03-27 16:16:20,407 DEBUG MainThread Setting ModbusTCP register: ['0x0010',
'0x0012']
2021-03-27 16:16:20,408 DEBUG MainThread Setting ModbusTCP nodeId: 9334
2021-03-27 16:16:20,408 DEBUG MainThread Setting ModbusTCP pubchannels:
['ToEmonCMS']
2021-03-27 16:16:20,409 DEBUG MainThread Setting ModbusTCP interval: 10
2021-03-27 16:16:30,419 DEBUG ModbusTCP expected bytes number after encoding:
8
2021-03-27 16:16:30,421 WARNING ModbusTCP Exception caught in ModbusTCP
thread. Traceback (most recent call last):
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 32, in wrapper
return func(*args)
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 99, in run
rxc = self.read()
File "/opt/openenergymonitor/emonhub/src/interfacers/EmonModbusTcpInterfacer.py", line
154, in read
register = int(registers[idx])
ValueError: invalid literal for int() with base 10: '0x0010'
Settings:
[[ModbusTCP]]
# this interfacer retrieves register information from modbusTCP clients
Type = EmonModbusTcpInterfacer
[[[init_settings]]]
modbus_IP = 192.168.1.60 # ip address of client to retrieve data from
modbus_port = 9999 # Portclient listens on
[[[runtimesettings]]]
# List of starting registers for items listed above
register = 10,12
# nodeid used to match with node definition in nodes section below. Can be set to any
integer value not previously used.
nodeId = 9334
# Channel to publish data to should leave as ToEmonCMS
pubchannels = ToEmonCMS,
# time in seconds between checks, This is in addition to emonhub_interfacer.run()
sleep time of .01
# use this value to set the frequency of data retrieval from modbus client
interval = 10
[[9334]]
nodename = USR
[[[rx]]]
names = Voltage L1,Voltage L1
datacodes = i,i
scales = 0.1,0.1
units = V,V
Log:
2021-03-27 16:26:38,243 INFO MainThread Creating EmonModbusTcpInterfacer
'ModbusTCP'
2021-03-27 16:26:38,244 INFO MainThread pymodbus installed
2021-03-27 16:26:38,245 DEBUG MainThread EmonModbusTcpInterfacer args:
192.168.1.60 - 9999
2021-03-27 16:26:38,247 INFO MainThread Opening modbusTCP connection: 9999 @
192.168.1.60
2021-03-27 16:26:38,248 INFO MainThread Modbustcp client Connected
2021-03-27 16:26:38,249 DEBUG MainThread Setting ModbusTCP register: ['10', '12']
2021-03-27 16:26:38,249 DEBUG MainThread Setting ModbusTCP nodeId: 9334
2021-03-27 16:26:38,250 DEBUG MainThread Setting ModbusTCP pubchannels:
['ToEmonCMS']
2021-03-27 16:26:38,250 DEBUG MainThread Setting ModbusTCP interval: 10
2021-03-27 16:26:38,251 INFO MainThread Creating EmonHubMqttInterfacer 'MQTT'
2021-03-27 16:26:38,254 DEBUG MainThread Setting MQTT pubchannels: ['ToRFM12']
2021-03-27 16:26:38,255 DEBUG MainThread Setting MQTT subchannels:
['ToEmonCMS']
2021-03-27 16:26:38,255 INFO MainThread Setting MQTT node_format_enable: 1
2021-03-27 16:26:38,256 INFO MainThread Setting MQTT nodevar_format_enable: 1
2021-03-27 16:26:38,256 INFO MainThread Setting MQTT nodevar_format_basetopic:
emon/
2021-03-27 16:26:38,258 INFO MainThread Creating
EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2021-03-27 16:26:38,259 DEBUG MainThread Setting emoncmsorg pubchannels:
['ToRFM12']
2021-03-27 16:26:38,259 DEBUG MainThread Setting emoncmsorg subchannels:
['ToEmonCMS']
2021-03-27 16:26:38,260 WARNING MainThread Setting emoncmsorg apikey: obscured
2021-03-27 16:26:38,260 INFO MainThread Setting emoncmsorg url:
https://emoncms.org
2021-03-27 16:26:38,261 INFO MainThread Setting emoncmsorg senddata: 1
2021-03-27 16:26:38,261 INFO MainThread Setting emoncmsorg sendstatus: 1
2021-03-27 16:26:48,253 DEBUG ModbusTCP expected bytes number after encoding:
8
2021-03-27 16:26:48,254 DEBUG ModbusTCP datacode i
2021-03-27 16:26:48,254 DEBUG ModbusTCP reading register #: 10, qty #: 2, unit #: 1
2021-03-27 16:26:48,325 ERROR ModbusTCP Connection failed on read of register: 10 :
2021-03-27 16:26:58,437 INFO ModbusTCP Not connected, retrying connect
{'modbus_IP': '192.168.1.60', 'modbus_port': '9999'}
2021-03-27 16:26:58,439 INFO ModbusTCP Opening modbusTCP connection: 9999 @
192.168.1.60
2021-03-27 16:26:58,440 DEBUG ModbusTCP expected bytes number after encoding:
8
2021-03-27 16:26:58,441 DEBUG ModbusTCP datacode i
2021-03-27 16:26:58,441 DEBUG ModbusTCP reading register #: 10, qty #: 2, unit #: 1
2021-03-27 16:26:58,515 ERROR ModbusTCP Connection failed on read of register: 10
After each change in the settings (in the emonhub.conf file) I have restarted the emonHub service before capturing the log files.
I have also tried chnaging the function in EmonModbusTcpInterfacer.py to read the
read_input_registers()
and changed the config in the .conf file datatype to f from i as per the guidance in the original pdf but see similar errors in the logs.
[[9334]]
nodename = USR
[[[rx]]]
names = Voltage L1,Voltage L1
datacodes = f,f
scales = 0.1,0.1
units = V,V
Any ideas what I need to do next please? Thank you.