Multiple scheduled outlet times

Do you have a question on how to do something.
Ask in here.
Post Reply
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Multiple scheduled outlet times

Post by Spotted »

I am moving my programming to the internal memory. I would like to set up different scheduled times for certain lights and power heads.
Is it possible to have 2 different scheduled times? I have been using the Wizard, but it only allows for 1 time for what it calls the light schedule.
I want to shut off my power heads at 10 PM and turn on turf scrubber LEDs at 6 PM, also I want them both to turn back on at different times as well.
Is this possible?
I also want one more thing. Is it possible to turn on Nutrient Mode for my Jebao power heads once Feeding Mode has ended?

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port7Bit | Port8Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port3 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Box1_Port8 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.SingleATOLow( Port1 );
    ReefAngel.DayLights( Port5 );
    ReefAngel.StandardHeater( Port6 );
    ReefAngel.Relay.DelayedOn( Port7 );
    ReefAngel.Relay.DelayedOn( Port8 );
    ReefAngel.DosingPumpRepeat1( Box1_Port3 );
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    
    if ((now()%SECS_PER_DAY==31320)) //if it is 8:42 AM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE
    if ((now()%SECS_PER_DAY==67320)) //if it is 6:42 PM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "spotted" );
    ReefAngel.ShowInterface();
}

Image
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

Can I do a mix of standard lights in the memory locations and manually code in the other times?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple scheduled outlet times

Post by rimai »

Yes, you can do that.
Do you use android app?
You can use StandardLights and MHLights.
They use 2 different schedules, but the memory locations for MHLights are only available on the android app or you would have to use direct HTTP calls to the controller.
Roberto.
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

I do use the android app and I think I would be lost without it!! I totally love it!
Image
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

I understand that if I put the times in the code, I can't change it without recoding. If I put the times in the internal memory then I can change them from the app, is this correct?
I only need to occasionally change one set of times maybe from time to time.

Also I can set delay ports in the code too, like I would with lighting times? I have 2 different delay times one for the return pump to come on 2 minutes and another for the skimmer to come on after 5 minutes.

How would I define which port is used for the MHLights and which for the StandardLights if I wanted to go all internal memory?
Sorry, I have no coding skills, I am a home theater installer. Ask me to hang your TV or put speakers in your ceiling, I'm all over that!!
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple scheduled outlet times

Post by rimai »

You can use:

Code: Select all

ReefAngel.StandardLights(Port1);
ReefAngel.MHLights(Port2);
The delay timer is only one though.
Roberto.
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

Ok, so I have set up internal memory stuff.. I'm having a little trouble with an aqualifter that I want to come on every hour for 15 minutes. Right now it seems to stay on all the time.
Here is the code I'm using for it. Can you let me know if this is correct?

Code: Select all

 
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); // Turn on Aqualifter for 15 minutes
    }
I was also wondering if I could get the aqualifter to kick on for a few minutes after feeding mode ends. The lifter is used to clear air out of an overflow.

Here's my whole code just in case

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port3 ); //Sump Powerhead. Relay 1 Port 3
    ReefAngel.Relay.On( Port5 ); //Display Tank Power Heads Relay 1 Port 5
    ReefAngel.Relay.On( Port8 ); //Return Pump Relay 1 Port 8
    ReefAngel.Relay.On( Box1_Port1 ); //ATS Air Pump. Relay 2 Port 1
    ReefAngel.Relay.On( Box1_Port2 ); //Media Reactor. Relay 2 Port 2
    ReefAngel.Relay.On( Box1_Port8 ); //Reef Breeders LED Light. Relay 2 Port 8

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.SingleATOLow( Port1 );
    ReefAngel.StandardHeater( Port6 ); //Relay 1 Port 6
    ReefAngel.Relay.DelayedOn( Port7 ); //Skimmer Relay 1 Port 7
    ReefAngel.MHLights( Box1_Port4 ); //ATS Light Relay 2 Port 4
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    
    if ((now()%SECS_PER_DAY==31320)) //if it is 8:42 AM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE
    if ((now()%SECS_PER_DAY==67320)) //if it is 6:42 PM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); // Turn on Aqualifter for 15 minutes
    }
    if (hour()>=22 || hour()<9)
    { // Sleep mode - slow things down 
    ReefAngel.DCPump.SetMode( ReefCrest,25,10 );
    }
    else
    {
    // Normal power
    ReefAngel.DCPump.SetMode( ReefCrest,50,10 );
    }
    
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "spotted" );
    ReefAngel.DDNS( "7730.homeip.net:2000" ); // Your DDNS is spotted-7730.homeip.net:2000.myreefangel.com
    ReefAngel.ShowInterface();
}


Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Add an off statement before or an else statement as part of the if.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Another way to do it is this

ReefAngel.Relay.Set(Box1_Port3, now()%3600<900);

Then you dont need any if statement because your setting the relay state on/off based on the result of your expression true/false.
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

So replace all of this

Code: Select all

 
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); // Turn on Aqualifter for 15 minutes
    }
with this?

Code: Select all

ReefAngel.Relay.Set(Box1_Port3, now()%3600<900);
Image
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

The other way with the else statement would look like this?

Code: Select all

 
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); 
    }
    } else {
    ReefAngel.Relay.Off(Box1_Port3); 
    }
I'm trying to learn how to properly use the if/else statement.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Like this:

Code: Select all

 
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); 
    } else {
    ReefAngel.Relay.Off(Box1_Port3); 
    }
you had an extra }
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

Yes
I see it, the line above the else line right?

So how about this? This looks a lot less complicated than the if else argument,.
Spotted wrote:So replace all of this

Code: Select all

 
    if (now()%3600<900)
    { //Every 60 minutes
    ReefAngel.Relay.On(Box1_Port3); // Turn on Aqualifter for 15 minutes
    }
with this?

Code: Select all

ReefAngel.Relay.Set(Box1_Port3, now()%3600<900);
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Yes and yes
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

I'm happy, my code is coming along.
Next project. Is there a way to get the power heads to go into Nutrient Transport mode after a feeding?
Can I modify this to work?

Code: Select all

    if ((now()%SECS_PER_DAY==31320)) //if it is 8:42 AM
    {ReefAngel.FeedingModeStart();}
Just change the times to coincide with the automated feeding?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

If you're good at reading code you should try and look through my INO. I know mine is a bit complex so I'll try and simplify the request here for you:

Code: Select all

  int ntmDelay=300; // Time to wait before starting Nutrient Transport
  int ntmTime=7200; // Time to run Nutrient Transport
  static time_t t;

  if (now()-t > ntmDelay && now()-t < ntmTime+ntmDelay) {
    ReefAngel.DCPump.Mode=NutrientTransport; 
  }
  
  if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
    t=now(); // Run post feeding mode when this counter stops 
  }
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

Ok, I don't think I'm going to use the NT mode after feeding. I might schedule it at a certain time of the day instead.
I have another request. I have the 12V power thingy I want to use to run a couple of water solenoid valves. I understand that it shows up as another relay box. I understand that I need to write it in the code as follows to turn ports on and off.

ReefAngel.Relay.On(Box2_Port3);

Thing is I will only be using them right now as manual ports to refill my ATO reservoir and water change barrels. How do I make them accessible in the app?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

They should show up once activated. If you don't already have a relay expansion, it should be Box1 rather than Box2.
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

I do have another relay. I have 2 regular relay boxes and then the 12 volt power expansion. How would I activate it? Just plug it in to the system and it adds another set of relays in the app?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Reference it in the code, then compile and upload and it should be recognized.
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

I'm sorry, I am not sure how to reference it in the code. I'm not a coder. I'm a home theater installer.. Sorry...
Image
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

Actually I think I understand. I could just reference them as off in the code and then I will get the ability to control them in the app right? Something like this?

Code: Select all

ReefAngel.Relay.Off(Box3_Port1);
ReefAngel.Relay.Off(Box3_Port2);
Is this right?
Image
Spotted
Posts: 101
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida

Re: Multiple scheduled outlet times

Post by Spotted »

No, It should be

Code: Select all

ReefAngel.Relay.Off(Box2_Port1);
ReefAngel.Relay.Off(Box2_Port2);
Box2 not Box3, yes?

I got a Main Relay (Box), Expansion Relay(Box1), and the Power Control Module(Box2)

Yes?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple scheduled outlet times

Post by lnevo »

Yes
Post Reply