# Using arduino serial data to control gpio

**URL:** <https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823>\
**Category:** General\
**Created:** [15 December 2018 02:18 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823 "2018-12-15T02:18:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mason08](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mason08](https://discourse.nodered.org/u/mason08)\
**Post date:** [15 December 2018 02:18 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/1 "2018-12-15T02:18:30Z")

</div>

So currently in my flow im using numbers that are being sent from a arduino to display info on the dashboard. Now what i want to do is use the numbers to turn on or off relays. I currently have a 3 relay board attached to the pi. I ran them by them self and everything works fine. What my goal is to have, if the numbers lower then what i want the relay is off and above its on. I have a node im using for email alerts but it wont turn on the relay from the gpio node. I tried using a switch node but wasnt able to get it to behave like its supposed to.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 December 2018 07:43 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/2 "2018-12-15T07:43:20Z")

</div>

if you post your flow perhaps people can help you see where you are going wrong

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 December 2018 10:09 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/3 "2018-12-15T10:09:42Z")

</div>

Also what is the relay board?

---

<div class="post-metadata">

**Author:** ![mason08](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mason08](https://discourse.nodered.org/u/mason08)\
**Post date:** [15 December 2018 15:27 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/4 "2018-12-15T15:27:23Z")

</div>

```auto
[{"id":"c9759d08.ecfe9","type":"switch","z":"6c09d71.3976f28","name":"switch 2","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"outdoor","vt":"str"},{"t":"cont","v":"ahu_s","vt":"str"},{"t":"cont","v":"ahu_r","vt":"str"},{"t":"cont","v":"boiler_s","vt":"str"},{"t":"cont","v":"boiler_r","vt":"str"},{"t":"cont","v":"waterheater","vt":"str"},{"t":"cont","v":"heatpump_s","vt":"str"},{"t":"cont","v":"heatpump_l","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":375.83332443237305,"y":457.4999771118164,"wires":[["b55943b6.1a6f3","86c89cc3.6bf08"],["b55943b6.1a6f3","17f10f12.9660b1"],["b55943b6.1a6f3","64098762.ac3608"],["b55943b6.1a6f3","1ddbe3c7.3e88bc"],["b55943b6.1a6f3","2f0a0d24.1f0b82"],["b55943b6.1a6f3","2a0dcedd.6b2172"],["b55943b6.1a6f3","cdeace34.f3b57"],["b55943b6.1a6f3","f8c8d35.7706c3"]]},{"id":"b3130a6d.cb4a98","type":"function","z":"6c09d71.3976f28","name":"Water Temp Alarm","func":"var upperThreshold = 200;\nvar lowerThreshold = 60;\n\n\nvar previousTemp = context.previousTemp || \n (upperThreshold - lowerThreshold)/2;\n \nvar temp = msg.payload;\n\ncontext.previousTemp = temp;\n\n\n// Check if the new temp is different from the previous\nif (previousTemp != temp){\n\tif ((previousTemp < upperThreshold) \n\t && (temp >= upperThreshold)){\n\t\tmsg.payload = \"BOILER OVERHEATING! Current temperature is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n\telse if ((previousTemp > lowerThreshold) \n\t && (temp <= lowerThreshold)){\n\t\tmsg.payload = \"Boiler SHUTTING DOWN! Current temperature is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n}","outputs":1,"noerr":0,"x":1446.7617797851562,"y":633.9285440444946,"wires":[["588913a4.d6ba5c","77bb81e6.a5a16"]]},{"id":"588913a4.d6ba5c","type":"debug","z":"6c09d71.3976f28","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1565.3332977294922,"y":805.2856837681361,"wires":[]},{"id":"c2fa8271.951a7","type":"debug","z":"6c09d71.3976f28","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":823.9047470092773,"y":845.2856788635254,"wires":[]},{"id":"3f5d1c52.0d8d94","type":"function","z":"6c09d71.3976f28","name":"String to Number","func":"msg.payload = Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":602.4761548723493,"y":755.2856837681361,"wires":[["c2fa8271.951a7","383ff936.2737a6","90e337dc.a36c38","f26e50fa.a1025"]]},{"id":"90e337dc.a36c38","type":"function","z":"6c09d71.3976f28","name":"Flue OVERFIRE","func":"var upperThreshold = 700;\nvar lowerThreshold = 60;\n\n\nvar previousTemp = context.previousTemp || \n (upperThreshold - lowerThreshold)/2;\n \nvar temp = msg.payload;\n\ncontext.previousTemp = temp;\n\n\n// Check if the new temp is different from the previous\nif (previousTemp != temp){\n\tif ((previousTemp < upperThreshold) \n\t && (temp >= upperThreshold)){\n\t\tmsg.payload = \"BOILER OVERFIRE! Current temperature is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n\telse if ((previousTemp > lowerThreshold) \n\t && (temp <= lowerThreshold)){\n\t\tmsg.payload = \"Boiler SHUTTING DOWN! Current temperature is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n}","outputs":1,"noerr":0,"x":861.0475845336914,"y":696.7141971588135,"wires":[["74da4921.c725c8"]]},{"id":"8cf0fadc.0fe5b8","type":"serial in","z":"6c09d71.3976f28","name":"","serial":"1f32b18b.fcfa2e","x":327.0833206176758,"y":790.2500114440918,"wires":[["404951f5.3f108","c9759d08.ecfe9"]]},{"id":"9cea4836.036798","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"7d85d4e3.34fd4c","order":4,"width":"6","height":"6","gtype":"gage","title":"Outdoor","label":"Degrees F","format":"{{value}}","min":"-30","max":"120","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1478.3333129882812,"y":358.9999694824219,"wires":[]},{"id":"1343f3f9.aed30c","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"330ba67c.56157a","order":1,"width":0,"height":0,"gtype":"gage","title":"ahu-s","label":"Degrees F","format":"{{value}}","min":"40","max":"120","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1467.3333129882812,"y":391.9999694824219,"wires":[]},{"id":"47f86ece.b012d","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"b998bc0b.cb238","order":1,"width":0,"height":0,"gtype":"gage","title":"ahu-r","label":"Degrees F","format":"{{value}}","min":"40","max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1468.3333129882812,"y":423.9999694824219,"wires":[]},{"id":"997248ce.170a08","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"6f0a462e.d6e518","order":1,"width":0,"height":0,"gtype":"gage","title":"water heater","label":"Degrees F","format":"{{value}}","min":"60","max":"240","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1484.3333129882812,"y":456.9999694824219,"wires":[]},{"id":"a6fd09d6.fc2ec8","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"aded4dfc.6f216","order":2,"width":0,"height":0,"gtype":"gage","title":"Boiler Return","label":"Degrees F","format":"{{value}}","min":"60","max":"240","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1487.3333129882812,"y":487.9999694824219,"wires":[]},{"id":"2d023e3c.d37bf2","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"1b2e1340.8794fd","order":6,"width":0,"height":0,"gtype":"gage","title":"Boiler Supply","label":"Degrees F","format":"{{value}}","min":"60","max":"240","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1484.3333129882812,"y":517.9999694824219,"wires":[]},{"id":"383ff936.2737a6","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"8395d4ed.a9c258","order":1,"width":0,"height":0,"gtype":"gage","title":"Boiler Flue","label":"Degrees F","format":"{{value}}","min":"50","max":"900","colors":["#f1ff01","#ffa50a","#ff0000"],"seg1":"","seg2":"","x":829.619010925293,"y":750.9999752044678,"wires":[]},{"id":"e74882b5.1e29c","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"d5e79a28.5d7798","order":1,"width":0,"height":0,"gtype":"gage","title":"Heatpump Suction Line","label":"Degrees F","format":"{{value}}","min":"30","max":"160","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1248.1903896331787,"y":833.8570594787598,"wires":[]},{"id":"3258fefd.bd5812","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"fcc0935d.d3cc7","order":1,"width":0,"height":0,"gtype":"gage","title":"Heatpump Liquid Line","label":"Degrees F","format":"{{value}}","min":"30","max":"160","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1242.4761562347412,"y":866.7142543792725,"wires":[]},{"id":"16eaf797.148978","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"1b2e1340.8794fd","order":1,"width":0,"height":0,"label":"Boiler Supply","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1200.3333129882812,"y":700.9999694824219,"wires":[[],[]]},{"id":"61f32d2b.288264","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"7d85d4e3.34fd4c","order":1,"width":0,"height":0,"label":"OUTDOOR TEMP","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1222.3333129882812,"y":732.9999694824219,"wires":[[],[]]},{"id":"1565b1ea.cee6ce","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"330ba67c.56157a","order":2,"width":0,"height":0,"label":"Air Handler Supply","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1214.3333129882812,"y":571.9999694824219,"wires":[[],[]]},{"id":"686d198c.9d4038","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"b998bc0b.cb238","order":1,"width":0,"height":0,"label":"Air Handler Return","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1215.3333129882812,"y":603.9999694824219,"wires":[[],[]]},{"id":"1338fc7d.2290b4","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"6f0a462e.d6e518","order":1,"width":0,"height":0,"label":"Water Heater","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1202.3333129882812,"y":635.9999694824219,"wires":[[],[]]},{"id":"6f1d907c.9a671","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"aded4dfc.6f216","order":1,"width":0,"height":0,"label":"Boiler Return","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1200.3333129882812,"y":668.9999694824219,"wires":[[],[]]},{"id":"1aefa388.557b3c","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"d5e79a28.5d7798","order":0,"width":0,"height":0,"label":"Heatpump Suction Line","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1243.9047012329102,"y":766.7142696380615,"wires":[[],[]]},{"id":"81ff303c.fea7d","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"fcc0935d.d3cc7","order":0,"width":0,"height":0,"label":"Heatpump Liquid Line","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1236.7618713378906,"y":798.1428089141846,"wires":[[],[]]},{"id":"f26e50fa.a1025","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"8395d4ed.a9c258","order":2,"width":0,"height":0,"label":"Boiler Flue","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":829.3332977294922,"y":787.9999694824219,"wires":[[],[]]},{"id":"b55943b6.1a6f3","type":"debug","z":"6c09d71.3976f28","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":316.3333206176758,"y":603.5000085830688,"wires":[]},{"id":"e5dcf766.c165f8","type":"change","z":"6c09d71.3976f28","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"FLUE","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":621.5555267333984,"y":872.2221822738647,"wires":[["3f5d1c52.0d8d94"]]},{"id":"404951f5.3f108","type":"switch","z":"6c09d71.3976f28","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"FLUE","vt":"str"},{"t":"cont","v":"PSI","vt":"str"},{"t":"cont","v":"A","vt":"str"},{"t":"cont","v":"B","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":412.2222023010254,"y":887.7777404785156,"wires":[["e5dcf766.c165f8"],["1203958f.8229fa"],[],[]]},{"id":"1203958f.8229fa","type":"change","z":"6c09d71.3976f28","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"PSI","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":622.9999847412109,"y":914.3332958221436,"wires":[["3a8fcab0.273a66","2acc2e05.5c2702","4aa642f4.453e0c"]]},{"id":"3a8fcab0.273a66","type":"ui_gauge","z":"6c09d71.3976f28","name":"","group":"2539ee8b.0c17c2","order":1,"width":0,"height":0,"gtype":"gage","title":"Boiler Pressure","label":"PSI","format":"{{value}}","min":0,"max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":976.3333282470703,"y":880.9999542236328,"wires":[]},{"id":"2acc2e05.5c2702","type":"ui_chart","z":"6c09d71.3976f28","name":"","group":"2539ee8b.0c17c2","order":2,"width":0,"height":0,"label":"Boiler Pressure","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":978.5555114746094,"y":919.8888721466064,"wires":[[],[]]},{"id":"4aa642f4.453e0c","type":"function","z":"6c09d71.3976f28","name":"Boiler Pressure","func":"var upperThreshold = 26;\nvar lowerThreshold = 10;\n\n\nvar previousTemp = context.previousTemp || \n (upperThreshold - lowerThreshold)/2;\n \nvar temp = msg.payload;\n\ncontext.previousTemp = temp;\n\n\n// Check if the new temp is different from the previous\nif (previousTemp != temp){\n\tif ((previousTemp < upperThreshold) \n\t && (temp >= upperThreshold)){\n\t\tmsg.payload = \"BOILER OVER PRESSURE! Current Pressure is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n\telse if ((previousTemp > lowerThreshold) \n\t && (temp <= lowerThreshold)){\n\t\tmsg.payload = \"BOILER UNDER PRESSURE! Current pressure is \" + String(temp) + \"°F\";\n\t\treturn msg;\n\t}\n}","outputs":1,"noerr":0,"x":828.5555419921875,"y":967.6665954589844,"wires":[["2da7e18b.64897e"]]},{"id":"2d96500d.94f92","type":"e-mail","z":"6c09d71.3976f28","server":"smtp.gmail.com","port":"465","secure":true,"name":"boiler.node.red@gmail.com","dname":"Boiler Email","x":1933.793586730957,"y":725.2857208251953,"wires":[]},{"id":"2da7e18b.64897e","type":"delay","z":"6c09d71.3976f28","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1710.8689765930176,"y":757.2856826782227,"wires":[["2d96500d.94f92"]]},{"id":"74da4921.c725c8","type":"delay","z":"6c09d71.3976f28","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1709.4166870117188,"y":726.7499694824219,"wires":[["2d96500d.94f92"]]},{"id":"77bb81e6.a5a16","type":"delay","z":"6c09d71.3976f28","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1704.3333129882812,"y":694.9999694824219,"wires":[["2d96500d.94f92"]]},{"id":"17f10f12.9660b1","type":"change","z":"6c09d71.3976f28","name":"ahu suply","rules":[{"t":"change","p":"payload","pt":"msg","from":"ahu_s","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":581.25,"y":366.25,"wires":[["1343f3f9.aed30c","1565b1ea.cee6ce"]]},{"id":"64098762.ac3608","type":"change","z":"6c09d71.3976f28","name":"ahu return","rules":[{"t":"change","p":"payload","pt":"msg","from":"ahu_r","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":587.5,"y":403.75,"wires":[["47f86ece.b012d","686d198c.9d4038"]]},{"id":"1ddbe3c7.3e88bc","type":"change","z":"6c09d71.3976f28","name":"boiler supply","rules":[{"t":"change","p":"payload","pt":"msg","from":"boiler_s","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":587.5,"y":448.75,"wires":[["2d023e3c.d37bf2","16eaf797.148978","b3130a6d.cb4a98"]]},{"id":"2f0a0d24.1f0b82","type":"change","z":"6c09d71.3976f28","name":"boiler return","rules":[{"t":"change","p":"payload","pt":"msg","from":"boiler_r","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":585,"y":493.75,"wires":[["a6fd09d6.fc2ec8","6f1d907c.9a671"]]},{"id":"2a0dcedd.6b2172","type":"change","z":"6c09d71.3976f28","name":"water heater","rules":[{"t":"change","p":"payload","pt":"msg","from":"waterheater","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":581.25,"y":542.5,"wires":[["997248ce.170a08","1338fc7d.2290b4"]]},{"id":"cdeace34.f3b57","type":"change","z":"6c09d71.3976f28","name":"heatpump suction","rules":[{"t":"change","p":"payload","pt":"msg","from":"heatpump_s","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":583.75,"wires":[["1aefa388.557b3c","e74882b5.1e29c"]]},{"id":"86c89cc3.6bf08","type":"change","z":"6c09d71.3976f28","name":"outdoor","rules":[{"t":"change","p":"payload","pt":"msg","from":"outdoor","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":315,"wires":[["9cea4836.036798","61f32d2b.288264"]]},{"id":"f8c8d35.7706c3","type":"change","z":"6c09d71.3976f28","name":"heatpump liquid","rules":[{"t":"change","p":"payload","pt":"msg","from":"heatpump_l","fromt":"str","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":583.75,"y":632.5,"wires":[["81ff303c.fea7d","3258fefd.bd5812"]]},{"id":"1f32b18b.fcfa2e","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"7d85d4e3.34fd4c","type":"ui_group","z":"6c09d71.3976f28","name":"Outdoor","tab":"e63a0a81.b28898","disp":true,"width":"6","collapse":false},{"id":"330ba67c.56157a","type":"ui_group","z":"6c09d71.3976f28","name":"Air Handler Supply","tab":"24a0c7f1.018d68","disp":true,"width":"6","collapse":false},{"id":"b998bc0b.cb238","type":"ui_group","z":"6c09d71.3976f28","name":"Air Handler Return","tab":"24a0c7f1.018d68","disp":true,"width":"6","collapse":false},{"id":"6f0a462e.d6e518","type":"ui_group","z":"6c09d71.3976f28","name":"Water Heater","tab":"11f49fd1.7349c","order":3,"disp":true,"width":"6","collapse":false},{"id":"aded4dfc.6f216","type":"ui_group","z":"6c09d71.3976f28","name":"Boiler Return","tab":"49974152.2ecb4","order":2,"disp":true,"width":"6","collapse":false},{"id":"1b2e1340.8794fd","type":"ui_group","z":"6c09d71.3976f28","name":"Boiler Supply","tab":"49974152.2ecb4","order":1,"disp":true,"width":"6","collapse":false},{"id":"8395d4ed.a9c258","type":"ui_group","z":"6c09d71.3976f28","name":"Boiler Flue","tab":"49974152.2ecb4","order":3,"disp":true,"width":"6","collapse":false},{"id":"d5e79a28.5d7798","type":"ui_group","z":"6c09d71.3976f28","name":"Heatpump Suction Line","tab":"8b0df29c.14cb3","order":5,"disp":true,"width":"6","collapse":false},{"id":"fcc0935d.d3cc7","type":"ui_group","z":"6c09d71.3976f28","name":"Heatpump Liquid Line","tab":"8b0df29c.14cb3","disp":true,"width":"6","collapse":false},{"id":"2539ee8b.0c17c2","type":"ui_group","z":"","name":"Boiler Pressure","tab":"49974152.2ecb4","disp":true,"width":"6","collapse":false},{"id":"e63a0a81.b28898","type":"ui_tab","z":"6c09d71.3976f28","name":"Outdoor","icon":"dashboard","order":2},{"id":"24a0c7f1.018d68","type":"ui_tab","z":"6c09d71.3976f28","name":"Air Handler","icon":"dashboard","order":2},{"id":"11f49fd1.7349c","type":"ui_tab","z":"6c09d71.3976f28","name":"Water Heater","icon":"dashboard","order":2},{"id":"49974152.2ecb4","type":"ui_tab","z":"6c09d71.3976f28","name":"Boiler Room","icon":"dashboard"},{"id":"8b0df29c.14cb3","type":"ui_tab","z":"6c09d71.3976f28","name":"Heat Pump","icon":"dashboard","order":2}]

```

the board snaps on top using the gpio pins. I got that part working.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 December 2018 19:57 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/5 "2018-12-15T19:57:38Z")

</div>

> [@mason08](#):
>
> the board snaps on top using the gpio pins

First off, add two inject nodes and a 'rpi gpio' out node and connect the inject nodes to the gpio node. In the gpio node select the gpio pin that controls a relay. In one inject node have it send the number 1 and the other send the number 0. Deploy and see if pressing the inject buttons controls the nodes. If it does all you have to do is check your value. If it is greater that N-low send a 1 to the gpio node. If it is higher than N-high send a 0.

---

<div class="post-metadata">

**Author:** ![mason08](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mason08](https://discourse.nodered.org/u/mason08)\
**Post date:** [15 December 2018 20:31 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/6 "2018-12-15T20:31:06Z")

</div>

So i did what you had said. Put two inject nodes and have one put out 1 and the other 0. That worked fine. I created this node...

```auto
[{"id":"a777f1d7.e7626","type":"function","z":"6c09d71.3976f28","name":"Boiler Relay 1","func":"var upperThreshold = 26;\nvar lowerThreshold = 10;\n\n\nvar previousTemp = context.previousTemp || \n (upperThreshold - lowerThreshold)/2;\n \nvar temp = msg.payload;\n\ncontext.previousTemp = temp;\n\n\n// Check if the new temp is different from the previous\nif (previousTemp != temp){\n\tif ((previousTemp < upperThreshold) \n\t && (temp >= upperThreshold)){\n\t\tmsg.payload = \"1\" + String(temp);\n\t\treturn msg;\n\t}\n\telse if ((previousTemp > lowerThreshold) \n\t && (temp <= lowerThreshold)){\n\t\tmsg.payload = \"0\" + String(temp);\n\t\treturn msg;\n\t}\n}","outputs":1,"noerr":0,"x":717.1428833007812,"y":1038.5714111328125,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 December 2018 21:33 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/7 "2018-12-15T21:33:47Z")

</div>

Great! So you should be on your way to solving your issue.

---

<div class="post-metadata">

**Author:** ![mason08](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mason08](https://discourse.nodered.org/u/mason08)\
**Post date:** [15 December 2018 23:20 UTC](https://discourse.nodered.org/t/using-arduino-serial-data-to-control-gpio/5823/8 "2018-12-15T23:20:44Z")

</div>

I ended up using a function node and got it all to work.
