Modbus-node write coil

#1

Hi,

I read value from modbus coil and the node returns it as {data : array [8], buffer[1])
when it works and when switch on only data [0]= true and the others false.
I am trying to write value which true or false in this modbus, but I cant know how can I write it in code? I tried Join to convert True value as array, but it doesn't work.
I am not familiar too much with JavaScript, so could you help me, please?

0 Likes

#2

It is not clear to me whether your problem is in decoding the received data, working out what to set the output to, or sending the new value via modbus.

By the way it is not java scripts it is javascript, which is not related to Java. Zero out of ten for those making up the names in the first place.

0 Likes

#3

Sorry for this mistake, I know it is JavaScript and I fixed it.
My question is about writing to modbus coil (sending the new value via modbus). I want to switch the coil on/off. but I don't know how to do it exactly.
In case of reading, it displays as array data[8], and only the first element data[0] is true in case of coil is on and the other elements are false. That means the coil status is only in the first element data[0].
I want send data to put this element false or true. This command should send to the modbus write node. I configured it with address and force single or multiple coil, but in both cases I cant figure out how to write it. I tried many things but they didn't work.

0 Likes

#4

So rather than trying to explain what you want give an example...

What does the data look like from the coil, what have you tried?

0 Likes

#5

I think that @manal is able to interpret the input ok but does not know how to write the required state to the output.

0 Likes