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

**URL:** <https://discourse.nodered.org/t/in-nodered-how-to-send-data-integer-four-bytes-to-tcp-device/31826>\
**Category:** General\
**Created:** [21 August 2020 11:57 UTC](https://discourse.nodered.org/t/in-nodered-how-to-send-data-integer-four-bytes-to-tcp-device/31826 "2020-08-21T11:57:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 August 2020 12:11 UTC](https://discourse.nodered.org/t/in-nodered-how-to-send-data-integer-four-bytes-to-tcp-device/31826/2 "2020-08-21T12:11:17Z")

</div>

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](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

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...

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

```

Here is some proof...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8cdc22addf7ddc4b72e06617d8eabc607aafdc1b.png)

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

In [this post here](https://discourse.nodered.org/t/ascii-convert-control-character/26140/8) an example where I calculated CRC in a function node for another user - you might be able to adapt it.

---

_[View the full topic](https://discourse.nodered.org/t/in-nodered-how-to-send-data-integer-four-bytes-to-tcp-device/31826)._
