Converting code to a node

Hey

Some years ago, I was interested in this project: https://github.com/crjens/PiPowerMeter

I got some of his boards and after quite some tinkering, I got it working.

Because I was not happy with the accuracy and didn't have the time to make it work properly, I left this project in the cupboard.

Now I want to give it another try. Unfortunately doing the install described on the github page is not working as there are many dependency errors.

As I'm now using Node-Red and InFluxdb for many of my home projects, I'd rather just implement this power meter into it.

Ideally, I have a node in Node-Red, where I can just inject a message saying which current channel, voltage channel and correction factor to use. And it would output a message containing current, voltage and power.

But how do I go about that? I can do some basic Javascript to make function nodes, but I have no clue on how to insert such a large amount of functions into 1 node.

Anybody that can give me some pointers, guides, help... so I can make this work?

Thanks a lot!

The easiest approach for this use case is using a subflow, then you can reuse the function.

Note that there is a big menu on the top of this site and one item is "documentation", both subflows and creating nodes is explained there.

Thanks.

So I would create a subflow with function nodes, and each function node contains 1 function from the javascript source file?

I actually looked for some information about this, but Google was not a good helper. Should've checked the nodered website of course... :man_facepalming:

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