py-gpio-output
A simple subflow to control Rapsberry GPIO out.
Dependencies
- function node
- python-function node
- python GPIO library
Usage
The node has a single configuration to set the BCM GPIO pin number to control. Then the user needs to send a msg.payload containing the boolean value of the output.[{"id":"7a3645b5a30f194b","type":"subflow","name":"PyGpioOut","info":"","category":"Raspberry Pi","in":[{"x":160,"y":120,"wires":[{"id":"0392c5d96995fb8b"}]}],"out":[],"env":[{"name":"pin","type":"num","value":"0"}],"meta":{},"color":"#3FADB5","icon":"node-red/rpi.svg"},{"id":"ce25770598faab2b","type":"python-function","z":"7a3645b5a30f194b","name":"SetGpioOut","func":"from RPi import GPIO\n\nGPIO.setwarnings(False)\n\nGPIO.setmode(GPIO.BCM)\n\nGPIO.setup(msg['gpioPin'], GPIO.OUT)\n\nif msg['payload'] == True:\n GPIO.output(msg['gpioPin'], GPIO.HIGH)\nelse:\n GPIO.output(msg['gpioPin'], GPIO.LOW)\n\n#GPIO.cleanup()\n\nreturn msg","outputs":1,"x":450,"y":120,"wires":[[]]},{"id":"0392c5d96995fb8b","type":"function","z":"7a3645b5a30f194b","name":"","func":"msg.gpioPin = env.get(\"pin\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":120,"wires":[["ce25770598faab2b"]]}]