Raspberry PI Input problem

#1

so i keep getting this error code
''GPIO pin 16 already set as type: input''
while trying to use a irl button to control a relay

i dont know what they mean with this.

0 Likes

#2

What pins are you using?
Have you got a GPIO-IN configured for pin16?

0 Likes

#3

I'm using this setup

plus this code

[{"id":"dafb65f9.769bb8","type":"function","z":"e4d8382f.f4813","name":"Get Params","func":"var StackValue = global.get(\"StackLevel\");\nvar RelayValue = global.get(\"Relay\");\nmsg.payload = StackValue+msg.payload+RelayValue+\" on\";\nreturn msg;","outputs":1,"noerr":0,"x":489,"y":1546,"wires":[["cfa13682.8c3728"]],"inputLabels":["IN"],"outputLabels":["IN"]},{"id":"89f2b0dd.c1d8c","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"console":"false","complete":"false","x":924,"y":1544,"wires":[]},{"id":"cfa13682.8c3728","type":"exec","z":"e4d8382f.f4813","command":"megaio","addpay":true,"append":"","useSpawn":"false","timer":"1","oldrc":false,"name":"MEGA-IO","x":702,"y":1547,"wires":[[],["89f2b0dd.c1d8c"],[]]},{"id":"fced52b.5fed43","type":"rpi-gpio in","z":"e4d8382f.f4813","name":"","pin":"16","intype":"tri","debounce":"25","read":false,"x":320,"y":1547,"wires":[["dafb65f9.769bb8"]]}]
0 Likes

#4

So the quick answer would have been "Yes I have GPIO-16 set as an input" I'm on my iPhone so can't import any flows.
That also can't be all of your flow as otherwise your Global Values are never set. So check any other GPIO nodes you are using to see if any of them are set to the same PIN.

0 Likes

#5

this is the code im trying to make work

[{"id":"fced52b.5fed43","type":"rpi-gpio in","z":"e4d8382f.f4813","name":"","pin":"16","intype":"tri","debounce":"25","read":false,"x":210,"y":1719,"wires":[["d2ddabef.936b28"]]},{"id":"d2ddabef.936b28","type":"ui_button","z":"e4d8382f.f4813","name":"Relay-Seven","group":"2059e38b.585704","order":1,"width":"0","height":"0","passthru":false,"label":"Relay-Seven","color":"","bgcolor":"{{colour}}","icon":"","payload":"Relay-Seven","payloadType":"str","topic":"","x":709,"y":1813,"wires":[["711c6891.53d74"]]},{"id":"711c6891.53d74","type":"function","z":"e4d8382f.f4813","name":"state","func":"var state = context.state || false;\nstate = !state;\ncontext.state = state;\nif (state) { return [msg,null]; }\nelse { return [null,msg]; }\n","outputs":2,"noerr":0,"x":204,"y":1772,"wires":[["f261b7b1.800f5"],["8e78bedd.e745f8"]]},{"id":"b767d205.24ef88","type":"function","z":"e4d8382f.f4813","name":"Get Params","func":"var StackValue = global.get(\"StackLevel\");\nvar RelayValue = global.get(\"Relay-Seven\");\nmsg.payload = StackValue+msg.payload+RelayValue+\" on\";\nreturn msg;","outputs":1,"noerr":0,"x":825,"y":1697,"wires":[["ac54ef22.44aac8"]],"inputLabels":["IN"],"outputLabels":["OUT"]},{"id":"a9bbb6b3.f9b41","type":"function","z":"e4d8382f.f4813","name":"Get Params","func":"var StackValue = global.get(\"StackLevel\");\nvar RelayValue = global.get(\"Relay-Seven\");\nmsg.payload = StackValue+msg.payload+RelayValue+\" off\";\nreturn msg;","outputs":1,"noerr":0,"x":824,"y":1749,"wires":[["ac54ef22.44aac8"]],"inputLabels":["IN"],"outputLabels":["OUT"]},{"id":"f261b7b1.800f5","type":"ui_button","z":"e4d8382f.f4813","name":"","group":"6117af8b.e73b18","order":5,"width":"3","height":"1","passthru":true,"label":"","color":"","bgcolor":"","icon":"","payload":" rwrite ","payloadType":"str","topic":"","x":630,"y":1696,"wires":[["b767d205.24ef88"]]},{"id":"8e78bedd.e745f8","type":"ui_button","z":"e4d8382f.f4813","name":"","group":"6117af8b.e73b18","order":7,"width":"3","height":"1","passthru":true,"label":"","color":"","bgcolor":"","icon":"","payload":" rwrite ","payloadType":"str","topic":"","x":627,"y":1751,"wires":[["a9bbb6b3.f9b41"]]},{"id":"e3803735.fd7f68","type":"function","z":"e4d8382f.f4813","name":"Save Relay","func":"global.set(\"Relay-Seven\",msg.payload);","outputs":1,"noerr":0,"x":497,"y":1846,"wires":[[]]},{"id":"45593d20.3599b4","type":"ui_numeric","z":"e4d8382f.f4813","name":"Relay","label":"Relay-Seven","group":"6117af8b.e73b18","order":8,"width":0,"height":0,"passthru":true,"topic":"","format":"{{value}}","min":"7","max":"7","step":"7","x":340,"y":1847,"wires":[["e3803735.fd7f68"]]},{"id":"ac54ef22.44aac8","type":"exec","z":"e4d8382f.f4813","command":"megaio","addpay":true,"append":"","useSpawn":"false","timer":"1","oldrc":false,"name":"MEGA-IO","x":914,"y":1829,"wires":[[],["26206486.a25524"],[]]},{"id":"26206486.a25524","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":959,"y":1908,"wires":[]},{"id":"2059e38b.585704","type":"ui_group","z":"","name":"Relay 1-8","tab":"13f7e980.24574f","order":2,"disp":true,"width":"6","collapse":false},{"id":"6117af8b.e73b18","type":"ui_group","z":"","name":"Hidden","tab":"999a958e.70c328","order":2,"disp":true,"width":"6","collapse":false},{"id":"13f7e980.24574f","type":"ui_tab","z":"","name":"RELAY TEST","icon":"dashboard"},{"id":"999a958e.70c328","type":"ui_tab","z":"","name":"RELAY TEST","icon":"dashboard"}]
0 Likes

#6

Oh, here is my suggestion. Add a debug note to the output of each of the "Get Parms' functions and to the out of the "Save Parms' function. Next add an inject node to the input of the 'Relay-Seven' node and do some testing.

What does the debug log tell you?

0 Likes

#7

debug tells me this when i presss the inject note

"undefined rwrite undefined on"

and

"undefined rwrite undefined off"

0 Likes

#8

I'd start by reading the docs about how to set and get context and then look at your "state" node

You don't say where those debugs are coming from. But if I assume they are after
msg.payload = StackValue+msg.payload+RelayValue+" on";
It means that StackValue and RelayValue are undefined. Which given the flow you shared is what I would expect.

0 Likes

#9

the stacksvalue are difined in an other part of my flow

but the debugs are both coming from the Get Parms
which is sending to the Mega-io extension for my rasperry

but the button itself works now but not the IRL button

0 Likes

#10

Are you sure the flow that initilizes the values is tun before this flow???

0 Likes