Newbie, having problem setting a coil with Modbus RTU

I'm trying to write a single coil on a modbus RTU relay board (RS485).
I'm using Modbus-contrib-serial Library.
I'm able to read value from another board on the same bus using Modbus serial In
I'm able to set the coil using another program. (
[19:44:28,813] <--:01 05 00 07 FF 00 3D FB
[19:44:28,891] -->:01 05 00 07 FF 00 3D FB
[19:44:47,641] <--:01 05 00 08 00 00 4C 08
[19:44:47,703] -->:01 05 00 08 00 00 4C 08 )
For the case device address is 01 coil is #7.

Can someone help me with the parameters I need to pass to modbus serial out ?
I tried to format a buffer using binary rpm without success

[{"id":"bce5d2b8.b20d9","type":"debug","z":"f8edcdbe.3d29c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":910,"y":2720,"wires":[]},{"id":"63a52c55.0c9b64","type":"function","z":"f8edcdbe.3d29c","name":"Set Modbus Read Parameters for Serial Number","func":"//Fermer relais #8 \n//[19:44:28,891] -->:01 05 00 07 FF 00 3D FB \n//Ca marche, les adresses vont de 00 a 0F\nmsg.payload = { //'unitid': 0x01,\n 'fc': 0x05,\n 'address': 0x007, // read address\n 'type': 0xFF00\n //,'chc': 0x3DFB\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":2860,"wires":[["bce5d2b8.b20d9","933c5f71.26dea"]]},{"id":"7d9598cd.2e6b78","type":"inject","z":"f8edcdbe.3d29c","name":"","topic":"/1","payload":"On","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"4","x":450,"y":2860,"wires":[["bce5d2b8.b20d9","63a52c55.0c9b64"]]},{"id":"592b7c3.7a94c84","type":"modbusSerial out","z":"f8edcdbe.3d29c","port":"773e9c89.131534","slave":"","start":"0","dtype":"coil","topic":"","name":"","x":1510,"y":2860,"wires":[]},{"id":"a10f743c.7bbb58","type":"inject","z":"f8edcdbe.3d29c","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"4","x":450,"y":2960,"wires":[["bce5d2b8.b20d9","61cafbf2.78d8d4"]]},{"id":"933c5f71.26dea","type":"binary","z":"f8edcdbe.3d29c","name":"","property":"payload","pattern":"b16 => fc, b32 => address ,b16 => type","x":1230,"y":2860,"wires":[["592b7c3.7a94c84","bce5d2b8.b20d9"]]},{"id":"61cafbf2.78d8d4","type":"function","z":"f8edcdbe.3d29c","name":"Set Modbus Read Parameters for Serial Number","func":"//Fermer relais #8 \n//[19:44:28,891] -->:01 05 00 07 FF 00 3D FB \n//Ca marche, les adresses vont de 00 a 0F\nmsg.payload = { // 'unitid': 0x01,\n 'fc': 0x05,\n 'address': 0x007, // read address\n 'type': 0x0000\n //'chc': 0x3DFB\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":2960,"wires":[["933c5f71.26dea"]]},{"id":"773e9c89.131534","type":"modbusSerialConfig","z":"","port":"/dev/ttyUSB0","baud":"9600","data":"8","parity":"none","stop":"1","name":""}]

thanks for your help

I can't import your code, check if you have formatted it correctly

I've edited your post and fixed the import,

Thanks for the format correction.

I've made several test today with monitoring of data on the bus:
a) 'modbus serial out' node seems to be limited to multiple coil writing ( 0F code when coil is selected)
I'm able to select type of action ; device address(01) ;start address (0A) through menu but still have no control on datas probably due to input (mis-) formatting.
reading on the bus is like this -->:01 0F 00 0A 00 08 01 04 67 57

b) I also tried modbus write (node-red-contrib-modbus) but I doesn't initialize (Always restarting). @9600baud 8bit +1stop also

On top of this my chinese board support single coil write but I'm not able for the moment of a multiple writing. I Don't expect that much support from supplier but it is on the way.

Any suggestion / direction is welcome.

Is it possible to pass a complete message and let the node just deal with CRC?

note: I noticed a unknown (at least to me) message just after a deploy: 01 19 80 00 80 00 01 9F BA
EE. Does someone knows what 19 stand for ?


01 05 00 07
if it can help you it should be like this:
01 tool id
05 single coil write function
0007 memory area to write to.

you should still get the protocol manual to see if any characters are needed at the end of the string (CR).

to write also try to use the node node-red-contrib-modubus -> "ModbusWrite"

mdb1 mdb2

Hello, I've made a fresh install with noobs and magic has worked!
node-red-contrib-modubus -> "ModbusWrite" is now working.

Thanks for your support.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.