Page 1 of 1

Jebao Custom programming help

Posted: Tue Feb 28, 2017 11:54 am
by GugsJr
I need help programming my Jebaos. I have 3 and currently I have them on reefcrest mode.

I need help adding the following:

1. Turning off the Jeabos on Dimming Channel 0 and Channel 2 during feed mode
2. Jeabo on Dimming channel 1 to go into nutrient transport mode
3. I want each Jeabo to randomly select a different mode randomly every hour from 3pm to Midnight with random times where they aren't running for about 10 minutes.
4. The Jebaos from Midnight - 3pm to go to 10% and randomly turn off for 5 minutes

Below is my current code. I have it in the memory so I can change things from my phone. I only have a few items that I changed because I wanted my moonlights to only be on until 3am. Not opposite of the of the daylights. Also I wanted my fans to turn on a bit before my lights and after the moonlights.

Thank you



#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 = 0;
ReefAngel.FeedingModePortsE[0] = Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit;
ReefAngel.WaterChangePortsE[0] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit;
// 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( Port6 );
ReefAngel.Relay.On( Box1_Port1 );
ReefAngel.Relay.On( Box1_Port2 );
ReefAngel.Relay.On( Box1_Port8 );

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


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

void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.StandardLights( Port3,23,55,3,0 );
ReefAngel.StandardHeater( Port4 );
ReefAngel.StandardLights( Port7,14,55,3,0 );
ReefAngel.StandardHeater( Box1_Port3 );
ReefAngel.StandardHeater( Box1_Port5 );
ReefAngel.StandardATO( Box1_Port6 );
ReefAngel.MoonLights( Box1_Port7 );
ReefAngel.PWM.DaylightPWMParabola();
ReefAngel.PWM.ActinicPWMParabola();
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = None;
ReefAngel.DCPump.ExpansionChannel[0] = Sync;
ReefAngel.DCPump.ExpansionChannel[1] = Sync;
ReefAngel.DCPump.ExpansionChannel[2] = AntiSync;
ReefAngel.DCPump.ExpansionChannel[3] = None;
ReefAngel.DCPump.ExpansionChannel[4] = None;
ReefAngel.DCPump.ExpansionChannel[5] = None;
////// Place your custom code below here


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

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

Re: Jebao Custom programming help

Posted: Thu Mar 02, 2017 9:28 am
by GugsJr
Is what I'm trying to do possible?

Re: Jebao Custom programming help

Posted: Thu Mar 02, 2017 10:00 am
by rimai
Aren't they going to 0 on feeding mode already?
This is supposed to turn them to 0:

Code: Select all

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

Re: Jebao Custom programming help

Posted: Thu Mar 02, 2017 11:35 am
by GugsJr
Rimai, They do. But I want one of them to stay on. The one on dimming port 1 to go into nutrient transport mode.

I'm also trying to get each to do a different mode every hour for a certain time. With brief periods of turning off.

Re: Jebao Custom programming help

Posted: Thu Mar 02, 2017 9:56 pm
by rimai
Start with this on loop() section.
I used this code, with different modes though.

Code: Select all

  if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
  {
    if (hour()>=15 && hour()<=18)
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.DCPump.SetMode(ShortWave,100,50 );
    }
    else if (hour()>=22 || hour()<=7)
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.DCPump.SetMode(ShortWave,100,50 );
    }
    else
    {
      ReefAngel.DCPump.UseMemory = true;
    }
  }
  else
  {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.DCPump.SetMode(NutrientTransport,100,50 );
  }

Re: Jebao Custom programming help

Posted: Fri Mar 03, 2017 12:23 pm
by GugsJr
Thank you for that can you explain this line please. I'm trying to learn how to code in here. I know if and then statements for general coding but trying to learn the language in reef angel.

else if (hour()>=22 || hour()<=7)

Re: Jebao Custom programming help

Posted: Fri Mar 03, 2017 12:42 pm
by GugsJr
This is what I came up with not sure if it will work.


#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 = 0;
ReefAngel.FeedingModePortsE[0] = Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit;
ReefAngel.WaterChangePortsE[0] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit;
// 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( Port6 );
ReefAngel.Relay.On( Box1_Port1 );
ReefAngel.Relay.On( Box1_Port2 );
ReefAngel.Relay.On( Box1_Port8 );

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


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

void loop()
if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
{
if (hour()>=15 && hour()<=18)
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(ShortWave,100,50 );
}
else if (hour()>=22 || hour()<=7)
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(ShortWave,100,50 );
}
else
{
ReefAngel.DCPump.UseMemory = true;
}
}
else
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(NutrientTransport,100,50 );
}

{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.StandardLights( Port3,23,55,3,0 );
ReefAngel.StandardHeater( Port4 );
ReefAngel.StandardLights( Port7,14,55,3,0 );
ReefAngel.StandardHeater( Box1_Port3 );
ReefAngel.StandardHeater( Box1_Port5 );
ReefAngel.StandardATO( Box1_Port6 );
ReefAngel.MoonLights( Box1_Port7 );
ReefAngel.PWM.DaylightPWMParabola();
ReefAngel.PWM.ActinicPWMParabola();
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = None;
ReefAngel.DCPump.ExpansionChannel[0] = Sync;
ReefAngel.DCPump.ExpansionChannel[1] = Sync;
ReefAngel.DCPump.ExpansionChannel[2] = AntiSync;
ReefAngel.DCPump.ExpansionChannel[3] = None;
ReefAngel.DCPump.ExpansionChannel[4] = None;
ReefAngel.DCPump.ExpansionChannel[5] = None;
////// 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, LongPulse, Else, Gyre };

if (now()%3600==0 || changeMode==true) { // Change at midnight 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 5%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Speed=20;
} 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

Re: Jebao Custom programming help

Posted: Fri Mar 03, 2017 4:48 pm
by rimai
You added more stuff to your code than what I gave you.
One may override the other.
else if (hour()>=22 || hour()<=7) means if the first condition is not true, then it will check if hour is greater than or equal to 22 hours (10pm) or hour is less than or equal to 7 hours.

Re: Jebao Custom programming help

Posted: Fri Mar 03, 2017 7:57 pm
by GugsJr
That's what I thought. I need to weed through it some more.

Re: Jebao Custom programming help

Posted: Fri Mar 03, 2017 9:06 pm
by GugsJr
So the longer version I came up with didn't work the way I thought.

Then I tried the one below and it didn't work either. All the pumps went off, the one I wanted to wouldn't stay on. I hate to bother you with this. Is there a tutorial for programming?

#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 = 0;
ReefAngel.FeedingModePortsE[0] = Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit;
ReefAngel.WaterChangePortsE[0] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit;
// 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( Port6 );
ReefAngel.Relay.On( Box1_Port1 );
ReefAngel.Relay.On( Box1_Port2 );
ReefAngel.Relay.On( Box1_Port8 );

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


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

void loop()
{
if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
{
if (hour()>=15 && hour()<=18)
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(ShortWave,100,50 );
}
else if (hour()>=22 || hour()<=7)
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(ShortWave,100,50 );
}
else
{
ReefAngel.DCPump.UseMemory = true;
}
}
else
{
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(NutrientTransport,100,50 );
}
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.StandardLights( Port3,23,55,3,0 );
ReefAngel.StandardHeater( Port4 );
ReefAngel.StandardLights( Port7,14,55,3,0 );
ReefAngel.StandardHeater( Box1_Port3 );
ReefAngel.StandardHeater( Box1_Port5 );
ReefAngel.StandardATO( Box1_Port6 );
ReefAngel.MoonLights( Box1_Port7 );
ReefAngel.PWM.DaylightPWMParabola();
ReefAngel.PWM.ActinicPWMParabola();
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = None;
ReefAngel.DCPump.ExpansionChannel[0] = Sync;
ReefAngel.DCPump.ExpansionChannel[1] = Sync;
ReefAngel.DCPump.ExpansionChannel[2] = AntiSync;
ReefAngel.DCPump.ExpansionChannel[3] = None;
ReefAngel.DCPump.ExpansionChannel[4] = None;
ReefAngel.DCPump.ExpansionChannel[5] = None;
////// Place your custom code below here


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

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