# How to send HEX buffer via NodeRed

**URL:** <https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439>\
**Category:** General\
**Created:** [21 June 2021 12:36 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439 "2021-06-21T12:36:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NatanST](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@NatanST](https://discourse.nodered.org/u/NatanST)\
**Post date:** [21 June 2021 12:36 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/1 "2021-06-21T12:36:44Z")

</div>

Hi!

I'm a newbie using Node-RED and I'm having some issues when I try to send messages in HEX. This is the conversion table that I need:

![01 - table](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/38d4892482254889e318c9a6eaf7a2d0826bbc3e.png)

I have a setup with 4 stepper motors and I'm connecting through bluetooth. My idea is to controll the motors with Node-RED. The first test that I made was using my cellphone and it worked with the following "setup".

 ![03 - works](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e036e34de1f517363ca25242313afcde4638cb3.jpeg)

What I need to do is to send this messages with Node-RED, but I'm having trouble converting it. What's the easiest way to do it? Using a msg.payload (buffer) as

"["254","254","254","254","254","254","254","254"]" that's my answer.

buffer[8][raw](http://127.0.0.1:1880/#)

0: 0xfe  
1: 0xfe  
2: 0xfe  
3: 0xfe  
4: 0xfe  
5: 0xfe  
6: 0xfe  
7: 0xfe

 ![02 - code](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d44e8d9f922497848ab30234bc614ad5df14ff5.png)

Using this function I managed to send a Buffer [5] with the return of 01 FE, but it doesn't work.

> msg.payload = Buffer("01 FE");  
> Buffer.toString('hex');  
> return msg;

Thanks in advance!

---

<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 June 2021 14:56 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/2 "2021-06-21T14:56:57Z")

</div>

Hi it is not 100% clear what you are trying to achieve.

Are you providing a page where you can enter a value in HEXADECIMAL that should then be transmitted to the bluetooth node as a byte array / buffer?

e.g. if your entry was `01 FE` you want to have a buffer of `[1,254]` transmitted?

---

<div class="post-metadata">

**Author:** ![NatanST](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@NatanST](https://discourse.nodered.org/u/NatanST)\
**Post date:** [23 June 2021 19:28 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/3 "2021-06-23T19:28:56Z")

</div>

Hi, Steve!

My problem was a typo, I'm sorry... It is done and if anyone is looking for the same thing, here's how I'm doing:

Motor 01 - clockwise:

> msg.payload = new Buffer([01,254]);  
> return msg;

Motor 01 - anti-clockwise

> msg.payload = new Buffer([02,253]);  
> return msg;

Thanks!

---

<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:** [23 June 2021 19:48 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/4 "2021-06-23T19:48:32Z")

</div>

`new Buffer(...)` is depreciated.

This is the correct way...

```auto
msg.payload = Buffer.from([1, 254]);
return msg;

```

```auto
msg.payload = Buffer.from([2, 253);
return msg;

```

---

<div class="post-metadata">

**Author:** ![NatanST](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@NatanST](https://discourse.nodered.org/u/NatanST)\
**Post date:** [24 June 2021 17:22 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/5 "2021-06-24T17:22:33Z")

</div>

Oh, updated here, thank you!

---

<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:** [23 August 2021 17:23 UTC](https://discourse.nodered.org/t/how-to-send-hex-buffer-via-nodered/47439/6 "2021-08-23T17:23:01Z")

</div>

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