Node-Red buffer

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?

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:

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.

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

and if you hit the 3 dots on the right you can see it expands to show the hex

(and in this case see there is an extra blank space at the end.... so it may or may not really be ascii)

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 image image

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.

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.