Hello there, I am trying to make my own node with arduino comunicating by modbus. After some fighting I got working reading of input register (slave1 in my cfg). But I am unable to control coils; with 3rd party modbus master I am.
Inside arduino, the 1st register contains distance from ultrasonic sensor, then in next register are 4 bits for relays / outputs.
1st issue is that I didn’t see any writing modbus function in logs yet. For coil it should be “5”.
2nd, small, issue is that modbus polling (binding) is not started automaticaly now, I am working with it like I am stopping and restarting binding from karaf console, because when I have been editing files, sometimes the tty got blocked, and I was unable to free it to use it again…
So this is my node.items
:
// Number waterpit_level "Water Pit Level [%s]" <cistern> (ALL) {modbus="slave1:0"}
// Number waterpit_outs (ALL) {modbuss="slave2:0"}
Switch waterpit_pump "Water Pit Pump" (ALL) {modbus=">slave3:0"}
// Switch waterpit_elm1 "Water Pit eValve 1" (ALL) {modbus=">slave4:0"}
// Switch waterpit_elm2 "Water Pit eValve 2" (ALL) {modbus=">slave5:0"}
// Switch waterpit_elm3 "Water Pit eValve 3" (ALL) {modbus=">slave6:0"}
These are my slaves in modbus.cfg
:
#serial.slave1.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
#serial.slave1.id=1
#serial.slave1.start=0
#serial.slave1.length=1
#serial.slave1.type=input
#serial.slave1.valuetype=uint16
#serial.slave2.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
#serial.slave2.id=1
#serial.slave2.start=1
#serial.slave2.lenght=1
#serial.slave2.type=holding
#serial.slave2.valuetype=uint16
serial.slave3.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
serial.slave3.id=1
serial.slave3.start=16
#serial.slave3.valuetype=bit
serial.slave3.type=coil
#serial.slave4.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
#serial.slave4.id=1
#serial.slave4.start=1
#serial.slave4.type=coil
#serial.slave5.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
#serial.slave5.id=1
#serial.slave5.start=2
#serial.slave5.type=coil
#serial.slave6.connection=/dev/ttyAMA0:19200:8:none:1:rtu:150
#serial.slave6.id=1
#serial.slave6.start=3
#serial.slave6.type=coil
this is my main.sitemap
:
sitemap main label="My home automation"
{
Frame label="Water Pit"
{
/* Text item=waterpit_level label="Value [%s]" */
Switch item=waterpit_pump label="Pump"
/* Switch item=waterpit_elm1 label="ELM 1"
Switch item=waterpit_elm2 label="ELM 2"
Switch item=waterpit_elm3 label="ELM 3" */
}
}
I am trying different things, for example using transformations in bindings everything except simple definition w/o < or > is not working, getting parsing errors …
Switch waterpit_pump "Water Pit Pump" (ALL) {modbus=">[slave3:0:trigger=ON, transformation=65535]"}
// or
Switch waterpit_pump "Water Pit Pump" (ALL) {modbus=">[slave3:0:valuetype=bit]"}
Also I do not understand, why the slave is still polled by reading when I am just writing to it…
2017-06-11 23:22:12.320 [INFO ] [b.core.service.AbstractActiveService] - Modbus Polling Service has been started
2017-06-11 23:22:12.407 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:12.439 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:13.487 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:13.507 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:14.558 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:14.573 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:15.617 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:15.632 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:16.677 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:16.693 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:17.737 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:17.751 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:18.797 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:18.811 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:19.857 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:19.871 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:20.918 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Sent: 01 01 00 10 00 00 3d cf
2017-06-11 23:22:20.945 [DEBUG] [t.wimpi.modbus.io.ModbusRTUTransport] - Response: 01 01 00 21 90
2017-06-11 23:22:21.966 [INFO ] [b.core.service.AbstractActiveService] - Modbus Polling Service has been shut down
Last thing … it is somehow possible to reset modbus binding without restartin RPI? I found out that there some configurations are left in /var/lib/openhab2/config/org/openhab/modbus.config
even I will change the modbus.cfg
and restart RPI. I have to delete that file before restart…
I must say I am very confused from binding wiki page