Hallo Community,
ich bin vor kurzem auf ioBroker gestoßen und komme auch ganz gut zurecht damit.
Jetzt wollte ich eine Kommunikation zu einem Modbus Teilnehmer aufbauen und bleibe einfach hängen.
Ich habe einen QNAP NAS auf dem ich mehrere LXD Container kreiert habe.
Unter anderem auch den ioBroker Container. MQTT klappt prima (hauptsächlich Panasonic Aquera, Heishamon).
Nun wurde ich waghalsig und wollte einen Technische Alternative Regler UVR610 Modb über einen USB-Adapter anbinden.
USB etwas mühevoll an den LXD Container gekoppelt und mit einen Tool Modpoll 3.10 die Verbindung getestet.
klickerkram@ubu2204-iobroker01:~$ ~/modpoll/x86_64-linux-gnu/modpoll --help
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Usage: modpoll [OPTIONS] SERIALPORT|HOST [WRITEVALUES...]
Arguments:
SERIALPORT Serial port when using Modbus ASCII or Modbus RTU protocol
COM1, COM2 ... on Windows
/dev/ttyS0, /dev/ttyS1 ... on Linux
HOST Host name or dotted IP address when using MDBUS/TCP protocol
WRITEVALUES List of values to be written. If none specified (default) modpoll reads data.
General options:
-m ascii Modbus ASCII protocol
-m rtu Modbus RTU protocol (default if SERIALPORT contains a /)
-m tcp MODBUS/TCP protocol (default otherwise)
-m udp MODBUS UDP
-m enc Encapsulated Modbus RTU over TCP
-a # Slave address (1-247 for serial, 0-255 for TCP, 1 is default)
-r # Start reference (1-65536, 100 is default)
-c # Number of values to read (1-125, 1 is default), optional for writing (use -c 1 to force FC5 or FC6)
-t 0 Discrete output (coil) data type
-t 1 Discrete input data type
-t 3 16-bit input register data type
-t 3:hex 16-bit input register data type with hex display
-t 3:int 32-bit integer data type in input register table
-t 3:mod 32-bit module 10000 data type in input register table
-t 3:float 32-bit float data type in input register table
-t 4 16-bit output (holding) register data type (default)
-t 4:hex 16-bit output (holding) register data type with hex display
-t 4:int 32-bit integer data type in output (holding) register table
-t 4:mod 32-bit module 10000 type in output (holding) register table
-t 4:float 32-bit float data type in output (holding) register table
-i Slave operates on big-endian 32-bit integers
-f Slave operates on big-endian 32-bit floats
-e Use Daniel/Enron single register 32-bit mode (implies -i and -f)
-0 First reference is 0 (PDU addressing) instead 1
-1 Poll only once only, otherwise every poll rate interval
-l # Poll rate in ms, (1000 is default)
-o # Time-out in seconds (0.01 - 10.0, 1.0 s is default)
Options for MODBUS/TCP, UDP and RTU over TCP:
-p # IP protocol port number (502 is default)
Options for Modbus ASCII and Modbus RTU:
-b # Baudrate (e.g. 9600, 19200, ...) (19200 is default)
-d # Databits (7 or 8 for ASCII protocol, 8 for RTU)
-s # Stopbits (1 or 2, 1 is default)
-p none No parity
-p even Even parity (default)
-p odd Odd parity
-4 # RS-485 mode, RTS on while transmitting and another # ms after
klickerkram@ubu2204-iobroker01:~$ ~/modpoll/x86_64-linux-gnu/modpoll -b 19200 -p none -m rtu -a 10 -t 3:int -i -r 1 -c 20 /dev/ttyUSB0
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 10, start reference = 1, count = 20
Communication.........: /dev/ttyUSB0, 19200, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 32-bit integer, input register table
Word swapping.........: Slave configured as big-endian word machine
-- Polling slave... (Ctrl-C to stop)
[1]: 162
[3]: 16383
[5]: 16383
[7]: 16383
[9]: 163830
[11]: 16383
[13]: 0
[15]: 0
[17]: 0
[19]: 0
[21]: 0
[23]: 0
[25]: 0
[27]: 0
[29]: 0
[31]: 500
[33]: 0
[35]: 0
[37]: 0
[39]: 0
-- Polling slave... (Ctrl-C to stop)
[1]: 162
[3]: 16383
[5]: 16383
[7]: 16383
[9]: 163830
[11]: 16383
[13]: 0
[15]: 0
[17]: 0
[19]: 0
[21]: 0
[23]: 0
[25]: 0
[27]: 0
[29]: 0
[31]: 500
[33]: 0
[35]: 0
[37]: 0
[39]: 0
-- Polling slave... (Ctrl-C to stop)
[1]: 162
[3]: 16383
[5]: 16383
[7]: 16383
[9]: 163830
[11]: 16383
[13]: 0
[15]: 0
Werte werden super abgefragt. Mit den Formaten musste ich etwas spielen, aber es funktioniert. Das ist genau der gleiche LXD Container auf dem auch ioBroker läuft
Dann gibt es im ioBroker den Adapter modbus. Installiert und Parametriert so wie ich es mir vorstellen konnte.
Ich kann hier gerade keine Bilder einfügen:
Daher versuche ich die Einstellung zu beschreiben:
Verbindungsparameter:
Seriell / /dev/ttyUSB0 / 19200 / 8 / 1 / none / 10 (Geräte ID) / Mehrere Geräte
Allgemein:
nur Alisas benutzen angewählt
2023-12-12 18:21:49.721 - info: host.ubu2204-iobroker01 "system.adapter.modbus.0" enabled
2023-12-12 18:21:49.766 - info: host.ubu2204-iobroker01 instance system.adapter.modbus.0 started with pid 12523
2023-12-12 18:21:51.155 - debug: modbus.0 (12523) Redis Objects: Use Redis connection: 127.0.0.1:9001
2023-12-12 18:21:51.190 - debug: modbus.0 (12523) Objects client ready ... initialize now
2023-12-12 18:21:51.193 - debug: modbus.0 (12523) Objects create System PubSub Client
2023-12-12 18:21:51.194 - debug: modbus.0 (12523) Objects create User PubSub Client
2023-12-12 18:21:51.213 - debug: modbus.0 (12523) Objects client initialize lua scripts
2023-12-12 18:21:51.222 - debug: modbus.0 (12523) Objects connected to redis: 127.0.0.1:9001
2023-12-12 18:21:51.239 - debug: modbus.0 (12523) Redis States: Use Redis connection: 127.0.0.1:9000
2023-12-12 18:21:51.246 - debug: modbus.0 (12523) States create System PubSub Client
2023-12-12 18:21:51.247 - debug: modbus.0 (12523) States create User PubSub Client
2023-12-12 18:21:51.257 - debug: modbus.0 (12523) States connected to redis: 127.0.0.1:9000
2023-12-12 18:21:51.284 - debug: modbus.0 (12523) Plugin sentry Initialize Plugin (enabled=true)
2023-12-12 18:21:51.677 - info: modbus.0 (12523) starting. Version 4.0.4 in /opt/iobroker/node_modules/iobroker.modbus, node: v18.19.0, js-controller: 5.0.16
2023-12-12 18:21:51.806 - debug: modbus.0 (12523) Initialize Objects for disInputs: []
2023-12-12 18:21:51.807 - debug: modbus.0 (12523) Initialize Objects for coils: []
2023-12-12 18:21:51.807 - debug: modbus.0 (12523) Initialize Objects for inputRegs: [{"_address":30001,"name":"val1","description":"","unit":"","type":"uint32le","len":2,"factor":1,"offset":0,"formula":"","role":"value","room":"","cw":"","isScale":"","address":0,"deviceId":10,"id":"inputRegisters.30001_val1"},{"_address":30003,"name":"val2","description":"","unit":"","type":"uint32le","len":2,"factor":1,"offset":0,"formula":"","role":"value","room":"","cw":"","isScale":"","address":2,"deviceId":10,"id":"inputRegisters.30003_val2"}]
2023-12-12 18:21:51.808 - debug: modbus.0 (12523) Add inputRegisters.30001_val1: {"_id":"inputRegisters.30001_val1","type":"state","common":{"name":"","role":"value","type":"number","read":true,"write":false,"def":0,"unit":""},"native":{"regType":"inputRegs","address":0,"deviceId":10,"type":"uint32le","len":2,"offset":0,"factor":1}}
2023-12-12 18:21:51.809 - debug: modbus.0 (12523) Add inputRegisters.30003_val2: {"_id":"inputRegisters.30003_val2","type":"state","common":{"name":"","role":"value","type":"number","read":true,"write":false,"def":0,"unit":""},"native":{"regType":"inputRegs","address":2,"deviceId":10,"type":"uint32le","len":2,"offset":0,"factor":1}}
2023-12-12 18:21:51.809 - debug: modbus.0 (12523) Initialize Objects for holdingRegs: []
2023-12-12 18:21:51.863 - debug: modbus.0 (12523) Remove old object modbus.0.inputRegisters.0_val1
2023-12-12 18:21:51.863 - debug: modbus.0 (12523) Remove old object modbus.0.inputRegisters.2_val2
2023-12-12 18:21:52.167 - debug: modbus.0 (12523) connect to serial /dev/ttyUSB0 with 19200
2023-12-12 18:21:52.175 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:21:53.178 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:22:53.179 - debug: modbus.0 (12523) connect to serial /dev/ttyUSB0 with 19200
2023-12-12 18:22:53.181 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:22:54.182 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:23:54.182 - debug: modbus.0 (12523) connect to serial /dev/ttyUSB0 with 19200
2023-12-12 18:23:54.183 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:23:55.184 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:24:55.184 - debug: modbus.0 (12523) connect to serial /dev/ttyUSB0 with 19200
2023-12-12 18:24:55.185 - warn: modbus.0 (12523) On error: {}
2023-12-12 18:24:56.186 - warn: modbus.0 (12523) On error: {}
Das dort modbus 4.0.4 gestartet bitte nicht stören, das waren verzweifelte Versuche , weil 5.0.11 nichts tat.
Ja und nun zu meiner Frage an die hoffentlich Wissenden.
Wenn ich das CLI Tool auf der selben Maschine startet, bekomme ich Werte und kann am USB Stecker die LED's blinken sehen wenn Kommunikation läuft.
Beim ioBroker Adapter Modbus blinkt nix.
Kann es sein, dass mir noch eine Middleware zwischen Adapter Modbus und /dev/ttyUSB0 fehlt??
Wenn ich Adressen falsch habe oder die Baudrate etc falsch habe müsste ich doch wenigstens die LED des USB RS485 blinken sehen.
Berechtigungen?
ioBroker ist in dialout.
Würde mich freuen, wenn mir jemand auf die Sprünge helfen könnte.
Gruß Wolfgang