In nodered how to send data integer (four bytes) to tcp device

Hi firstly, in order to make code more readable and importable it is important to post it between two sets of three backticks - ``` - see this post for more details - How to share code or flow json

You should go back and edit your post.

Secondly, setting msg.payload=00000008 is just setting the number 8 - e.g. you might as well have written msg.payload=8 - in other words, this in not correct.

It is more likely you need to send a Buffer

An example would be - to send 000000000000008c02010000013feb55ff74000f0ea850209a6900009400d6120000 you need to convert it to a bytes (a Buffer) which can be either hard coded or converted in a function node like this...

msg.payload = Buffer.from("000000000000008c02010000013feb55ff74000f0ea850209a6900009400d6120000","hex");
return msg;

Here is some proof...

Lastly, there is also a CRC to calculate to append to the end. This is not so straight forward.

In this post here an example where I calculated CRC in a function node for another user - you might be able to adapt it.

1 Like