Sure!
Here’s some examples
modbus.things
Reads from from a serial device, configures serial parameters. Holding registers are polled every 500ms. Values are extracted from the holding registers to things read1
and read2
. Furthermore, write1
thing is defined in order to tell how commands to readwriteCollector
should be handled. In this case the are written as int16
register (first register)
Bridge modbus:serial:endpoint [ port="/dev/ttyS0", baud=9600, id=1, stopBits="1.0", parity="none",dataBits=8, echo=false, encoding="rtu", flowControlIn="none", flowControlOut="none", receiveTimeoutMillis=1500 ] {
Bridge poller poller1 [ start=0, length=3, refresh=500, type="holding" ] {
Bridge readwrite readwriteCollector {
Thing read read1 [ start=0, transform="default", trigger="*", valueType="int16" ]
Thing read read2 [ start=1, transform="default", trigger="*", valueType="int16" ]
Thing write write1 [ start=0, transform="default", trigger="*", valueType="int16", type="holding" ]
}
}
}
modbus.items
Number NumberItemTest "Number readwrite [%f]" { channel="modbus:readwrite:endpoint:poller1:readwriteCollector:number" }
modbus.sitemap
sitemap modbus label="Modbus"
{
Frame {
Text item=NumberItemTest
}
}
###To install the modbus binding
- Install serial transport:
feature:install openhab-transport-serial
- install modbus transport bundle (copy it to addons folder, see this thread if you are unsure)
- install modbus binding bundle (same way as the transport bundle)
- List modbus bundles
bundle:list | grep -i modbus
. If necessary, start them withbundle:start BUNDLENUMER
The bundles are not visible via Eclipse IOT openhab addon (reason unknown, discussed here). However, you can download the jar
files manually for installation.
Best,
Sami
UPDATE: corrected NumberItemTest
channel reference.