# How to send Acknowledgement to device

**URL:** https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520
**Category:** General
**Created:** [15 December 2020 10:54 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520 "2020-12-15T10:54:35Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ptwtech](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Ptwtech](https://discourse.nodered.org/u/Ptwtech)
#### Post date: [15 December 2020 10:54 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/1 "2020-12-15T10:54:36Z")

</div>

Hello ,  
I want to send acknowledgement to device in hex format.  
I'm doing this.please help me how to send acknowledgement in hex format  
Thanks

var data;  
if(msg.payload.length == 17){  
data= stringToHex('01');  
}else{  
data= stringToHex('00','utf8');  
}  
msg.payload = data;  
return msg;

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [15 December 2020 11:20 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/2 "2020-12-15T11:20:00Z")

</div>

Add a `catch` node connected to a `debug` node (set to display the complete msg object) and see if that will lead you to figuring out your issue.

also, if you just want to send back a hex 0 or 1 why not to that? For reference take look at [https://www.w3schools.com/js/js\_numbers.asp](https://www.w3schools.com/js/js_numbers.asp) The section on Hexadecimal

---

<div class="post-metadata">

### Author: ![Ptwtech](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Ptwtech](https://discourse.nodered.org/u/Ptwtech)
#### Post date: [15 December 2020 11:57 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/3 "2020-12-15T11:57:17Z")

</div>

I want to send acknowledgement like this i.e 1 byte 0x01 or 0x00.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [15 December 2020 11:58 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/4 "2020-12-15T11:58:17Z")

</div>

if you just want to send back a hex 0 or 1 why not to that? For reference take look at [https://www.w3schools.com/js/js\_numbers.asp](https://www.w3schools.com/js/js_numbers.asp) The section on Hexadecimal

---

<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: [15 December 2020 13:09 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/5 "2020-12-15T13:09:48Z")

</div>

there is no such function `stringToHex` unless you make it.

hexadecimal 0x0 is simply `0` and hex 0x01 is simply `1`.

If you want to send a `hex string` then just set payload to `"00"` or `"01"`

---

<div class="post-metadata">

### Author: ![Ptwtech](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Ptwtech](https://discourse.nodered.org/u/Ptwtech)
#### Post date: [16 December 2020 05:26 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/6 "2020-12-16T05:26:44Z")

</div>

Actually, i also did this msg.payload =0x01; & msg.payload =0x00; in this scenario device getting 30 or 31

if(msg.payload.length == 17){  
msg.payload =0x01;  
}else{  
msg.payload =0x00;  
}  
return msg;

And also did this msg.payload ='01'; & msg.payload ='00'; in this scenario device getting D3.

if(msg.payload.length == 17){  
msg.payload ='01';  
}else{  
msg.payload ='00';  
}  
return msg;

Device Should be received 01 or 00.

---

<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 December 2020 08:00 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/7 "2020-12-16T08:00:08Z")

</div>

> [@Ptwtech](#):
>
> Actually, i also did this msg.payload =0x01; & msg.payload =0x00; in this scenario device getting 30 or 31

30 is ASCII `'0'` and 31 is ASCII `'1'` - something in the transmission path is converting the number in `payload` to a character before or during transmission.

I realise now you are trying to transmit `NUL` and `STX` - which are not really idea characters to send as ACK or NAK.

Can you share your flow so we can see if there is something is possible.

Alternatively, can you change the code in the other device to accept a string/ASCII response like "OK" or "NG"?

---

<div class="post-metadata">

### Author: ![Ptwtech](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Ptwtech](https://discourse.nodered.org/u/Ptwtech)
#### Post date: [16 December 2020 12:10 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/8 "2020-12-16T12:10:05Z")

</div>

![WhatsApp Image 2020-12-16 at 5.36.50 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d682d72978ee69459d26a4f039a2fd3e02d2bec2.jpeg) ![WhatsApp Image 2020-12-16 at 5.31.49 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb13d046adac92bfe2b1ba75f5e81b52cf24be21.jpeg)

i want to send acknowledgement to device ...should be sent as binary packet. I.e. 1 byte 0x01 or 0x00.

Thansks

---

<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 December 2020 13:37 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/9 "2020-12-16T13:37:29Z")

</div>

You need to share your flow - I cannot see how you have set the nodes from a screenshot.

Also, some questions...

- What is the End device?
- is it possible to change the end device to use something else (like a string or a different protocol)?

---

<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: [14 February 2021 13:37 UTC](https://discourse.nodered.org/t/how-to-send-acknowledgement-to-device/37520/10 "2021-02-14T13:37:36Z")

</div>

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