Countdown timer for relay

Community contributed apps
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sun Oct 11, 2015 3:46 pm
What is the port supposed to do. Just cause the code you posted is gonna run that port for 2 minutes every 6 hours.

Try and put the following before the if statement.

ReefAngel.Relay.Off(Box2_Port6);

Is that the port your using anyway? You have to change the code to use the correct port. I don't see any Box1 or other Box2 ports...

Posts: 171
Joined: Fri May 23, 2014 8:09 am
PostPosted: Sun Oct 11, 2015 4:07 pm
Facepalm ;) I thought that having two boxes meant I had a box 1 and a box 2. After reading your comment I realized that box 1 is actually my second box. After that came together it was simple to change the time values and remove the "else" line and it's working perfectly. Thanks!
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sun Oct 11, 2015 9:11 pm
Awesome. Can you post your final code that you used.

Posts: 171
Joined: Fri May 23, 2014 8:09 am
PostPosted: Mon Oct 12, 2015 7:54 am
I ran into some issues last night, but think it's working now. I'll post the code once I'm sure it's stable and correct, just doing a little testing today.
Image

Posts: 171
Joined: Fri May 23, 2014 8:09 am
PostPosted: Wed Oct 14, 2015 8:09 am
Here's what I ended up with. It runs for one hour and repeats every two days. , I have to wait two days to be sure it actually repeats, but I think it will:

Code: Select all
  int repeat=2880; // in minutes
  int runtime=3600; // in seconds
  static time_t t;
 
  // Manual mode
  if (ReefAngel.Relay.isMaskOn(Box1_Port6)) {
    ReefAngel.Relay.Auto(Box1_Port6);
    t=now();
  } 

  if (now()-t < runtime) {
    ReefAngel.Relay.On(Box1_Port6);
  } else {
    ReefAngel.DosingPumpRepeat(Box1_Port6,0,repeat,runtime);   
  } 
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Oct 14, 2015 8:13 am
Cool and triggering manually is working? What are you automating here?

Posts: 171
Joined: Fri May 23, 2014 8:09 am
PostPosted: Thu Oct 15, 2015 8:39 am
Yep, when I toggle the relay from the app it opens the relay for the set amount of time (60 minutes currently) and shuts off again. It then runs automatically every two days for 60 minutes.

I'm using this code to control a solenoid on my RODI system. It refills my fresh water container on a regular basis and other containers on demand.

My fresh water container has a shut off float in it, but I overflowed other water containers too many times, so it's nice to have something that will shut off automatically.

I wonder if this function could be built into the app that would allow one to start a countdown timer for any relay, after which the relay would return to its normal function. Seems like something a lot of people would use, and would be a lot simpler than changing to code frequently.
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Oct 15, 2015 12:53 pm
I have a class in the libraries called TimedPort that does this. I would recommend looking at the water level sensor module and then just using the WaterLevelATO function to control the solenoid.
Previous

Return to Apps

Who is online

Users browsing this forum: No registered users and 2 guests