# Controlling Relay

**URL:** <https://discourse.nodered.org/t/controlling-relay/13243>\
**Category:** General\
**Created:** [13 July 2019 15:16 UTC](https://discourse.nodered.org/t/controlling-relay/13243 "2019-07-13T15:16:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lungsnjokoafrica](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lungsnjokoafrica/32/10101_2.png) [@lungsnjokoafrica](https://discourse.nodered.org/u/lungsnjokoafrica)\
**Post date:** [13 July 2019 15:16 UTC](https://discourse.nodered.org/t/controlling-relay/13243/1 "2019-07-13T15:16:46Z")

</div>

Hi all,

I'm really new to node-red and I've been playing around with it for a couple of weeks. I'm trying to use the light scheduler to turn a relay channel on and off but I find that whatever is sent to the raspberry Pi GPIO pin connected to the relay channel (0,1 or nothing) the relay channel will remain on for as long as the GPIO pin output is on the flow.

I've also tried to inject 0 or 1 with no difference. Any thoughts on what I could try.

Thank you so much for the help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 July 2019 18:39 UTC](https://discourse.nodered.org/t/controlling-relay/13243/2 "2019-07-13T18:39:00Z")

</div>

Post the terminal log when you start node red and post a small flow with the inject and gpio node.

---

<div class="post-metadata">

**Author:** ![lungsnjokoafrica](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lungsnjokoafrica/32/10101_2.png) [@lungsnjokoafrica](https://discourse.nodered.org/u/lungsnjokoafrica)\
**Post date:** [13 July 2019 22:49 UTC](https://discourse.nodered.org/t/controlling-relay/13243/3 "2019-07-13T22:49:03Z")

</div>

Terminal log:

```auto
Starting as a systemd service.
Started Node-RED graphical event wiring tool.
14 Jul 00:38:28 - [info]
Welcome to Node-RED
===================
14 Jul 00:38:28 - [info] Node-RED version: v0.20.7
14 Jul 00:38:28 - [info] Node.js version: v8.11.1
14 Jul 00:38:28 - [info] Linux 4.19.57-v7+ arm LE
14 Jul 00:38:37 - [info] Loading palette nodes
14 Jul 00:38:54 - [info] Settings file : /home/pi/.node-red/settings.js
14 Jul 00:38:54 - [info] Context store : 'default' [module=memory]
14 Jul 00:38:54 - [info] User directory : /home/pi/.node-red
14 Jul 00:38:54 - [warn] Projects disabled : editorTheme.projects.enabled=false
14 Jul 00:38:54 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
14 Jul 00:38:54 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
14 Jul 00:38:54 - [info] Starting flows
14 Jul 00:38:54 - [info] Started flows
14 Jul 00:38:54 - [info] Server now running at http://127.0.0.1:1880/

```

---

<div class="post-metadata">

**Author:** ![lungsnjokoafrica](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lungsnjokoafrica/32/10101_2.png) [@lungsnjokoafrica](https://discourse.nodered.org/u/lungsnjokoafrica)\
**Post date:** [13 July 2019 23:02 UTC](https://discourse.nodered.org/t/controlling-relay/13243/4 "2019-07-13T23:02:13Z")

</div>

[{"id":"1f89d4db.776aeb","type":"rpi-gpio out","z":"fba85.43f8a57b8","name":"Light A","pin":"35","set":"","level":"0","freq":"","out":"out","x":310,"y":140,"wires":}]

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 July 2019 06:26 UTC](https://discourse.nodered.org/t/controlling-relay/13243/5 "2019-07-14T06:26:15Z")

</div>

Please see this post on how to share a flow, however I can see that you have not included inject nodes to exercise the output.  
Also check in the terminal whether any error is shown when you exercise the output.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…
