Can i turn on/off a port based on water level?

Do you have a question on how to do something.
Ask in here.
User avatar
Posts: 86
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Wed Mar 20, 2019 2:37 am
Ahhh... still learning the functions too and the ReefAngel.Relay.Set() function is a logical TRUE/FALSE.

But how do you accomplish the range of port ON that is desired using it?

The original goal was on at or below 85 and off at 95. The first condition is met but the second isn't. I added the check for above 9 because I've had the overfill happen (with the associated shopvac usage :oops: ).

Also, if a TRUE/FALSE is used for this function the ATO relay is going to cycle often at the 85 mark; on at 85 off at 86. Correct?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink

Posts: 52
Joined: Mon Oct 01, 2018 5:55 pm
PostPosted: Wed Apr 03, 2019 10:00 am
So this is working great when it comes to turning on the relay when water reached a certain level
However i ran into another issue, the water level tends to jump 1-3% from 89-92 back and forth.

Is there a way to put a delay on this relay as well?

I did try adding to the code:
ReefAngel.Relay.DelayedOn( Port7,1200 );

So it would delay to turn it on for 20 minutes, but it does not seem to be working.
User avatar
Posts: 5418
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Apr 03, 2019 4:45 pm
DelayedOn only works after reboot, feeding mode or waterchange mode.

What you want to do is set the relay override which you can do with

ReefAngel.Relay.Override(Port7, false);

That will turn the relay on definitively. However it won't go back on unless you do it manually or add additional logic to put it back on after 20 minutes or if the WL changes to something else.

Posts: 52
Joined: Mon Oct 01, 2018 5:55 pm
PostPosted: Thu Apr 04, 2019 10:24 am
lnevo wrote:DelayedOn only works after reboot, feeding mode or waterchange mode.

What you want to do is set the relay override which you can do with

ReefAngel.Relay.Override(Port7, false);

That will turn the relay on definitively. However it won't go back on unless you do it manually or add additional logic to put it back on after 20 minutes or if the WL changes to something else.


Oh i see, so what i am trying to do will not work unless i figure out some other logic to turn it back on after 20 minutes or whatever time.

Just want this port to have a delayed on time based off any 'on' trigger.

Ideally it would work like this:
Water level gets to 90%
Port 7 (ATO port) Turns on RODI water. Until water level gets above 90% (91%)

What is happening is water level is jumpung from 89% to 92% every few seconds causing the relay to go crazy.

So ideally it would work like this:
Water level gets to 90%
Port 7 Turns on after a delayed time of 20 minutes to fill RODI water
Water level jumps betwen 89-92%
Port 7 turns off and has a delayed turn on time of 20 minutes
After 20 minutes Port 7 (ATO port) Turns on RODI water.


I dont care if my water level drops below 85% as long as it eventually gets filled to 90%. And it seems a delay on for the port would do the job. Maybe even a longer delay on time, which is something i can eventually mess with.

Posts: 12486
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Apr 04, 2019 9:47 pm
I'm not understanding why use the timer is the level is the best way to go.
Have you tried the code you said you would? Can you explain to me so I better understand why the code didn't work?
Code: Select all
                 if ( ReefAngel.WaterLevel.GetLevel(2) <= 85 && ReefAngel.WaterLevel.GetLevel(2) > 9 ) ReefAngel.Relay.On( Port7 );

                 if ( ReefAngel.WaterLevel.GetLevel(2) >= 95 ||  ReefAngel.WaterLevel.GetLevel(2) = 0 ) ReefAngel.Relay.Off( Port7 );

Relay would turn on only when goes below 85 and turn off when above 95. Even if it bounces around, it would not turn back on until it goes all the way down to 85 again.
Roberto.

Posts: 52
Joined: Mon Oct 01, 2018 5:55 pm
PostPosted: Fri Apr 05, 2019 8:42 am
The code is throwing an error:

In function 'void loop()':
error: lvalue required as left operand of assignment


Looks like it does not like = 0
User avatar
Posts: 5418
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Apr 05, 2019 7:09 pm
= is an assignment not a comparison. So here you are trying to set a function to equal 0. = by itself is used to set the value of a variable int i = 4; for example. What you want is to use a comparison, is it equal to which is represented by == alternatively if you ever need, you can use != along with < > <= >=

Posts: 52
Joined: Mon Oct 01, 2018 5:55 pm
PostPosted: Sat Apr 06, 2019 7:07 am
Thank you for the explanation.

This is working perfectly now.
Previous

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 2 guests

cron