# Send hexadecimal value to serial port

**URL:** https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537
**Category:** General
**Created:** [13 April 2023 15:05 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537 "2023-04-13T15:05:21Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [13 April 2023 15:05 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/1 "2023-04-13T15:05:21Z")

</div>

hi, I'm currently working on a project where i need to send data over the serial port. data are in hexadecimal form so, i did put them in a buffer following this code before sending them.

```auto
var data = [0x7E,0xA0,0x07,0x03,0x21,0x93,0x0F,0x01,0x7E];
var buffer= Buffer.from(data)
msg.payload = buffer;

```

the issue is when i send this value, my device doesn't reply like it didn't get the correct form of the payload, can somebody nudge me in the right path, thanks in advance.

---

<div class="post-metadata">

### Author: ![jw\_te\_r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jw_te_r/32/69700_2.png) [@jw\_te\_r](https://discourse.nodered.org/u/jw_te_r)
#### Post date: [14 April 2023 17:08 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/2 "2023-04-14T17:08:06Z")

</div>

It should work. I did it the same way and it works nicely.  
Are you 100% sure the message is correct?

Other things to check: port settings (baud rate, parity, data bits, stop bits)  
Write rights? Is your Node-Red user in the user group Dialout?  
Etcetera.

---

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [15 April 2023 21:28 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/3 "2023-04-15T21:28:41Z")

</div>

yes, when i send the payload to the serial port, following all parameters as given, the device doesn't reply as it should.  
i had checked the communication with the port by passing in a handshake frame (main characters was in ascii) and the device reply.  
this made me think that the data sent aren't in hex type.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d011b721e8c1f6cafe16eb98fe20003fd3cd3fd2.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: [15 April 2023 21:51 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/4 "2023-04-15T21:51:57Z")

</div>

Do you need something like an “enter” character at the end ?

---

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [15 April 2023 21:59 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/5 "2023-04-15T21:59:39Z")

</div>

what do you mean like " enter"? i have manually configure my serial node to add every time CRLF to each frame out . do you mean that?

---

<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: [16 April 2023 00:28 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/6 "2023-04-16T00:28:31Z")

</div>

What is the protocol? Is it a well known protocol? Is there a manual?

What is the handshake frame data made up of - show us how you did that.

---

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [16 April 2023 20:36 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/7 "2023-04-16T20:36:10Z")

</div>

the protocol is IEC 62056-21. the handshake frame is  
`[0x2f, 0x3f, 0x21, 0x0D, 0x0A]`  
the aim of this feed to get your guidance on how to know if my device is replying after sending a frame of hex value.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [16 April 2023 20:51 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/8 "2023-04-16T20:51:00Z")

</div>

> [@zeus8497](#):
>
> how to know if my device is replying after sending a frame

Are you using a Serial Request node? If so then any received data should be passed on in a message.

---

<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: [16 April 2023 21:18 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/9 "2023-04-16T21:18:36Z")

</div>

By enter I do mean adding \n or \r or whatever is necessary. I see it actually needs 0x0d 0x0a which is both so you may need to add them manually rather than letting the node just add one.

---

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [17 April 2023 01:05 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/10 "2023-04-17T01:05:47Z")

</div>

actually, i'm working with the serial in and out node to get a better view of the stream

---

<div class="post-metadata">

### Author: ![zeus8497](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zeus8497/32/78740_2.png) [@zeus8497](https://discourse.nodered.org/u/zeus8497)
#### Post date: [17 April 2023 01:09 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/11 "2023-04-17T01:09:33Z")

</div>

okay got it, at the beginning i was adding them manually but i figure it out they give the same outcome as they were added in the node.  
and following some software doing the same stuff that i want to do, they don't add 0D0A after the handshake

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [17 April 2023 13:34 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/12 "2023-04-17T13:34:06Z")

</div>

> [@zeus8497](#):
>
> i'm working with the serial in and out node to get a better view of the stream

Presumably you are not seeing anything on a debug node connected to the serial in node, or you would have said.

Select the serial In and Out nodes, Export them and paste it here so we can see how you have configured them.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [16 June 2023 13:34 UTC](https://discourse.nodered.org/t/send-hexadecimal-value-to-serial-port/77537/13 "2023-06-16T13:34:36Z")

</div>

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