# Won't restart after delay

**URL:** <https://forum.xod.io/t/wont-restart-after-delay/864>\
**Category:** Uncategorized\
**Created:** [June 18, 2018, 5:40am UTC](https://forum.xod.io/t/wont-restart-after-delay/864 "2018-06-18T05:40:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sios](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sios](https://forum.xod.io/u/sios)\
**Post date:** [June 18, 2018, 5:40am UTC](https://forum.xod.io/t/wont-restart-after-delay/864/1 "2018-06-18T05:40:28Z")

</div>

Hello  
i make some automatic filling system for my aquarium. actually this code work fine. The problem happen if the fresh water container empty and im late to fill with the new fresh water.

The idea is sensor read the water level and if the level below the desire it will turn on pump to fill the tank with the delay 15s (the pump will on for 15s then off) if the water reach the sensor no problem will occurs. but if the water cant reach the pump it will stop working until i restart the arduino or lower the sensor to the water then place it again in the original place (need to manually restart the sensor value to make it work again)

for information if i didn’t use the delay node everything work fine even if the water can’t reach the sensor then it will turn on the pump until the water reach the desire level.

i choose to using delay because the sensor is sensitive if not using delay the relay will on off on off in short time and i believe it will short the relay age and make some annoying noise 😅

can someone help me solve this issue?  
i upload my code for more details  
Thanks  
[ATONEWv2.xodball](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/3b29ae8bf889fb049e2df5e52ff89d623b1f99c5.xodball) (3.4 KB)

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [June 18, 2018, 8:30am UTC](https://forum.xod.io/t/wont-restart-after-delay/864/2 "2018-06-18T08:30:08Z")

</div>

Hello!

Here’s your patch for reference:

 ![Screenshot%20from%202018-06-18%2011-24-57](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/de3c1ebfb5b882a99a447cfcf1e1f61d6aa3896c.png)

> [@sios](#):
>
> …but if the water cant reach the pump it will stop working until i restart the arduino or lower the sensor to the water then place it again in the original place

It stops working until a new pulse to `delay`, that is when greater outputs `false` and then `true` again, that is util the water overflows and underflows again.

I am not sure what behavior you’re trying to achieve if the fresh water tank is empty? If you want to keep trying until the water sensor is reached but handle the relay carefully, try to use [`xod/core/debounce`](https://xod.io/libs/xod/core/debounce/) instead of `delay`.

---

<div class="post-metadata">

**Author:** ![sios](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sios](https://forum.xod.io/u/sios)\
**Post date:** [June 18, 2018, 3:10pm UTC](https://forum.xod.io/t/wont-restart-after-delay/864/3 "2018-06-18T15:10:42Z")

</div>

yes i want it to keep trying until the the water reach the sensor.

it works perfect like i want. thanks a lots 🙂

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [June 18, 2018, 3:29pm UTC](https://forum.xod.io/t/wont-restart-after-delay/864/4 "2018-06-18T15:29:47Z")

</div>

One idea is to feed “needs more water” sensor directly to pump, but in parallel, have the delay node that keeps it running for at least 15s (‘or’ the output of sensor & delay to run pump). This will cause it to run for at least 15s, but continue to run if level is still below sensor.

Probably a better alternative is to drop the delay timer and use flip-flop to remember pump state. Set the flip-flop when water drops below one level, reset the flip-flop when water rises above a higher level. For example, assuming you are using range-finder to determine water level, turn pump on at \>8cm, turn pump off at \<7cm.

---

<div class="post-metadata">

**Author:** ![sios](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sios](https://forum.xod.io/u/sios)\
**Post date:** [June 19, 2018, 1:08am UTC](https://forum.xod.io/t/wont-restart-after-delay/864/5 "2018-06-19T01:08:42Z")

</div>

great idea i will try it and see which method is the most effective

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [June 21, 2018, 1:08am UTC](https://forum.xod.io/t/wont-restart-after-delay/864/6 "2018-06-21T01:08:50Z")

</div>

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