UNPKG

@iiot2k/node-red-gpio

Version:

Node-RED nodes for Raspberry Pi gpio

104 lines (94 loc) 3.73 kB
<!-- Copyright 2025 Derya Y. (iiot2k@gmail.com). Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <script type="text/javascript"> RED.nodes.registerType('iiot2k-gpio-out', { category: 'iiot2k', color: 'Coral', paletteLabel: 'gpio-out', defaults: { gpio: { value: 20, required: true, validate: function (v) { return (RED.validators.number(v) && (v >= 0) && (v <= 27)); } }, mode: { value: "output", required: true }, activate: { value: false, required: true }, name: { value: "" }, }, inputs: 1, outputs: 0, icon:"font-awesome/fa-microchip", labelStyle: function() { return this.name ? "node_label_italic" : ""; }, label: function () { return this.name || "gpio" + this.gpio + "-out"; }, }); </script> <script type="text/html" data-template-name="iiot2k-gpio-out"> <div class="form-row"> <label style="width:100%; border-bottom: 2px solid rgb(0, 0, 0);"><b>GPIO digital output</b></label> </div> <div class="form-row"> <label for="node-input-gpio">GPIO</label> <input id="node-input-gpio" input type="number" min="0" max="27" required style="width: auto;"> </div> <div class="form-row"> <label for="node-input-mode">Mode</label> <select type="text" id="node-input-mode" style="width: auto;"> <option value="output">output</option> <option value="sink">output sink</option> <option value="source">output source</option> </select> </div> <div class="form-row"> <label for="node-input-activate">Activate</label> <input type="checkbox" id="node-input-activate" style="display: inline-block; width: auto; vertical-align: top;"> </div> <div class="form-row"> <label for="node-input-name">Name</label> <input id="node-input-name" type="text"> </div> </script> <script type="text/markdown" data-help-name="iiot2k-gpio-out"> GPIO digital output ### Input : *payload* (number/boolean) : sets output state : *toggle* (any) : toggles GPIO : *blink* (number) : blink GPIO with period in ms (0..)<br> 0 stops blink : *blink_stop* (any) : stops blinking : *pulse* (number) : pulse GPIO with period in ms (0..)<br> 0 stops pulse : *pulse_stop* (any) : stops pulse : *pwm.duty* (number) : pwm duty cycle in % (0..100)<br> 0 turns output off<br> 100 turns output on : *pwm.freq* (number) : pwm frequency in Hz (0..1000)<br> 0 stops pwm : *pwm_stop* (any) : stops pwm ### Details This node sets, toggles, blinks, pulses or pwm GPIO output.<br> Only one node per pin is possible.<br> <br> ```Mode:```<br> **output:**<br> 0 Connect to ground.<br> 1 Connect to +3.3V.<br> **output sink:**<br> 0 Set to Hi-Z.<br> 1 Connect to ground.<br> **output source:**<br> 0 Set to Hi-Z.<br> 1 Connect to +3.3V.<br> <br> ```Activate:```<br> **unchecked:**<br> Set output to 0 on start.<br> **checked:**<br> Set output to 1 on start.<br> <br> This node works on Raspberry Pi with 64bit OS.<br> Check with raspi-config for alternate functions on GPIO.<br> If alternate function on GPIO is overwritten then malfunction is made.<br> </script>