Modbus for HLK DIO 16

Tags: #<Tag:0x00007f173f221548>

Hello I’m enu here and have a problem. I got four Modbus controllers with 16 inputs and 16 outputs. I would like to integrate this into openhup. but does not know how the Modbus is doing that can be addressed via TCP. can any of you tell me how I think I can address the individual coils.

I got a regestrie list, but I don’t understand these values
e.g .:
Output control command / 0x00 / Output Action / Low byte valid, high byte reserved / Action type (low 4 bits): 0x00 off , 0x01 on, 0x02 flip , 0x03 jog; Execution mode (optional): Whether bit7 is executed cyclically, whether bit6 is delayed or not;

thank you for everyone who takes care of my problem.

As a general approach;
openHAB Modbus is not really suitable for experimentation, you need toknow what you are trying to do.
Some 3rd party utility like Simply Modbus is better to workout how your devices act.

I don’t understand them either, let’s make some guesses.

Output control command / 0x00
Little idea what that means in isolation. An address, a pattern?
Maybe it just means each binary output is controlled by one register.

Using that idea -
Action type (low 4 bits): 0x00 off ,
send 00to turn output off
0x01 on,
0x02 flip ,
toggle the output, i.e.change to opposite state
0x03 jog;
“jog” is used sometimes in Chinglish manuals to mean “turn output on for a short time.”
Somewhere else, you can probably select that time.

You’re also going to need register addressing information, and find out how to set unit IP address, as you have multiples.

No idea what that means.

Hi, thanks for your reply. I’ve already tried to find out something with Simply Modbus. But I don’t understand what to enter there, I don’t get an answer. I am connected to the actuator.
Modbus looks so simple but what I have here from the manufacturer is, I think, all in HEX. I’ve been trying to work with it for months. I have three of the four at merbaut with buttons and settings. The app is all great. Only if I want to switch output x from actuator 1 after active input x to actuator 2 does not work with the app.
How can I send a command to the modbus in open hup? as a thing I have created:

UID: modbus:tcp:e51eeb9ae6
label: Modbus TCP Slave
thingTypeUID: modbus:tcp
timeBetweenTransactionsMillis: 60
connectMaxTries: 1
reconnectAfterMillis: 0
port: 8080
timeBetweenReconnectMillis: 0
connectTimeoutMillis: 10000
id: 1
enableDiscovery: true
indent preformatted text by 4 spaces


It is simple as a protocol
that means you have to do everything yourself, there is no self identification, few conventions about how things should work between one manufacturer and another.
That makes it hard for us!

I don’t know what any of that means. App?

I really recommend using some independent modbus utility to explore your devices. You will get nowhere doing it with openHAB unless you know what you are doing. If you can’t get them to work with a utility, you won’t get them to work with OH.
This is going to be a long road.

Simply Modbus is not the simplest utility to use, it was just an example None of them are simple, but there are others. Try another, like modbus-poll

You would find it easier to try setting up reads before writes.

But to write -
You first send an openHAB command to an OH Item.
You do that from a UI or from a rule.
You will need to have chosen your Items type, if you have no idea about Modbus you might start with a Number type there.

The Item needs to be linked to a channel, which will describe what register address and type to write to.
The channel needs to be linked to a Bridge Thing, which will describe the target device -IP and ID in this case.

Looks reasonable, if you have put the correct addresses in.

I do not think you want enableDiscovery, that is for a few special solar extensions. Set it false.

On its own, this Thing will do nothing. You would usually add poller Bridge Things to read register groups, and data Things to read or write individual registers.

Okay, I’ve done some homework
HLK DIO-16 is this device, yes?

There is a datasheet

From what I can tell, the device runs proprietary HLK protocol over ethernet or WiFi. It does not appear to support Modbus-TCP.

The device also has an R485 wired serial port, which appears to support Modbus-RTU.
You would be able to talk from openHAB to these devices over Modbus wired serial, maybe using a USB-RS485 adaptor at your openHAB host.
The datasheet does not give any detail register addresses or how to set device ID, so there is still the unknowns you began with.

But in summary, I think you’re wasting your time trying Modbus-TCP over network.