# What is the best function to use on a relay

**URL:** https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711
**Category:** General
**Created:** [19 August 2020 00:37 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711 "2020-08-19T00:37:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Doberman19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/doberman19/32/27399_2.png) [@Doberman19](https://discourse.nodered.org/u/Doberman19)
#### Post date: [19 August 2020 00:37 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/1 "2020-08-19T00:37:38Z")

</div>

Hello everyone,

I am new to node red and have a simple question.This probably sounds like a broken record for most of y’all. I’m attempting to build an aeroponics veggie garden and need some of y’alls expert help. I’m using a raspberry pi 3b with a NCD relay controller and need to to control some solenoid valves. I have already gone through some of the basic tutorials and have used the inject and delay nodes off the pallet (pretty dang cool thanks node red). Now to my first of many questions... what would best way to have this valve open for 30 sec then close for 5 min and repeat indefinitely. Thanks In advance for your replies and advice.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [19 August 2020 00:59 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/2 "2020-08-19T00:59:42Z")

</div>

Something like this?

```auto
[{"id":"997419c6.232068","type":"trigger","z":"d103f472.19f3c8","op1":"open","op2":"close","op1type":"str","op2type":"str","duration":"30","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":340,"y":3140,"wires":[["efde99d1.90524"]]},{"id":"cb3ee4fc.bdaeb","type":"inject","z":"d103f472.19f3c8","name":"Trigger","topic":"","payload":"foo","payloadType":"str","repeat":"300","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":3140,"wires":[["997419c6.232068"]]},{"id":"efde99d1.90524","type":"debug","z":"d103f472.19f3c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":3140,"wires":[]}]

```

Get the output of the `trigger` node (`open` and `close` for simplicity) and handle that to control the valve.

I don't get the NCD relay controller, but.....

Use those _words_ (or change them) to control the relay and ...... voila!

---

<div class="post-metadata">

### Author: ![Doberman19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/doberman19/32/27399_2.png) [@Doberman19](https://discourse.nodered.org/u/Doberman19)
#### Post date: [19 August 2020 01:27 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/3 "2020-08-19T01:27:02Z")

</div>

Thanks I’ll give that a try after dinner. [NCD.io](http://NCD.io) is just a brand (not a bad looking board says made in the USA if that means anything).

---

<div class="post-metadata">

### Author: ![Doberman19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/doberman19/32/27399_2.png) [@Doberman19](https://discourse.nodered.org/u/Doberman19)
#### Post date: [19 August 2020 04:10 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/4 "2020-08-19T04:10:39Z")

</div>

Using the trigger and delay got it work to in about 3 mins and done....pretty neat . Thanks for the help. I’ll be back to ask more questions.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [19 August 2020 04:26 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/5 "2020-08-19T04:26:28Z")

</div>

No problems.

I guess you need to have a good idea of what Node-Red is and what it can do, and can't.

Good luck.

And: Don't be afraid to ask. The worst question is the one you don't ask.  
😉

---

<div class="post-metadata">

### Author: ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)
#### Post date: [19 August 2020 07:16 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/6 "2020-08-19T07:16:56Z")

</div>

Looks like they have an impressive set of IoT-enabled products with scalability build-in and that they know what they are doing. Thanks for sharing.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 October 2020 07:17 UTC](https://discourse.nodered.org/t/what-is-the-best-function-to-use-on-a-relay/31711/7 "2020-10-18T07:17:06Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
