Modbus network commands: Read/write to modbus subnet device over RTU

I have a modbus RTU relay module connect to the main RS485 of the T3 Nano ESP. I try to search on this forum about send command to on/off the relay with programing with T3000 but not clearly understand.

The relay module have address FF (255), T3 address 1, hex command to turn on the relay:

FF 0F 00 00 00 08 01 FF 30 1D

30 1D is the CRC
Command to turn on the relay:

FF 0F 00 00 00 08 01 00 70 5D

70 5D is the CRC
Command to red relay status:

FF 01 00 00 00 08 28 12

I have test and it work with USB-RS485 adapter but I want to control the module with T3000.
I try some code like

1.255.MB_REG1 = 0F0000000801FF301D

for on command but it failed.

You cannot use 255 as the modbus address of the relay module, and the modbus address of the relay module cannot be the same as that of the T3 Nano ESP.
if T3 Nano ESP ,and panel is 144

if the RTU relay module modbus id is 4
If the register controlling the RTU relay module is 12

Use the following line to turn on the relay if the relay module vendor defines a register with 12 addresses as “on”

10 144.4.MB_REG12 = 1
20 144.4.MB_REG12 = 0
3

What about CRC, is it auto calculated by the T3 Nano? I changed the relay module to address 02 and try your code but it’s not working. My T3 Nano panel ID is one, I connect the RS485 relay module to main port and set it as master.

10 1.2.MB_REG12 = 1

Update: this is the relay module and command format: Modbus-Rtu 2 Channel Relay Module RS485/TTL Communication Output Modbus-Rtu 2 Channel Relay Module RS485/TTL Communication Output [RKI-4450] - ₹760.00 : Robokits India, Easy to use, Versatile Robotics & DIY kits

The 1 byte before the stop bit is the CRC check, which belongs to the Modbus standard protocol.

Register 12 is an example, and you need to confirm which register is the one that controls your third-party device.
And you need to figure out what value is written to turn on the relay of this third-party device.
Third party modbus devices will usually give you a register table, which should explain how to operate the register.
“= 1“ means write value 1 to this register. I’m assuming here that write 1 to turn on the third-party device relay.

Yes, I have try multiple value, I also read this post Using the T3-BB controller to read & write to modbus tcp & BACnet/IP sensors - #5 by DonatoM
The module have 2 relay.

The command turn relay 1 on:

02 05 00 00 FF 00 8C 09

8C 09 is CRC
The command turn relay 1 off:

02 05 00 00 00 00 CD F9

CD F9 is CRC

  • 02 is address of the module on the Modbus
  • 05 I guest is write single coil command
  • Byte 3 and 4 is the relay, 00 00 is the relay 1. 00 01 is relay 2
  • Byte 5 and 6 is on/off command: 00 00 for off and 00 FF for on.

So it is 64 bit but, I read that your app only support 16, If you have experience please help me in detail, I take days and could not make it work.

Never mind, I use standard write coil to the relay address and it work with:

10 1.2.MB_COIL1 = 1

I recommend that you do the following to verify the communication and that the device responds to these modbus commands.
5


7

If the preceding steps can communicate properly, the relay can also be turned on and off normally. In check 10 1.2.MB_COIL1 = 1 is not working properly.


Check whether the remote point has a record of recent operations.

If you still can’t find the cause, it could be something else. You can send an email to our sales, tell us your remote assistance Anydesk ID, we make an appointment, we can provide you with remote assistance.

1 Like