node-p1-reader icon indicating copy to clipboard operation
node-p1-reader copied to clipboard

Using P1 node over TCP with ser2net

Open albertjve opened this issue 2 years ago • 5 comments

Hi Ruud, I have pi2 that is in my meter closet that is not running Node Red. I want to use it to bridge the serial P1 data over TCP using ser2net to the machine that runs node red.(How) Can this be done? Could I simply direct the p1 node to IP:port?

Alternatively I can tunnel the serial port via ser2net to the other machine, but this seems more complicated and requires more configuration than the option above. I hope you can help.

Kind regards, Albert

albertjve avatar Dec 08 '21 17:12 albertjve

Hi Albert,

I'm not familiar with ser2net but what I quickly read is that is send the raw serial port data over IP. This Node.js library parses serial data directly from a connected physical usb/serial port so that would not work.

So I guess you have 2 options: use ser2net and write your own serial parser to make sense out of the data (you can copy paste some logic of this library for the parsing), OR run a node.js script on the machine that is connected to the P1 port and let this library do it's magic :)

In the latter case you would need to have some input / listener defined in Node Red. A quick and dirty way could be to use the HTTP GET input of Node Red, copy the example.js file in this repo and extend that to make a GET request to the Node Red server. Then run that script on the Pi2 in the meter closet.

Off course HTTP has quite a lot of overhead so something like MQTT might be more appropriate but that would require an additional broker.

Good luck!

Ruud

ruudverheijden avatar Dec 09 '21 20:12 ruudverheijden

This is possible, I use it over here. P1 data is sent over ser2net. Node-red picks up the data (Node-red TCP in) and the packetParser lib (Node-red function) from Ruud is parsing the data to an object. :-)

timoline avatar Aug 08 '22 09:08 timoline

uick and dirty way could be to use the HTTP GET input of Node Red, copy the example.js file in this repo and extend that to make a GET request to the Node Red server. Then run that script on the Pi2 in the meter closet.

Hi Timoline, Due to limited node-red knowledge, could you please help, provide, shows your parser file? I have the P1 Raw data available in node-red.

thxs, much appreciated, Jeroen

jeroenkl avatar Feb 06 '23 19:02 jeroenkl

here is the flow flows.zip

timoline avatar Feb 10 '23 19:02 timoline

here is the flow flows.zip

Hi, thanks for this flow! It is realy great.

My skills are also limited but is it possible to modify the flatten function a bit so it removes all the lines with .unit and were the reading is null. This will reduce the mqtt load a lot.

Giel538 avatar Aug 15 '23 17:08 Giel538