Automatic sprinkler system

Dear people can anyone help me with the following. Il recently installed a rain gauge. Now I want to link my irrigation system to this. What I want to do with this is quite simple and I do the following.
I want to take a measurement at the beginning of the day and then at the end of the day to do another 1 there is a difference of 15mm of rain between the two measurements, then my sprinkler system may remain off, because there has been enough rain. Does anyone know with which node I can do this. Preferably by writing as little code as possible.

So a node that gets a start value has an end value, if it is more than 15mm then it must give an output with which I can block the sprinkling.

gr Vlak

I have a rain gauge which outputs a constantly increasing number. I've used node-red-contrib-totaliser to give hourly and daily rain values. I have configured it to output a diff between the start and end value within the given time frame.

Hi ristomatti, can you show me your flow. and especially your totaliser settings

Here's an example flow:

[{"id":"300a494.de2d8b6","type":"totaliser","z":"a9d2ff30.566fd","output":"diff","interval":"24","intervalUnits":"hours","name":"rain 24h","x":380,"y":60,"wires":[["759e1649.e180d8"]]},{"id":"759e1649.e180d8","type":"change","z":"a9d2ff30.566fd","name":"total","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.total","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":120,"wires":[["377cda53.066d56"]]},{"id":"377cda53.066d56","type":"debug","z":"a9d2ff30.566fd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":120,"wires":[]},{"id":"38a1987d.4056e8","type":"inject","z":"a9d2ff30.566fd","name":"simulated rain start value 0ml","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":160,"y":60,"wires":[["300a494.de2d8b6"]]},{"id":"d1bc5a19.edf318","type":"inject","z":"a9d2ff30.566fd","name":"simulated rain value 8ml","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"8","payloadType":"num","x":150,"y":120,"wires":[["300a494.de2d8b6"]]}]

Note that the totaliser node outputs the payload.total value only after the set period is reached so you likely want to change the time frame in the example to for example 10 seconds for testing. I just copied part of my current flow there.

ok, I don't get this. I cannot read a programming language. can I copy it in the node or how should I see this?

Here is another way to do it.

[{"id":"dc03d983.08016","type":"inject","z":"2a10ff07.234f98","name":"Start at morning","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":640,"wires":[["a7d099e2.a9ef1","b1f4786b.55af"]]},{"id":"a7d099e2.a9ef1","type":"function","z":"2a10ff07.234f98","name":"Get rain value","func":"msg.payload = 2;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":640,"wires":[["fe562e34.d05758"]]},{"id":"b1f4786b.55af","type":"delay","z":"2a10ff07.234f98","name":"Delay to afternoon","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":120,"y":690,"wires":[["2f0ca91a.61cd8e"]]},{"id":"fe562e34.d05758","type":"join","z":"2a10ff07.234f98","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":640,"wires":[["92d6d5d5.f38818"]]},{"id":"92d6d5d5.f38818","type":"function","z":"2a10ff07.234f98","name":"Compare","func":"let difference = (msg.payload[1] - msg.payload[0]);\nmsg.payload = difference;\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":690,"wires":[["7f6d53af.f083cc"]]},{"id":"7f6d53af.f083cc","type":"debug","z":"2a10ff07.234f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":720,"y":690,"wires":[]},{"id":"2f0ca91a.61cd8e","type":"function","z":"2a10ff07.234f98","name":"Get rain value","func":"msg.payload = 20;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":690,"wires":[["fe562e34.d05758"]]},{"id":"f136ec43.d281e","type":"comment","z":"2a10ff07.234f98","name":"Read me *","info":"The two `function` nodes are here only to simulate getting the readings.\nYou will have to use your nodes here and the signal is to get the node to send out an output.\nActually you would only need one node.  I use two to return two values so as to show how it works.\n","x":350,"y":600,"wires":[]}]

You use the code posted by clicking to the left of the area and click on the clipboard icon which will appear.

Go to your node-red edit screen, select IMPORT and paste the code there.
That is the top right corner the burger (menu) button in Node-Red.

1 Like

You'll need to copy the code and import from Node-RED menu as explained by @Trying_to_learn. This way you can experiment with it yourself.

Sorry dude, I wasn't wanting to mean your way was worse than mine.

Given @Vlak is new, adding more foreign nodes only complicates things. I know my way had a few tricks, but I don't think it is/was too hard.

And sorry I didn't actually look at the code you posted. But if you had those nodes needed, I wouldn't have them anyway.

I believe contrib nodes have their place. Especially handling dates is somewhat cumbersome in function nodes and at least I would have found using a contrib node easier than a function node of I was new to Node-RED. :slightly_smiling_face:

Yeah, fair enough.

Anyway, so long as a working solution is found: that's all that matters, huh?

1 Like

ok, thanks guys.
I think i should be able to deal with this.

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