# Node-Red buffer

**URL:** https://discourse.nodered.org/t/node-red-buffer/17727
**Category:** General
**Created:** [10 November 2019 01:31 UTC](https://discourse.nodered.org/t/node-red-buffer/17727 "2019-11-10T01:31:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![New2Node](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@New2Node](https://discourse.nodered.org/u/New2Node)
#### Post date: [10 November 2019 01:31 UTC](https://discourse.nodered.org/t/node-red-buffer/17727/1 "2019-11-10T01:31:03Z")

</div>

Hi, I’m new to Node-Red so I’m just working my way through all the various nodes.

I want to use Node-Red to read an Electricity meter which uses IEC 62056-21 protocol. I have the meter connected over RS232, if I use the meter software I can read it, but if I send the same serial commands using an inject node and Serial node, I don’t get a response.

I used a COM port monitor to record all the data on the TX, RX lines. So I have all the commands sent by the meter software, I need to somehow copy the TX data to Node-Red to replicate the meter software.

So, I think I need a buffer? The command I need to send to the meter is “/?! “ which is ASCII? The meter then responds with HEX data (Voltage, current, Meter Serial number...).

How do I convert this string “/?! “ In Node-Red so the meter understands the request?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [10 November 2019 11:46 UTC](https://discourse.nodered.org/t/node-red-buffer/17727/2 "2019-11-10T11:46:26Z")

</div>

I think that you need to check the hex values of what is being sent first.

This guide tells you how to use binary buffers with Node-RED:

[http://www.steves-internet-guide.com/understanding-buffers-node-red/](http://www.steves-internet-guide.com/understanding-buffers-node-red/)

As for input, you need to understand how a response is terminated. This cropped up the other day on the forum. Not all serial outputs are terminated with a line-feed. They may be of a specific length for example. Or you may need to wait for a timeperiod to know when to let the serial-in node send the data it received.

---

<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: [10 November 2019 16:02 UTC](https://discourse.nodered.org/t/node-red-buffer/17727/3 "2019-11-10T16:02:43Z")

</div>

Hi - if it really is ascii “/?! “ then you may not need a buffer ... but you may need to add a line feed \n or carriage return \r to the end to "hit the enter key"

Or in the inject node for example you can insert a buffer

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e64dfb3a8cc2ac3b071682d3977333c5dc8972d3.png)  
and if you hit the 3 dots on the right you can see it expands to show the hex  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fd526615c202a57df840d4ea27b293b2e995cf73.png)  
(and in this case see there is an extra blank space at the end.... so it may or may not really be ascii)

---

<div class="post-metadata">

### Author: ![New2Node](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@New2Node](https://discourse.nodered.org/u/New2Node)
#### Post date: [11 November 2019 12:58 UTC](https://discourse.nodered.org/t/node-red-buffer/17727/4 "2019-11-11T12:58:48Z")

</div>

Hi everyone, I’ve got a little bit further!

I used a function node with the message:  
Msg.paylaod= “/?!\r\n” and I’ve got a response! [image|640x480](https://discourse.nodered.org/uploads/short-url/gSaxUOlI0sgc2dLVFFd6Fps3CAX.jpeg) ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/57b568618450839760003096b64ce2276ff9ce84.jpeg) ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c5edfe81b95d6e86b689e0c0cd3d7f982ae43dfc.jpeg)

Now I need to send a list of commands to the meter in the same function. For example  
Message 1 (/?!\r\n)  
Wait 1 sec  
Message 2 (XXX)  
Wait 1 sec  
Message 3 (XXX)...

I can then log all the responses and convert it into meter data. I’ve uploaded the list of commands I need to send to the meter.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 November 2019 13:27 UTC](https://discourse.nodered.org/t/node-red-buffer/17727/5 "2019-11-11T13:27:29Z")

</div>

Assuming that the response also ends in \r\n then the default settings on the serial-in node will work fine.

Then just a matter of splitting the resulting strings (change nodes), reformatting to whatever data you need.
