# Where to apply a delay: Arduino or NodeRed

**URL:** <https://discourse.nodered.org/t/where-to-apply-a-delay-arduino-or-nodered/56116>\
**Category:** General\
**Tags:** mqtt\
**Created:** [4 January 2022 22:43 UTC](https://discourse.nodered.org/t/where-to-apply-a-delay-arduino-or-nodered/56116 "2022-01-04T22:43:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@Noh](https://discourse.nodered.org/u/Noh)\
**Post date:** [4 January 2022 22:43 UTC](https://discourse.nodered.org/t/where-to-apply-a-delay-arduino-or-nodered/56116/1 "2022-01-04T22:43:08Z")

</div>

I have wired an NodeMCU ESP8266 to an SHT30 humidity monitor and publish its reading every 10 sec.  
NodeRed subscribes to the published _humidity_ topic and checks it against a threshold value (95%). If it's over that, then the flow publishes an _ON_ value on a _fanswitch_ topic, and another ESP8266, which subscribes to that topic (and has a relay controlling a bathroom fan), turns on the fan until it receives an _OFF_ value. This all works well. Shower on, short delay, fan on. Shower off, slightly longer delay, fan off.

I have just added a momentary switch and a red and green LED to the ESP8266 that has the SHT30 sensor, with a view to introducing manual overrides to the humidity threshold switch (in an executable node in my NodeRed flow. I detect the switch and have it toggle between three modes on the ESP8266.

I'm not sure what the best pattern would be.  
1/ keep the timing on the ESP8266 and use it to control the LEDs (red=fan off ie cease publishing the humidity value, green=fan on for 10 mins ie publish a high value humidity for a bit or both off=let the published humidity through.  
OR  
2/ publish the switch mode (0, 1 or 2) and do the timing LED and fan control in NodeRed

Any thoughts on the best approach. The cease publishing method does mean the NodeRed dashboard won't have continuous humidity graphs for manual override periods. Are there gotchas for letting NodeRed take the strain in this scenario?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 January 2022 23:10 UTC](https://discourse.nodered.org/t/where-to-apply-a-delay-arduino-or-nodered/56116/2 "2022-01-04T23:10:07Z")

</div>

I would suggest you control the timing in node-red if for no other reason then it is easier to change in node-red than on the esp8266.

Let’s assume you are using mqtt to send the msgs to NR. You can add a trigger or delay node after the mqtt-in node, to control how much data gets passed on.

---

<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 January 2022 23:11 UTC](https://discourse.nodered.org/t/where-to-apply-a-delay-arduino-or-nodered/56116/3 "2022-01-18T23:11:01Z")

</div>

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