Page 1 of 3

Reefology's code

Posted: Mon Jan 05, 2015 4:23 pm
by Reefology
Current code

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

void SeasonalTemps ()
 {
  static int heatArray[][2] = { {778,784},// default in case of error in month=0 (May)
                    {762,768},//January (winter)
                    {766,772},//February (winter)
                    {770,776},//March (early spring)
                    {774,780},//April (spring)
                    {778,784},//May (spring)
                    {782,788},//June (early summer)
                    {786,792},//July (summer)
                    {782,788},//August (summer)
                    {778,784},//September (early fall)
                    {772,780},//October (fall)
                    {770,776},//November (fall)
                    {766,772} };//December (early winter)
                   
               
  ReefAngel.StandardHeater( Port1,heatArray[month()][0],heatArray[month()][1]);
 }//end seasonalTemps

////// 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 = Port3Bit | Port5Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port5Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    
    //Feeding Timer
    ReefAngel.Timer[FEEDING_TIMER].SetInterval(2100);


    // Ports that are always on
 
    ReefAngel.Relay.On( Port5 );
    

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

void loop()
{
    SeasonalTemps();
    
    ReefAngel.ActinicLights( Port2 ); // Royal blue led strip
    ReefAngel.DayLights( Port4 ); // T5's
    ReefAngel.StandardFan( Port6 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.ActinicPWMSlope();

    ////// Place your custom code below here
    
    // koralia 1150
    // if (hour()>=23 || hour()<11) ReefAngel.Relay.Off( Port5 );
    // else ReefAngel.WavemakerRandom( Port5, 120, 1800 );
    
    //ATO
    //if ((hour()>=20 || hour()<=8) && (ReefAngel.Params.PH < 830))
   // {
    // ReefAngel.SingleATO(false,Port5,180,0);   //  Sump switch. Kalk schedule 8pm - 8am if pH < 8.3  If ATO/Kalk runs for 180 seconds, shut off and send alert.
   // }
    // else   
    //{
    // ReefAngel.SingleATO(false,Port8,180,0);   //  Sump switch.  If ATO/RoDi runs for 180 seconds, shut off and send alert.
   // }
   
    //skimmer off when collection container is full
    if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port3);
    else ReefAngel.StandardLights( Port3, 17,0,9,0); //skimmer off 9am-5pm 
    
    //light mover
    //if (hour()>=9 && hour()<=21) ReefAngel.DosingPumpRepeat( Port6,0,90,2 );   //  from 9am - 9pm, moves 2 seconds every 90 minutes with 0 minutes offset
    //else ReefAngel.Relay.Off( Port6);

    
    //kalk dosing
    if ((hour()>13 && hour()<20) || (ReefAngel.Params.PH > 845))
   {
    ReefAngel.Relay.Off( Port7); //  Kalk off 1pm - 8pm & if pH is > 8.45   
   }
   else   
   {
    ReefAngel.PHControl( Port7 );
   }
   
   //carbon dosing
    if (hour()>=6 && hour()<23) ReefAngel.DosingPumpRepeat1( Port8 );  
    else ReefAngel.Relay.Off( Port8);

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

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




-----------------------------------------------------------------------------------------------------------------

Original Post

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 = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    ReefAngel.Relay.On( Port8 );

    ////// Place additional initialization code below here
    
    ReefAngel.DDNS( "" ); 

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

void loop()
{
    ReefAngel.DosingPumpRepeat1( Port1 );
    ReefAngel.MoonLights( Port2 );
    ReefAngel.ActinicLights( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.WavemakerRandom( Port5,119,1200 );
    ReefAngel.WavemakerRandom( Port6,99,1000 );
    ReefAngel.StandardHeater( Port7 );
    ////// Place your custom code below here
    

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

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

Re: My code

Posted: Mon Jan 05, 2015 4:25 pm
by Reefology
so should i take the jebao port offline? well it isn't working anyway :D

Re: My code

Posted: Mon Jan 05, 2015 4:53 pm
by cosmith71
Just set it to always on, or plug it into a power strip. Let the stock Jebao controller handle the pump, unless you want to use a Jebao cable to control it with the RA.

You also need to remove this line:

Code: Select all

ReefAngel.DDNS( "Reefology" ); // Your DDNS is Reefology-tank.myreefangel.com
You already have a DDNS declaration in setup(). That's probably why you're having issues with your phone app.

--Colin

Re: My code

Posted: Mon Jan 05, 2015 4:58 pm
by Reefology
great Colin, will do. But you might want to note that i didnt manually add it, was done by the wizard.

I also wanted to add password authentication but havent' figured out how, can you help me with that? I'm aware i won't be able to use the iphone app until its supported.

thanks

Re: My code

Posted: Mon Jan 05, 2015 5:48 pm
by cosmith71
Must have been an evil Wizard. Voldemort is my guess. ;)

I don't use the password authentication. Maybe someone else can chime in. I do know you won't be able to use the iPhone app if you enable it.

--Colin

Re: Reefology's code

Posted: Mon Jan 05, 2015 5:51 pm
by lnevo
Add this in setup

ReefAngel.Network.WifiAuthentication("username:password");

Change username and password for whatever you'd like it to be.

Re: Reefology's code

Posted: Mon Jan 05, 2015 6:14 pm
by Reefology
great thanks, i forgot Roberto had already given it to me just couldn't find it.

Re: Reefology's code

Posted: Thu Jan 08, 2015 10:53 am
by Reefology
Added this custom code that i copied from anothher user but not getting desired result. Can someone explain each section so i can learn the code and make adjustments going forward please?

FYI, i changed ''if (now()%SECS_PER_DAY==600'' from 0 to 600 hoping to change mode every 10 mins.

Code: Select all

static int rmode;
    static boolean changeMode=true;


    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre };

    if (now()%SECS_PER_DAY==600 || changeMode==true) { // Change every 10 mins or if controller rebooted
    rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3600) {
    // Continue NTM for the 60 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Sine;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }

Re: Reefology's code

Posted: Thu Jan 08, 2015 11:00 am
by lnevo
What desired behavior are you trying to get and what behavior are you seeing instead..

Re: Reefology's code

Posted: Thu Jan 08, 2015 12:52 pm
by Reefology
thanks for the quick response. I have a single WP40 and would like to have alternate wave modes that change throughout each day, I'd like a calm mode at night running at 30% or less if possible (but not sure it is), I'd like to override via internal memory if possible and then have it revert back to random after a set time (but not a must have).

I like the way it kicks into night mode and feed mode but it doesnt alternate wave patterns listed in the code its stuck in else mode.

Thanks

Re: Reefology's code

Posted: Thu Jan 08, 2015 1:26 pm
by cosmith71
I think it's this line here.

Code: Select all

if (now()%SECS_PER_DAY==600 || changeMode==true) { // Change every 10 mins or if controller rebooted
This tells it to change modes every 24 hours and 10 minutes.

Try changing it to this.

Code: Select all

if (now()%600==0 || changeMode==true) { 
Edit: Forgot the {

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:07 pm
by Reefology
thanks so much, will try that. while we're at it, is there anyway to make the speed random? I assume some of the modes have random speed built in but i dont know which ones so I just selected all of them hoping to get a varying flow.

Thnaks

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:08 pm
by cosmith71
Here's some commented code. You will also find this link handy:

http://arduino.cc/en/Reference/HomePage

Look up the different kinds of data types (int, boolean, unsigned long) and also if...else. Also read up on arithmetic, boolean, and comparison operators.

Code: Select all

// Declare an integer (a whole number between -32,768 to 32,767) rmode
// and a boolean (false or true, 0 or 1) changeMode which is set to true.
// "static" means only initialize them once.  Otherwise they would be reset
// every time loop loops around.

static int rmode;
static boolean changeMode=true;


// These are the modes we can cycle through. You can add more and even repeat...
// modes[] is an array of bytes (whole numbers between 0 and 255).
byte modes[] = { 
  ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre };

// now() is a running tally of seconds since Jan 1, 1970.  It's a big number.
// % is modulo, it returns the remainder from division.  So, if the number of seconds ever
// divided by 600 is 0 (that is, every 600 seconds or 10 minutes) then this is true.
// The || means 'or'.  '==' means 'is equal to'.  So this line says 'if it's been 10 minutes, 
// or changeMode is equal to true, then do this stuff in these curly braces.
if (now()%600==0 || changeMode==true) { // Change every 10 mins or if controller rebooted
  rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
  changeMode=false;
}

// Set timer when in feeding mode
static unsigned long feeding;  // another variable declaration, type unsigned long
// Difference between '==' and '=':  '==' means 'is equal to' (comparing two things)
// '=' means 'make equal to' as in changing the value of something.  So this line
// says if the menu displayed is equal to FEEDING_MODE, then make the variable 'feeding'
// equal to the number of seconds returned by the function now()
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();

// if right now minus the time feeding was set is less than 3600 (seconds, remember now() returns
// seconds) then do the stuff in the curly braces.
if (now()-feeding<3600) {
  // Continue NTM for the 60 minutes
  ReefAngel.DCPump.UseMemory=false;  // Turn off portal control of the pumps
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();  // Get the portal pump duration from memory
  ReefAngel.DCPump.Mode=NutrientTransport;    // Manually set the mode to NutrientTransport
} 
// so if the above 'if' isn't true, do the stuff after 'else'.  If this thing is true, do this stuff, else do other stuff
// If it's been more than 60 minutes since feeding time, check to see if now (in seconds) divided by 
// the number of seconds per day (86400 to be exact) returns a remainder of less than 43200 (noon)
// or greater than 79200 (10 PM, 2200) then do some stuff
else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
  // Night mode (go to 30%)
  ReefAngel.DCPump.UseMemory=false;  // Turn off portal control of DC Pumps
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();  // Get portal duration from memory location
  ReefAngel.DCPump.Mode=Sine;  // Set the mode to Sine  
  ReefAngel.DCPump.Speed=30;   // With a speed of 30
} 
// if the above isn't true, check this
else if (InternalMemory.DCPumpMode_read()==11) {
  // Custom Mode set on portal and nothing else going on (not feeding time, not night time)
  ReefAngel.DCPump.UseMemory=false;  // Turn off portal control of pumps
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();  // Get the duration
  ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
  ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} 
// if none of this stuff was true, default to this
else {
  // Do whatever the portal says to do with the DC Pumps
  ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}


Re: Reefology's code

Posted: Thu Jan 08, 2015 2:09 pm
by cosmith71
You mean the speed at which the pumps run? Some modes like Else do that automatically. Others, like gyre and sine, go up and down in a set pattern.

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:30 pm
by Reefology
awesome thank you, the notes are a huge help to me. I'll check out the link as well.

cheers

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:41 pm
by Reefology
its still stuck in else mode and doesnt change?!

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:44 pm
by cosmith71
Do you have the portal set to custom?

Re: Reefology's code

Posted: Thu Jan 08, 2015 2:49 pm
by Reefology
not sure, here is all my code:

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 = Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | 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( Port8 );

    ////// Place additional initialization code below here
    
    // Password Protection username:xxxxxxx password:xxxxxxx
    // ReefAngel.Network.WifiAuthentication("xxxxxx,xxxxxxx"); 

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

void loop()
{
    ReefAngel.DosingPumpRepeat1( Port1 );
    ReefAngel.DosingPumpRepeat2( Port2 );
    ReefAngel.ActinicLights( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.MoonLights( Port5 );
    ReefAngel.WavemakerRandom( Port6,120,1500 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = None;
    ReefAngel.DCPump.ActinicChannel = Sync;
    
    ////// Place your custom code below here
    
    static int rmode;
    static boolean changeMode=true;


    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre };

    if (now()%600==0 || changeMode==true) { // Change every 10 mins or if controller rebooted
    rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3600) {
    // Continue NTM for the 60 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Sine;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }

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

    // This should always be the last line
    ReefAngel.Portal( "Reefology" );
    ReefAngel.DDNS( "xxxxxxxx" ); // Your DDNS is Reefology-xxxxxxxx.myreefangel.com
    ReefAngel.ShowInterface();
}

Re: Reefology's code

Posted: Thu Jan 08, 2015 3:35 pm
by Reefology
ok found custom in the portal. but now im wondering what the speed and duration does? doesnt ''custom'' call the code in the custom area thereby overriding speed and duration? asking because now that ive managed to get the modes to changing every 10 minutes, the speed stays the same?

Re: Reefology's code

Posted: Thu Jan 08, 2015 3:56 pm
by lnevo
Speed and duration are pulled from the portal. The speed will report in that section as static but you should see the speed change on the screen.

Re: Reefology's code

Posted: Thu Jan 08, 2015 7:56 pm
by Reefology
this is awesome, im in love with my reef angel and what it is capable of...

now that i have my dc pump up and running, I'm going back to something i put on hold, can someone please look at the code i just put up and tell me why i still cant log into the iphone app using my DDNS?

Thanks

Re: Reefology's code

Posted: Thu Jan 08, 2015 10:15 pm
by rimai
Make sure you enter reefology-ddns.myreefangel.com
Change the ddns to whatever you choose. Make sure it is - and not _

Re: Reefology's code

Posted: Fri Jan 09, 2015 10:11 pm
by Reefology
Thanks Roberto but I've checked it too many times to count. Are there other possibilities?

Re: Reefology's code

Posted: Fri Jan 09, 2015 10:51 pm
by rimai
PM me what you are entering. I checked the server and the entries are all there.
I saw 3 entries for you, but they were all same ip address.

Re: Reefology's code

Posted: Sun Jan 11, 2015 8:44 pm
by Reefology
pm sent

Re: Reefology's code

Posted: Sun Feb 08, 2015 6:15 pm
by Reefology
current code

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 = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | 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

    ////// Place additional initialization code below here
    
    // Password Protection username:xxxx password:xxxx
    // ReefAngel.Network.WifiAuthentication("xxxx"); 

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

void loop()
{
    ReefAngel.DosingPumpRepeat1( Port1 );
    ReefAngel.MoonLights( Port2 );
    ReefAngel.ActinicLights( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,120,1500 );
    ReefAngel.WavemakerRandom2( Port6,180,1000 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.DosingPumpRepeat2( Port8 );
    ReefAngel.DCPump.ActinicChannel = AntiSync; // Now pump will be affected by the portal settings
    // Comment out next 2 lines for single dc pump
    // ReefAngel.DCPump.DaylightChannel = Sync; // Now pump will be affected by the portal settings
    // ReefAngel.DCPump.AntiSyncOffset=100; 
    
    ////// Place your custom code below here
    
  // Wavemaker Koralia night mode
    if (hour()>=22 || hour()<7) ReefAngel.Relay.Off (Port5 );
    if (hour()>=23 || hour()<8) ReefAngel.Relay.Off (Port6 );
   
  // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3000) {
    // Continue NutrientTranspot Mode for 45 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }

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

    // This should always be the last line
    ReefAngel.Portal( "Reefology" );
    ReefAngel.DDNS("xxxx"); // Your DDNS is Reefology-xxxx.myreefangel.com
    ReefAngel.ShowInterface();
}

Have another dc pump coming and just want to makes sure i'm ready with code.

Re: Reefology's code

Posted: Sun Feb 08, 2015 6:17 pm
by Reefology
// Comment out next 2 lines for single dc pump
// ReefAngel.DCPump.DaylightChannel = Sync; // Now pump will be affected by the portal settings
// ReefAngel.DCPump.AntiSyncOffset=100;

do i just change this?

Re: Reefology's code

Posted: Sun Feb 08, 2015 6:32 pm
by Reefology
and does the antisync offset delay 2nd pump by 100 seconds?

Re: Reefology's code

Posted: Sun Feb 08, 2015 7:09 pm
by lnevo
No, it allows the antisync channel to be 100% of what it should be. If you have a strong or weaker pump, you could adjust that pump to compensate.

Re: Reefology's code

Posted: Sun Feb 08, 2015 9:52 pm
by Reefology
sorry, i don't understand.

so if i have a Jebao wp40 and a wp25, how would i use the offset?

Thanks