Raspi 3 Outputs in Ascending or Descending Order

#1

I would like to control three Raspi Outputs based on an Upper and Lower Value. Upper Value is 100. If value is above 100 turn on first output, if still above 100 after 10 seconds turn on second output and if still above 100 after another 10 seconds turn on third output. Lower Value is -1. If value is below -1 after 10 seconds turn off third output, if still below -1 after another 10 seconds turn off second output and if value is still below -1 after 10 seconds turn off first output. The flow that I am attaching is an example of just turning all three outputs on or off at the same time based on 100 Upper and -1 Lower Values.

[{"id":"1a271078.5500e","type":"ui_gauge","z":"523c97fe.704cb4","name":"","group":"77664b29.0411b4","order":0,"width":"6","height":"6","gtype":"gage","title":"gauge","label":"Units","format":"{{value}}","min":"-100","max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":374,"y":58,"wires":[]},{"id":"85df5463.af0248","type":"ui_slider","z":"523c97fe.704cb4","name":"","label":"slider","group":"77664b29.0411b4","order":0,"width":0,"height":0,"passthru":true,"topic":"","min":"-100","max":"200","step":1,"x":55,"y":58,"wires":[["1a271078.5500e","c72a5d1f.fb09d","e3417885.050f78","c9059372.9ff92"]]},{"id":"c9059372.9ff92","type":"function","z":"523c97fe.704cb4","name":"Above 100 Pack1","func":"if (msg.payload > 100){\n msg.payload = 0\n}\nelse\nif (msg.payload < -1){\n msg.payload = 1\n}\nreturn msg","outputs":1,"noerr":0,"x":160,"y":153,"wires":[["25a31938.9ad836"]]},{"id":"25a31938.9ad836","type":"delay","z":"523c97fe.704cb4","name":"Pack1","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":430,"y":132,"wires":[["e9c54dc9.af2e4"]]},{"id":"c72a5d1f.fb09d","type":"function","z":"523c97fe.704cb4","name":"Above 100 Pack2","func":"if (msg.payload > 100){\n msg.payload = 0\n}\nelse\nif (msg.payload < -1){\n msg.payload = 1\n}\nreturn msg","outputs":1,"noerr":0,"x":152,"y":219,"wires":[["a506da97.df1c08"]]},{"id":"e3417885.050f78","type":"function","z":"523c97fe.704cb4","name":"Above 100 Pack3","func":"if (msg.payload > 100){\n msg.payload = 0\n}\nelse\nif (msg.payload < -1){\n msg.payload = 1\n}\nreturn msg","outputs":1,"noerr":0,"x":149,"y":277,"wires":[["775e8574.2f541c"]]},{"id":"a506da97.df1c08","type":"delay","z":"523c97fe.704cb4","name":"Pack2","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":430,"y":213,"wires":[["494fe8d7.5339c8"]]},{"id":"775e8574.2f541c","type":"delay","z":"523c97fe.704cb4","name":"Pack3","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":428,"y":283,"wires":[["cd1132db.6617d"]]},{"id":"e9c54dc9.af2e4","type":"rpi-gpio out","z":"523c97fe.704cb4","name":"","pin":"3","set":true,"level":"1","freq":"","out":"out","x":599,"y":133,"wires":[]},{"id":"494fe8d7.5339c8","type":"rpi-gpio out","z":"523c97fe.704cb4","name":"","pin":"5","set":true,"level":"1","freq":"","out":"out","x":600,"y":208,"wires":[]},{"id":"cd1132db.6617d","type":"rpi-gpio out","z":"523c97fe.704cb4","name":"","pin":"7","set":true,"level":"1","freq":"","out":"out","x":598,"y":282,"wires":[]},{"id":"77664b29.0411b4","type":"ui_group","z":"","name":"Dent","tab":"dd31cd83.95ad9","disp":true,"width":"6","collapse":false},{"id":"dd31cd83.95ad9","type":"ui_tab","z":"","name":"Dent","icon":"dashboard"}]

0 Likes

#2

Hi

Can you edit your post and stick 3 ``` on the line before your code and and another 3 on the line after it (so its gets formatted correctly by the forum software)

0 Likes

#3

Sorry, new here, please check that I now have formatted correctly. Thanks

0 Likes

#4

Sounds like a job for some trigger nodes -- they can be set up to send another msg 10 secs. after receiving the first msg, with the original topic/payload or even some other data.

0 Likes

#5

Thanks for the Suggestion, I will try that.

0 Likes

#6

I am wondering whether there may be a better way of handling the complete requirement as this sounds to me as if you are trying to control something. If you are interested in considering alternatives then tell us what you are hoping to do and there may well be useful suggestions.

0 Likes