Strategies in Node-Red for a 200 sensor install

I am a novice user of Node Red.

I recently purchased an Enterprise Gateway and 2 Bidirectional pressure sensors for my initial testing. I now have the 2 sensors sending their pressure data to a Blynk dashboard using node red by following this example; modifying to my sensor type and outputting just the pressure:

My goal is to have 200 of these sensors installed at a single site, all sending their pressure values to a single Blynk dashboard.

Any suggested strategies in node red that I could use, rather than just duplicating the node red flow 200 times, manually renaming each sensor within each flow?

-David

Hi David,

Can you export and share your node-red flow so we can review? @Eduardo_Mtz can make some suggestions to optimize the flow, more than likely using the Wireless Gateway node rather than wireless device nodes.

Thank you,
Travis Elliott

Hi Travis,

How do I send it to you?

-David

Hi @dmwengineering Sure, In Node-RED go to main menu and click on “Export” option.
image

Then click on “Copy to clipboard” button:

Return to ncd community and click on “Performatted text”:
image

Paste your flow in JSON format:
image

Let us know if you have any questions.
Thanks,
Eduardo M.

I do not want to post company data/info on a public forum. How do I send to you?

@dmwengineering Okay, no problem. Let me check the basic Blynk flow you used as a base, and I will send you a flow example. If I need more information I will let you know.

1 Like

Hi @dmwengineering I share with you an example to manage multiples of your NCD pressure and temperature sensors with a single function node and MQTT out node.

[{"id":"372806d2e7c24b76","type":"function","z":"37c8e44a35e28282","name":"ncd to blynk","func":"let mac_device = msg.payload.addr.substring(12);\nmac_device = mac_device.replaceAll(\":\",\"\");\nlet pressure = msg.payload.sensor_data.pressure;\nlet temperature = msg.payload.sensor_data.temperature;\n\nmsg.payload = mac_device;\nnode.send([msg, null]);\n\nmsg = {\n    topic: \"ds/\" + mac_device + \"_pressure\",\n    payload: pressure\n}\nnode.send([null, msg]);\n\nmsg = {\n    topic: \"ds/\" + mac_device + \"_temperature\",\n    payload: temperature\n}\nnode.send([null, msg]);","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":970,"y":120,"wires":[["683fd7d271645c11"],[]]},{"id":"683fd7d271645c11","type":"debug","z":"37c8e44a35e28282","name":"mac","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":100,"wires":[]}]

You can copy the following JSON code, then go to the main menu in Node-RED, select the import option, then paste the code into the text input box, finally press the import button.

You should connect the output of the “Wireless Gateway” node to the input of the “ncd to blynk” node, as well as the output number 2 of the “ncd to blynk” node to the input of your MQTT node configured with the Blynk credentials.

flow_

But be sure this time iside MQTT node to leave the “Topic” property blank, as this time the MQTT topic will be dynamic.

To manage your NCD pressure temperature sensors inside Blynk we are going to use the MAC address, this address is unique in each NCD sensor, we will use it to identify from which sensor the pressure and temperature signal comes from.

I have added a “debug” node called “mac” this node will allow you when a new data arrives from the sensor, to visualize and obtain the last 8 characters of the MAC address of your NCD sensor (you can also observe the MAC address of each device in the physical sensor). You should write down/copy this value, as you will have to use it inside Blynk.

For each sensor you must create its respective element inside Blynk, but this time you must add inside the property “NAME” the last 8 characters of the MAC address of the sensor, underscore and the name of the variable:

For example:

So, in theory, this flow allows you that every time you add a new sensor, you only have to create the object in Blynk adding its MAC address in the identifier NAME, on the Node-RED side you should not add anything, the following image shows how the messages are constructed.

Note: At the moment I don’t have a Blynk account to test the code, please let me know your results.

Please take a look at this, test it, share if it works or let us know if you have any questions.

Thank you,
Eduardo M.

1 Like

Thanks Eduardo… will keep you posted on my testing…

It appears to work. Data streams as expected. I do get this error in the debug… not sure what is causing it.

Hi @dmwengineering Great, could you copy this code and paste inside the “ncd to blynk” function node, it is the same logic, but this time I’ve added a filter to avoid this “TypeError”.

if (msg.topic == "sensor_data"){
    let mac_device = msg.payload.addr.substring(12);
    mac_device = mac_device.replaceAll(":","");
    let pressure = msg.payload.sensor_data.pressure;
    let temperature = msg.payload.sensor_data.temperature;

    msg.payload = mac_device;
    node.send([msg, null]);

    msg = {
        topic: "ds/" + mac_device + "_pressure",
        payload: pressure
    }
    node.send([null, msg]);

    msg = {
        topic: "ds/" + mac_device + "_temperature",
        payload: temperature
    }
    node.send([null, msg]);
}

Please try this and share with us your results or let us know if you have any questions.
Thank you,
Eduardo M.

Works great. Thank you.

Now we just need to solve this and we will be good to go…

-David