Introduction
Do you have or work in a small / medium-sized company and you keep wasting time doing processes manually? Do you know that, thanks to industrial automation, you can automate them and invest your time in another tasks?
In this post, we are going to show you how to automate these processes that you were still doing manually. We will activate and deactivate an output, analog or digital, with customizable time from the Node-RED Dashboard, and this application will work only if a digital input is at 1.
Requirements
- Raspberry Pi PLC > or Panel PC >
- Power Supply >
- Some valve, sensor > or actuator to connect to the input and output
Node-RED
We will create our application with Node-RED >, so the first thing to do is download and install it, either as an application or as a service.
By default on your open source Raspberry Pi PLC or Panel PC, Node-RED comes by default. If you don't have it, please download it by clicking on this link > .
Application example
To make this post really useful, we are going to see some practical examples in which you can use the Node-RED flows and control your application through the Node-RED Dashboard.
First of all, we invite you to take a look at this post, where you can see a list of up to 50 industrial applications! >
Now, we are going to see how to take advantage of this example Node-RED flows.json that we provide you to be able to control your application through a Dashboard.
1. In the first place, we could connect a digital input signal such as a frequency inverter, which if it is turned on, will activate an ON/OFF valve that will regulate the emission of liquids inside bottles for the time that we tell it. The on time will be the time that the valve will let liquid pass through, and the off time will be the time that it will not let it pass. Liquid will be emitted intermittently. The same application can be applicable to a labeling system > and as many projects as you can think about.
This applications would be an example for an automatic input.
2. Another application could be to receive the signal from a switch, and when we receive a HIGH signal, therefore, when the switch is on, activate the intermittent output, like a light, alarm, valve, pump, motor, turbine, etc.
This example would be applicable as a manually triggered input.
Node-RED flows.json
Once Node-RED is correctly installed, go to the the menu > click on Import > copy this flows.json:
[{"id":"b6bec7a8.e550b8","type":"tab","label":"Industrial Shields","disabled":false,"info":""},{"id":"c33d895f.e9ebf8","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#2e9348","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#2e9348","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#2e9348","edited":true},"page-titlebar-backgroundColor":{"value":"#2e9348","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#48c668","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#2e9348","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"c662856.b2c7878","type":"ui_tab","name":"Industrial Shields","icon":"close","disabled":false,"hidden":false},{"id":"94e80e20.ee556","type":"ui_group","name":"","tab":"c662856.b2c7878","order":1,"disp":true,"width":24,"collapse":false},{"id":"fe66a221.1767a","type":"rpiplc-config","model":"RPIPLC_21","name":""},{"id":"d9e12361.912e7","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":3,"width":4,"height":1},{"id":"2a7f6dcb.53c1a2","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":5,"width":1,"height":1},{"id":"ea3de633.5d64c8","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":6,"width":1,"height":1},{"id":"e2535e44.4117e","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":7,"width":4,"height":1},{"id":"b824ad60.dbfd8","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":8,"width":1,"height":1},{"id":"e1946377.e5e62","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":9,"width":1,"height":1},{"id":"d2de7f17.0a5d4","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":10,"width":4,"height":1},{"id":"6f21b07c.ecff7","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":11,"width":1,"height":1},{"id":"b666b5d7.e45a98","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":12,"width":24,"height":1},{"id":"b6a3c6e0.12bc28","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":13,"width":1,"height":1},{"id":"8da4151b.352898","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":15,"width":4,"height":1},{"id":"3b0cdc00.db17e4","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":17,"width":1,"height":1},{"id":"4150adf0.af2ea4","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":18,"width":1,"height":1},{"id":"1bf4c0c4.35235f","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":19,"width":4,"height":1},{"id":"bb97f5c2.abd378","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":20,"width":1,"height":1},{"id":"6b3aa597.48466c","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":21,"width":1,"height":1},{"id":"c281fb9.fe27208","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":22,"width":4,"height":1},{"id":"64358406.e9e5bc","type":"ui_spacer","name":"spacer","group":"94e80e20.ee556","order":23,"width":1,"height":1},{"id":"be6dbc57.7133","type":"inject","z":"b6bec7a8.e550b8","name":"Initial state = False","props":[{"p":"payload","v":"false","vt":"bool"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":300,"wires":[["d28917d1.2cdb28"]]},{"id":"4572d3b1.720d8c","type":"function","z":"b6bec7a8.e550b8","name":"set t1","func":"let t1 = msg.payload;\nflow.set('t1', t1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":340,"wires":[["956f3b61.bdd678","60bdcc7f.214e14"]]},{"id":"fe68860a.f0c058","type":"function","z":"b6bec7a8.e550b8","name":"set t2","func":"let t2 = msg.payload;\nflow.set('t2', t2);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":380,"wires":[["956f3b61.bdd678","60bdcc7f.214e14"]]},{"id":"1d9c540c.0a04ac","type":"delay","z":"b6bec7a8.e550b8","name":"Wait 10ms","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1150,"y":760,"wires":[["cb5d5ee3.39838"]]},{"id":"6054a937.fec848","type":"function","z":"b6bec7a8.e550b8","name":"set active","func":"let active = msg.payload;\nflow.set('active', active);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":300,"wires":[["956f3b61.bdd678"]]},{"id":"73ba781d.71bd38","type":"switch","z":"b6bec7a8.e550b8","name":"flow.active","property":"active","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":600,"wires":[["29ef3da0.c55c52"],["2561d26d.f8b37e"]]},{"id":"2561d26d.f8b37e","type":"delay","z":"b6bec7a8.e550b8","name":"delay","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":430,"y":540,"wires":[["73ba781d.71bd38"]]},{"id":"ee2fcf71.fa6cf","type":"delay","z":"b6bec7a8.e550b8","name":"delay","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":210,"y":760,"wires":[["a46be30c.3eb3a"]]},{"id":"1081e5b8.8eb87a","type":"inject","z":"b6bec7a8.e550b8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":190,"y":600,"wires":[["73ba781d.71bd38"]]},{"id":"69611f30.35345","type":"function","z":"b6bec7a8.e550b8","name":"Get times from flow","func":"return {\n payload: {\n t1: flow.get('t1'),\n t2: flow.get('t2'),\n useInput: flow.get('useInput'),\n }\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1130,"y":140,"wires":[["ed831243.095b6"]]},{"id":"33c0ae95.0d1112","type":"function","z":"b6bec7a8.e550b8","name":"","func":"return [\n {payload: msg.payload.t1},\n {payload: msg.payload.t2},\n {payload: msg.payload.useInput}\n ];","outputs":3,"noerr":0,"initialize":"","finalize":"","x":260,"y":360,"wires":[["48e0d53f.74932c"],["72166daf.79da74"],[]]},{"id":"125ad292.e4420d","type":"function","z":"b6bec7a8.e550b8","name":"set useInput","func":"let useInput = msg.payload;\nflow.set('useInput', useInput);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":420,"wires":[["956f3b61.bdd678"]]},{"id":"a46be30c.3eb3a","type":"switch","z":"b6bec7a8.e550b8","name":"Is running","property":"running","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":420,"y":820,"wires":[["df716f33.de3bc","5a4df363.a56fbc"],["c435b975.daad18"]]},{"id":"7ce63d96.31c834","type":"switch","z":"b6bec7a8.e550b8","name":"Is running","property":"running","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":820,"wires":[["1d9c540c.0a04ac"],["c750d9d2.b34b38","cb3f7da8.ccf5e"]]},{"id":"eb5adc67.c3826","type":"function","z":"b6bec7a8.e550b8","name":"Update running","func":"const useInput = flow.get('useInput');\nconst inputValue = flow.get('input');\nconst active = flow.get('active');\nconst t1 = flow.get('t1');\nconst t2 = flow.get('t2');\n\nlet running = active && (!useInput || (useInput && (inputValue == 0))) && (t1 > 0) && (t2 > 0);\n\nflow.set('running', running);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1560,"y":600,"wires":[[]]},{"id":"45f5cda5.4cd994","type":"inject","z":"b6bec7a8.e550b8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":190,"y":820,"wires":[["a46be30c.3eb3a"]]},{"id":"df716f33.de3bc","type":"change","z":"b6bec7a8.e550b8","name":"Set start time","rules":[{"t":"set","p":"startTime","pt":"flow","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":820,"wires":[["7ce63d96.31c834"]]},{"id":"ecfd6e61.bf72e","type":"function","z":"b6bec7a8.e550b8","name":"Check spent T1","func":"const startTime = flow.get('startTime');\nconst t1 = flow.get('t1') * 1000;\nconst diffTime = Date.now() - startTime;\n\nreturn diffTime >= t1 ? [null, msg] : [msg, null];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":900,"y":880,"wires":[["7ce63d96.31c834"],["d482a4ce.df8368","55c96381.e5b26c"]]},{"id":"ab28e4f3.a7fe98","type":"switch","z":"b6bec7a8.e550b8","name":"Is running","property":"running","propertyType":"flow","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":1340,"y":340,"wires":[["ba4552cd.0824b","27cccecc.ea1642"],["46e15e6b.8115c"]]},{"id":"55c96381.e5b26c","type":"change","z":"b6bec7a8.e550b8","name":"Set start time","rules":[{"t":"set","p":"startTime","pt":"flow","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":920,"wires":[["46fc3a6.9ebe2c4"]]},{"id":"264bffb2.2dc34","type":"function","z":"b6bec7a8.e550b8","name":"Check spent T2","func":"const startTime = flow.get('startTime');\nconst t2 = flow.get('t2') * 1000;\n\nconst diffTime = Date.now() - startTime;\n\nreturn diffTime >= t2 ? [null, msg] : [msg, null];","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1360,"y":400,"wires":[["ab28e4f3.a7fe98"],["3d1b8961.c4af96"]]},{"id":"46e15e6b.8115c","type":"delay","z":"b6bec7a8.e550b8","name":"Wait 10ms","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1110,"y":400,"wires":[["264bffb2.2dc34"]]},{"id":"bfb621be.79aa2","type":"change","z":"b6bec7a8.e550b8","name":"","rules":[{"t":"set","p":"input","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":600,"wires":[["eb5adc67.c3826","bd875aa2.368d08"]]},{"id":"813258f1.4984e8","type":"file","z":"b6bec7a8.e550b8","name":"","filename":"/home/pi/values.json","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"utf8","x":1540,"y":140,"wires":[[]]},{"id":"f6c50d90.8c126","type":"file in","z":"b6bec7a8.e550b8","name":"","filename":"/home/pi/values.json","format":"utf8","chunk":false,"sendError":false,"encoding":"utf8","x":480,"y":140,"wires":[["3a3d169c.5ab35a"]]},{"id":"3a3d169c.5ab35a","type":"json","z":"b6bec7a8.e550b8","name":"","property":"payload","action":"obj","pretty":false,"x":710,"y":140,"wires":[["6cd1edd7.22cba4"]]},{"id":"ed831243.095b6","type":"json","z":"b6bec7a8.e550b8","name":"","property":"payload","action":"str","pretty":false,"x":1330,"y":140,"wires":[["813258f1.4984e8"]]},{"id":"48e0d53f.74932c","type":"ui_numeric","z":"b6bec7a8.e550b8","name":"TIME ON","label":"TIME ON","tooltip":"","group":"94e80e20.ee556","order":4,"width":12,"height":3,"wrap":false,"passthru":true,"topic":"topic","topicType":"str","format":"{{msg.payload}}","min":0,"max":10,"step":"0.1","x":440,"y":340,"wires":[["4572d3b1.720d8c"]]},{"id":"72166daf.79da74","type":"ui_numeric","z":"b6bec7a8.e550b8","name":"TIME OFF","label":"TIME OFF","tooltip":"","group":"94e80e20.ee556","order":16,"width":12,"height":3,"wrap":false,"passthru":true,"topic":"topic","topicType":"str","format":"{{msg.payload}}","min":0,"max":10,"step":"0.1","x":450,"y":380,"wires":[["fe68860a.f0c058"]]},{"id":"d28917d1.2cdb28","type":"ui_switch","z":"b6bec7a8.e550b8","name":"","label":"ACTIVATE","tooltip":"","group":"94e80e20.ee556","order":2,"width":6,"height":3,"passthru":true,"decouple":"false","topic":"","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"x":450,"y":300,"wires":[["6054a937.fec848","e601c2f7.66658"]]},{"id":"506d43e2.94667c","type":"ui_switch","z":"b6bec7a8.e550b8","name":"FORCE","label":"FORCE","tooltip":"","group":"94e80e20.ee556","order":14,"width":6,"height":3,"passthru":true,"decouple":"false","topic":"","topicType":"str","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","animate":true,"x":440,"y":420,"wires":[["125ad292.e4420d"]]},{"id":"17ea332b.0462bd","type":"ui_template","z":"b6bec7a8.e550b8","group":"94e80e20.ee556","name":"","order":1,"width":1,"height":1,"format":"<style>\n md-card .label{\n margin-right:20px;\n font-weight:bold;\n font-size:xx-large;\n }\n md-switch {\n transform:scale(3);\n margin-left:50px !important;\n margin-right:150px !important;\n }\n md-switch.md-checked .md-bar {\n background-color:#2E9348 !important;\n }\n md-switch.md-checked .md-thumb {\n background-color:#25c179 !important;\n }\n .md-icon-button {\n transform:scale(3);\n margin-left:50px !important;\n margin-right:50px !important;\n }\n .nr-dashboard-theme .nr-dashboard-numeric .value {\n transform:scale(3);\n }\n .nr-dashboard-theme .nr-dashboard-numeric {\n padding:50px!important;\n }\n .layout-align-space-between {\n justify-content:center;\n }\n\n</style>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":160,"y":80,"wires":[[]]},{"id":"8a69599c.51abc8","type":"inject","z":"b6bec7a8.e550b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":140,"wires":[["f6c50d90.8c126"]]},{"id":"1eef739.d9b7d8c","type":"inject","z":"b6bec7a8.e550b8","name":"Initial useInput = True","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":220,"y":420,"wires":[["506d43e2.94667c"]]},{"id":"f0c160de.ac9d4","type":"rpiplc-digital-write","z":"b6bec7a8.e550b8","rpiplc":"fe66a221.1767a","pin":"Q0.0","value":"0","name":"","x":1560,"y":840,"wires":[]},{"id":"d33b0bc1.f62838","type":"rpiplc-digital-write","z":"b6bec7a8.e550b8","rpiplc":"fe66a221.1767a","pin":"Q0.0","value":"0","name":"","x":1560,"y":880,"wires":[]},{"id":"30f2dda8.851ef2","type":"rpiplc-digital-write","z":"b6bec7a8.e550b8","rpiplc":"fe66a221.1767a","pin":"Q0.0","value":"1","name":"","x":910,"y":760,"wires":[]},{"id":"29ef3da0.c55c52","type":"rpiplc-digital-read","z":"b6bec7a8.e550b8","rpiplc":"fe66a221.1767a","pin":"I0.0","name":"","x":720,"y":600,"wires":[["bfb621be.79aa2"]]},{"id":"5a4df363.a56fbc","type":"change","z":"b6bec7a8.e550b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":760,"wires":[["30f2dda8.851ef2"]]},{"id":"c750d9d2.b34b38","type":"change","z":"b6bec7a8.e550b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":840,"wires":[["f0c160de.ac9d4"]]},{"id":"d482a4ce.df8368","type":"change","z":"b6bec7a8.e550b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":880,"wires":[["d33b0bc1.f62838"]]},{"id":"6cd1edd7.22cba4","type":"link out","z":"b6bec7a8.e550b8","name":"databaseOut","links":["233a7e9d.8a7502"],"x":855,"y":140,"wires":[]},{"id":"233a7e9d.8a7502","type":"link in","z":"b6bec7a8.e550b8","name":"functionIn","links":["6cd1edd7.22cba4"],"x":115,"y":360,"wires":[["33c0ae95.0d1112"]]},{"id":"956f3b61.bdd678","type":"link out","z":"b6bec7a8.e550b8","name":"setOut","links":["90dbe9a.037d418"],"x":955,"y":420,"wires":[]},{"id":"90dbe9a.037d418","type":"link in","z":"b6bec7a8.e550b8","name":"setIn","links":["956f3b61.bdd678"],"x":1435,"y":580,"wires":[["eb5adc67.c3826"]]},{"id":"bd875aa2.368d08","type":"link out","z":"b6bec7a8.e550b8","name":"setFlowInput","links":["704d735a.2cfdec"],"x":1055,"y":580,"wires":[]},{"id":"704d735a.2cfdec","type":"link in","z":"b6bec7a8.e550b8","name":"preDelay","links":["bd875aa2.368d08"],"x":115,"y":540,"wires":[["2561d26d.f8b37e"]]},{"id":"9d85c242.866ec","type":"link in","z":"b6bec7a8.e550b8","name":"preDelay","links":["60bdcc7f.214e14","90dbe6e2.920bc8"],"x":955,"y":140,"wires":[["69611f30.35345"]]},{"id":"60bdcc7f.214e14","type":"link out","z":"b6bec7a8.e550b8","name":"setTimes","links":["9d85c242.866ec"],"x":955,"y":340,"wires":[]},{"id":"79932055.6bd28","type":"link in","z":"b6bec7a8.e550b8","name":"preSecondDelay","links":["c435b975.daad18","ba4552cd.0824b","cb3f7da8.ccf5e"],"x":115,"y":760,"wires":[["ee2fcf71.fa6cf"]]},{"id":"c435b975.daad18","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["79932055.6bd28"],"x":615,"y":880,"wires":[]},{"id":"ba4552cd.0824b","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["79932055.6bd28"],"x":1635,"y":380,"wires":[]},{"id":"cb3f7da8.ccf5e","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["79932055.6bd28"],"x":1095,"y":800,"wires":[]},{"id":"3d1b8961.c4af96","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["805b5ce9.69937"],"x":1635,"y":420,"wires":[]},{"id":"805b5ce9.69937","type":"link in","z":"b6bec7a8.e550b8","name":"preSecondIsRunning","links":["3d1b8961.c4af96"],"x":235,"y":880,"wires":[["a46be30c.3eb3a"]]},{"id":"cb5d5ee3.39838","type":"link out","z":"b6bec7a8.e550b8","name":"afterWait10","links":["bd95212d.8122e"],"x":1295,"y":760,"wires":[]},{"id":"bd95212d.8122e","type":"link in","z":"b6bec7a8.e550b8","name":"preSecondIsRunning","links":["cb5d5ee3.39838"],"x":715,"y":880,"wires":[["ecfd6e61.bf72e"]]},{"id":"46fc3a6.9ebe2c4","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["fe76bcec.9d734"],"x":1495,"y":920,"wires":[]},{"id":"fe76bcec.9d734","type":"link in","z":"b6bec7a8.e550b8","name":"preSecondIsRunning","links":["46fc3a6.9ebe2c4"],"x":1055,"y":340,"wires":[["ab28e4f3.a7fe98"]]},{"id":"27cccecc.ea1642","type":"link out","z":"b6bec7a8.e550b8","name":"","links":["c4d5e728.5d3cb8"],"x":1635,"y":340,"wires":[]},{"id":"c4d5e728.5d3cb8","type":"link in","z":"b6bec7a8.e550b8","name":"preSecondIsRunning","links":["27cccecc.ea1642"],"x":1295,"y":820,"wires":[["f0c160de.ac9d4"]]},{"id":"e601c2f7.66658","type":"switch","z":"b6bec7a8.e550b8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":260,"wires":[["90dbe6e2.920bc8"]]},{"id":"90dbe6e2.920bc8","type":"link out","z":"b6bec7a8.e550b8","name":"setTimes","links":["9d85c242.866ec"],"x":835,"y":260,"wires":[]}]
And paste it to the import nodes (clipboard).
Explanation
Once imported, you should see your flows.json, something like the picture above, which is divided into several parts:
1. We create a file called /home/pi/values.json that will serve as a database of the stored values, so that when the application is stopped and turned on again, the values are initialized with the last ones established.
2. We initialize the variables of T1, T2, active and useInput, we assign these values in flow variables.
3. With the flow variables, we will assign the value of another variable in the execution flow.
4. If the digital input signal is at 1 and also the enable switch is activated, running must be positive. And if in addition, the force button is also activated, the application has to run.
If, on the contrary, the digital input signal is deactivated but the force is activated, the application also has to work, as long as the activate button is lit, otherwise the output must be deactivated.
5. Finally, there is a template node where you can modify the CSS from the Node-RED Dashboard.
Finally, go to your Dashboard and enjoy your application!
Node-RED Tutorial: Node-RED Example Project