# Sending an Hex Command over TCP

**URL:** <https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267>\
**Category:** General\
**Created:** [22 February 2019 10:15 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267 "2019-02-22T10:15:23Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 10:15 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/1 "2019-02-22T10:15:23Z")

</div>

Hi,

i´m trying to read out my Central Heating.  
It have an RS232 port and i will send an Command over Node-red (based on IoBroker), over a Usr-TCP232 (Serial Port converter).

 ![9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/34f210b3e2d60b22b9a7791eaa84c1697fea6566.jpeg)

I try to send this Hex Command:  
0x7B 0x4D 0x43 0x00 0x04 0x1F 0x0a 0x08 0x00 0x0d 0x7D

But i don´t get an Answer, i sent it via String.  
Sorry but i´m new and just begin to learn.

I hope some one understand my terrible Englisch an can help me 🙂

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [22 February 2019 11:45 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/2 "2019-02-22T11:45:20Z")

</div>

Whats the actual flow you are using in Node-RED?

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [22 February 2019 15:22 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/3 "2019-02-22T15:22:35Z")

</div>

> [@BastelKlaus](#):
>
> 0x7B 0x4D 0x43 0x00 0x04 0x1F 0x0a 0x08 0x00 0x0d 0x7D

You can't send it as a string because 0x00 is the string terminator and the receiver will see it as end of the string.  
You have to send it as bytes

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 17:54 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/4 "2019-02-22T17:54:47Z")

</div>

Thx for your fast response.

This is a Picture of my Flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9e73058df9b3199e9d48217dc71a109745a523c3.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 February 2019 17:55 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/5 "2019-02-22T17:55:28Z")

</div>

You will need to send it as a buffer type

eg like this

```auto
[{"id":"c43eb6d0.a40ec8","type":"inject","z":"df0a9f4b.bc75b","name":"","topic":"","payload":"[\"0x7B\",\"0x4D\",\"0x43\",\"0x00\",\"0x04\",\"0x1F\",\"0x0a\",\"0x08\",\"0x00\",\"0x0d\",\"0x7D\"]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":60,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 17:55 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/6 "2019-02-22T17:55:34Z")

</div>

The heater Company gave me a document: (Picture of an .pdf)

 ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e372b9510991e6c570d07901e2497515a3bba0fb.png)

and i read on a Homepage messages should be send as HEX so i tried it with String.  
How can i sen it as bytes?

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 18:04 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/7 "2019-02-22T18:04:48Z")

</div>

@dceejay

the same Message send as Buffer:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8a0ddeeab73ac181407de219afde8d73a4d7d6e2.png)

but i think this is not what you mean, sorry.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 February 2019 18:08 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/8 "2019-02-22T18:08:38Z")

</div>

hmm no... set up an inject... in binary mode (the 0110 logo)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/66208b5caf4e7f42adfac13ced02bbcea127a6d7.png)

with

["0x7B","0x4D","0x43","0x00","0x04","0x1F","0x0a","0x08","0x00","0x0d","0x7D"]

as the payload

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 18:22 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/9 "2019-02-22T18:22:00Z")

</div>

Ok i found it

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

Debug logs:  
22.2.2019, 19:10:50[node: c8667d1.f89de8](http://192.168.1.113:1880/#)msg.payload : undefined

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 18:32 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/10 "2019-02-22T18:32:10Z")

</div>

If i take a look on the webinterface of USR i can see:

Sending as String RX Count.  
Sending as Buffer first test RX Count.  
Sending as last test RX diden`t Count.

TX never counts ☹

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 February 2019 18:36 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/11 "2019-02-22T18:36:04Z")

</div>

Though also looking at the doc you pasted there should only be 7 bytes - so the message is too long...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9e3cc6686a96c75e241286abb12a1f2a6d389107.png)

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 18:46 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/12 "2019-02-22T18:46:54Z")

</div>

sorry i cant upload the complet .pdf.  
i use an example massage from a other hompage, witch i found.  
But he scribe his Code in C+.  
Could i post a link or is it unwanted in hear?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 February 2019 19:33 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/13 "2019-02-22T19:33:45Z")

</div>

What is wanted is an example you know works

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [22 February 2019 21:48 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/14 "2019-02-22T21:48:40Z")

</div>

The command request the Heater to send him Boiler temperature every 10 sec

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9806f2f25fdb77eedc1017153ad21b31a87010fa.png)

This should be the shortest command, it makes the heater stopping sending Informations:  
"{" "M" "E" 0 0 "}"  
0x7B 0x4D 0x45 0x00 0x00 0x7D

This is the link to his Page [C+ Heater request](http://ulrich-franzke.de/haustechnik/eta_programm1.html)

But it locks like nothing is sendet if i send request in binary mode.  
Only if i click on the ... the paylode is then morpht and it locks like on Debug and USR (web interface) it is sendet.

Thank you for your patience.

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [24 February 2019 08:48 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/15 "2019-02-24T08:48:45Z")

</div>

I tryed now a few inject tippings of the Code in Binary Mode

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0e5b2b62a0d51b93d4db785ac45354f98d8801e5.png)

Injects with "slash", wouldn't be send, debug log "undefined".  
I read in a other tread, that it should be type like "0x7B",  
But my heater never response.

@dceejay maybe you are right and my code is to long 🙄  
The datasheet is not clear for me, because its new for me.  
I try to contact the Heater Company next week, maybe they can help me.

Thx for all you help and Tips.

---

<div class="post-metadata">

**Author:** ![BastelKlaus](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@BastelKlaus](https://discourse.nodered.org/u/BastelKlaus)\
**Post date:** [25 February 2019 15:13 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/16 "2019-02-25T15:13:24Z")

</div>

Hi  
the answer to my problem was not only how to send the command in the right way like:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b3324490fbddb3e65cbc77459397addd1daac7dc.png)

I used a wrong hardware.  
At first i took a Serial cable like i read in the Dokument of the heater Company,  
but they changed an internal extension cable.  
So i have to take an crossed cabel.

No i get Answers from my Heater over USR-TCP232-302.

Thx for all your help and Tips, i hope it helps other People too.

---

<div class="post-metadata">

**Author:** ![Napalmcsr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/napalmcsr/32/30910_2.png) [@Napalmcsr](https://discourse.nodered.org/u/Napalmcsr)\
**Post date:** [13 October 2023 02:44 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/17 "2023-10-13T02:44:50Z")

</div>

So I am having issues even connecting node red tcp to the usr-tcp232. Can you share your tcp config and the web config of your usr-tcp?  
Thanks!

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [13 October 2023 09:21 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/18 "2023-10-13T09:21:18Z")

</div>

Always best to start a new thread rather than adding to a 5 year old one 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [13 October 2023 09:21 UTC](https://discourse.nodered.org/t/sending-an-hex-command-over-tcp/8267/19 "2023-10-13T09:21:22Z")

</div>


