[Solved] ModBus and cheap 4 relay module (D18994)

Hello !

I have a cheap relays module with ModBus support integrated. I`ve tested it with my debug scripts and it works well. Here is my short manual about it: link (russian lang). Relays on this card could not be accessed as coils and another scheme used instead.
For example if i need to enable relay number 2 i should write value 0x0200 to holding register 2, and i should write 0x0100 if it need to be changed back to open state.
My question is: how to use such kind of control scheme as reular Switch item if it is possible? I have a led lamp connected to such board and i need to enable and disable it with some schedule or manually.

I think you can use the newly updated Modbus binding version

A trsnsformation of Openhab Switch Item ON/OFF to Modbus holding register number values should be possible.


I`m not experienced with modbus and OH at a moment :frowning: but i will try to understand how to use it. I will post results there.
Thanks again for your response !

Seems i not enough experienced yet (in OH configuration mostly) to understand how to bind different modbus commands (and may be check its state) for Switch item. Ive trying to build vegitables micro-farm in own room and this relay module should be used for activation/deactivation of light and water pump. It was mounted before i`ve found OH.

Thanks to @rossko57 for help again!

It works!
Here is example that switching On/Off relay 2 on such board:

Board definition as modbus device. (Note that register numbers on such devices starting from 1, not from 0. eg 1-4) :


Item definition:

Switch Light  "Main Light" (ALL)   {modbus=">[slave2:1:trigger=ON,transformation=256],>[slave2:1:trigger=OFF,transformation=512]"}

This line will write to holding register 2 (with index 1 in my modbus definition) on device slave2 numerical values 256 (0x0100) to switch relay to Closed state and 512 (0x0200) backwise as described in device documentation.

Note, that you should upgrade modbus binding in order to enable transformation functionality.


Great to hear the new binding works for you!


1 Like

Thank you very much for great job!


Hi all,

I have the same relay board. I want to controll my roller shutter with it. In my Installation I would like to have 2 relays to control 1 roller shutter. So one is for up and one for down. So I could define 2 relays like that:

Switch Light “Roller1 up” (ALL) {modbus=">[slave2:0:trigger=ON,transformation=256],>[slave2:0:trigger=OFF,transformation=512]"}
Switch Light “Roller1 down” (ALL) {modbus=">[slave2:1:trigger=ON,transformation=256],>[slave2:1:trigger=OFF,transformation=512]"}

Is it also possible to unify both relays into 1 item/switch? So that I have UP, DOWN and STOP as triggers?

Something like that:
Switch Light “Roller1” (ALL) { … }

  • STOP sends 512 to both holding registers
  • UP sends 256 to the first and 512 to the second register
  • DOWN sends 512 to the first and 256 to the second register

Thanks for supporting me


I think it should be possible, just add more entries like >[…] with same trigger.


Would this be possible?

Switch Light “Roller1” (ALL)

Looks good to me. Let me know if it does not work.


Hi thanks for the support.

I have a stupid question.

If I have my item defined as follows:
Switch Relay1 “Relay1” (ALL) {modbus=“slave1:1”}
and the modbus (sniffed on bus) has the expected telegram.

But for the relay card I need to have a transformation from 1 to 0100 and from 0 to 0200. Therefore I added the following:

Switch Relay1 “Relay1” (ALL) {modbus=">[slave1:1:trigger=*,transformation=256],>[slave1:1:trigger=0,transformation=512]"}
Unfortunately after that change I have no telegram on bus.

What I am doing wrong?

Do I need to install anything, that this transformation works?


regards Daniel


You need the 1.10.0-SNAPSHOT as indicated in the docs. Transformation was introduced there. You should find installation instructions somewhere from here.

If you have that version already, it might be worthwhile to check logs for any errors


Edit : perhaps this thread helps with the installation Replacing openhab2 Paper UI installed binding with custom jar