Turn On and Off Mist Maker When the Humidity is Compared with the Humidity Set By the User

Hello, I'm trying to compare the humidity given by a sensor to the maximum humidity set by the user. If the humidity is above the humidity set by the user the mist maker turns off else it continues running. Been stuck on this problem for days any help would be amazing. [ { "id": "9b43da8bf82bae27", "type": "tab", "label": "Sets When the Pod's Turn On ", "disabled": false, "info": "", "env": [] }, { "id": "425e96850f0d167b", "type": "serial in", "z": "9b43da8bf82bae27", "name": "Arduino", "serial": "6dc75486fa724c57", "x": 270, "y": 480, "wires": [ [ "28a94542b9a7f2bc" ] ] }, { "id": "28a94542b9a7f2bc", "type": "function", "z": "9b43da8bf82bae27", "name": "DHT11 Data Transform", "func": "m = msg.payload.split(',');\nH = {payload:parseFloat(m[0])};\nreturn [H];\n\n", "outputs": 1, "noerr": 3, "initialize": "", "finalize": "", "libs": [], "x": 510, "y": 480, "wires": [ [ "3751947b2642ad5a" ] ] }, { "id": "1f732145346433c2", "type": "ui_slider", "z": "9b43da8bf82bae27", "name": "", "label": "Slider", "tooltip": "", "group": "0f27424b1e504c56", "order": 0, "width": 0, "height": 0, "passthru": true, "outs": "end", "topic": "", "topicType": "str", "min": 0, "max": "100", "step": 1, "className": "", "x": 450, "y": 420, "wires": [ [ "3751947b2642ad5a" ] ] }, { "id": "90c9726cc2aea105", "type": "rpi-gpio out", "z": "9b43da8bf82bae27", "name": "Pod One's Water Atomiser", "pin": "24", "set": true, "level": "0", "freq": "", "out": "out", "bcm": true, "x": 1100, "y": 480, "wires": [] }, { "id": "340a4182a03d5dee", "type": "catch", "z": "9b43da8bf82bae27", "name": "", "scope": null, "uncaught": false, "x": 460, "y": 340, "wires": [ [] ] }, { "id": "3751947b2642ad5a", "type": "function", "z": "9b43da8bf82bae27", "name": "Function One", "func": "if(H < msg.payload) msg.payload = 1;\nelse msg.payload = 0;\nreturn [msg];\n\n", "outputs": 1, "noerr": 1, "initialize": "", "finalize": "", "libs": [], "x": 800, "y": 480, "wires": [ [ "90c9726cc2aea105" ] ] }, { "id": "6dc75486fa724c57", "type": "serial-port", "serialport": "/dev/ttyACM0", "serialbaud": "9600", "databits": "8", "parity": "none", "stopbits": "1", "waitfor": "", "dtr": "none", "rts": "none", "cts": "none", "dsr": "none", "newline": "\\n", "bin": "false", "out": "char", "addchar": "", "responsetimeout": "10000" }, { "id": "0f27424b1e504c56", "type": "ui_group", "name": "Pod Controller", "tab": "3621bd84478fa19f", "order": 1, "disp": true, "width": "12", "collapse": false, "className": "" }, { "id": "3621bd84478fa19f", "type": "ui_tab", "name": "Pod Controller", "icon": "dashboard", "disabled": false, "hidden": false } ]

Hi @KatieCook, welcome to the forum.

Can you show us an example of the data that flows from your Arduino node into the first function node?

Hi jbubb,
Thank you for responding. An example is: 53.00,24.60. Where 53.00 is the humidity and 24.60 is the temperature.

Feed the Arduino node into a debug node then hover over the data and click on the Copy button that pops up. Paste that here. That will allow us to see the form of the data better. When you paste it use the </> button at the top of the forum entry window.

Thank you Colin,

When I copy it, it just comes out as 53.00, 24.60, like before. But I've attached a screenshot of the debug node panel.

raspberrypi.local (raspberrypi) - VNC Viewer 27_11_2022 16_31_48

You have not provided the data in the form required, please read my post again and do what I suggested. That allows us to use the data you paste and put that into a debug node so that we can simulate your data.

From what you have posted we can see that it is a string, and also that it is of length 13, which means that there are two unprintable characters, which is a bit odd.
Also it is telling us that you also have a javascript object coming from the Arduino node, which is also odd. Or is that coming from somewhere else? Generally it is best to feed data into different debug nodes, and give them different names, so that it is clear what data is coming from where.

Yes, there is something odd about that input data.
If I inject the string "55.00,24.30" into a debug node I see this
Untitled 2

Which is a) string[11] and b) displayed in debug wrapped between quotes (This might be because we run NR on different platforms. I use Linux)

So we certainly need you to post some actual data rather than a screenshot please.

Do you have control of the Arduino code? If you could get it to send eg "{humidity: 53.0, temperature: 24.60}" it will probably be easier to extract the value as in Node-red as JSON.

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