Page 1 of 1

controlling Jebao from portal

Posted: Thu Nov 27, 2014 3:20 pm
by psyrob
I am trying to set up controlling my jebao wp25 from the portal and it is not working. I want to be able to change the pump setting from the portal during the day and then have it be steady sine mode during the night. when I upload this, I can't change anything during the day from the portal, when I try and change modes, else mode stays on.
Any ideas? Thanks and Happy Thanksgiving...

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

    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Frag Pump";  
    ReefAngel.CustomLabels[1]="Actinics";  
    ReefAngel.CustomLabels[2]="Daylights";  
    ReefAngel.CustomLabels[3]="Frag LED";  
    ReefAngel.CustomLabels[4]="ATO Pump";  
    ReefAngel.CustomLabels[5]="Reactor";  
    ReefAngel.CustomLabels[6]="Heater";  
    ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.ActinicLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.SingleATOLow( Port5 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    ReefAngel.DCPump.UseMemory = true;
   
 
       if (hour()>=8 && hour()<21)
   
     {
             ReefAngel.PWM.SetDaylight(0);
        if (ReefAngel.DCPump.Mode==Custom)
          {
         ReefAngel.PWM.SetActinic(ElseMode(65, 20, true));
         
            ReefAngel.DCPump.UseMemory = false;
          } 
          
          else
            {
            ReefAngel.DCPump.UseMemory = true;
            }
      }
           
          else 
         {
         ReefAngel.PWM.SetActinic(SineMode(75,35, 15, true));
         }
           
    
  
    ////// Place your custom code below here
    

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

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

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 1500);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}


Re: controlling Jebao from portal

Posted: Thu Nov 27, 2014 6:08 pm
by cosmith71
OK, so you want Portal control from 8 AM to 8 PM, with "Custom" being Else mode, and then Sine after 8 PM?

Re: controlling Jebao from portal

Posted: Thu Nov 27, 2014 6:21 pm
by cosmith71
Try this:

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

  ////// Place additional initialization code below here
  ReefAngel.CustomLabels[0]="Frag Pump";  
  ReefAngel.CustomLabels[1]="Actinics";  
  ReefAngel.CustomLabels[2]="Daylights";  
  ReefAngel.CustomLabels[3]="Frag LED";  
  ReefAngel.CustomLabels[4]="ATO Pump";  
  ReefAngel.CustomLabels[5]="Reactor";  
  ReefAngel.CustomLabels[6]="Heater";  
  ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
  ReefAngel.ActinicLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.ActinicLights( Port4 );
  ReefAngel.SingleATOLow( Port5 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );

  ReefAngel.PWM.SetActinic(SineMode(75,35,15,true));    // This will run unless something changes it

  if (hour()>=8 && hour()<21)    //runs from 8 am to 2000 (8 PM)
  {
    ReefAngel.DCPump.UseMemory = true;

    if (ReefAngel.DCPump.Mode == Custom)
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.PWM.SetActinic(ElseMode(65,20,true));
    }
  }



  ////// Place your custom code below here


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

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

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 1500);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}

--Colin

Re: controlling Jebao from portal

Posted: Fri Nov 28, 2014 3:42 pm
by psyrob
Thanks: I uploaded this new code, but still can't change the pump from the portal. I switch to long pulse, for example, and it stays in custom, running else mode...

Re: controlling Jebao from portal

Posted: Fri Nov 28, 2014 4:05 pm
by psyrob
correction:
when I upload the code, it is in sine mode. I go to the portal or my ipad app, and if I change it to custom (which is else), I can't change it back to anything else...

Re: controlling Jebao from portal

Posted: Fri Nov 28, 2014 4:23 pm
by cosmith71
Huh.

Try this.

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

  ////// Place additional initialization code below here
  ReefAngel.CustomLabels[0]="Frag Pump";  
  ReefAngel.CustomLabels[1]="Actinics";  
  ReefAngel.CustomLabels[2]="Daylights";  
  ReefAngel.CustomLabels[3]="Frag LED";  
  ReefAngel.CustomLabels[4]="ATO Pump";  
  ReefAngel.CustomLabels[5]="Reactor";  
  ReefAngel.CustomLabels[6]="Heater";  
  ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
  ReefAngel.ActinicLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.ActinicLights( Port4 );
  ReefAngel.SingleATOLow( Port5 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );

  ReefAngel.DCPump.UseMemory = false;
  ReefAngel.PWM.SetActinic(SineMode(75,35,15,true));    // This will run unless something changes it

  if (hour()>=8 && hour()<21)    //runs from 8 am to 2000 (8 PM)
  {

    if (ReefAngel.DCPump.Mode == Custom)
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.PWM.SetActinic(ElseMode(65,20,true));
    }
    else ReefAngel.DCPump.UseMemory = true;
   }



  ////// Place your custom code below here


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

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

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 1500);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}
Edit: Made a minor fix.

Re: controlling Jebao from portal

Posted: Sun Nov 30, 2014 1:19 pm
by psyrob
Still cant control jebao pump from portal or ipad app. It stays on custom (else) no matter what I change it to...
I appreciate your help, tho...

Re: controlling Jebao from portal

Posted: Sun Nov 30, 2014 3:45 pm
by cosmith71
psyrob wrote:Still cant control jebao pump from portal or ipad app. It stays on custom (else) no matter what I change it to...
I appreciate your help, tho...
OK, this works (kind of). We forgot to set the sync channel to Actinic for the DC pumps.

The main problem is that when we use ReefAngel.SetActinic to set our pumps, it doesn't reflect on the pump section of the portal. It would be much better if you were using the dev libraries which has Else built in and selectable from the Portal.

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

  ////// Place additional initialization code below here
  ReefAngel.CustomLabels[0]="Frag Pump";  
  ReefAngel.CustomLabels[1]="Actinics";  
  ReefAngel.CustomLabels[2]="Daylights";  
  ReefAngel.CustomLabels[3]="Frag LED";  
  ReefAngel.CustomLabels[4]="ATO Pump";  
  ReefAngel.CustomLabels[5]="Reactor";  
  ReefAngel.CustomLabels[6]="Heater";  
  ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
  ReefAngel.ActinicLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.ActinicLights( Port4 );
  ReefAngel.SingleATOLow( Port5 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );


  ReefAngel.DCPump.ActinicChannel = Sync;
  ReefAngel.DCPump.UseMemory = false;
  ReefAngel.PWM.SetActinic(SineMode(75,35,15,true));    // This will run unless something changes it

  if (hour()>=8 && hour()<21)    //runs from 8 am to 2000 (8 PM)
  {

  if (InternalMemory.DCPumpMode_read()==11)   // Custom mode on Portal
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.PWM.SetActinic(ElseMode2(65,20,true));
    }
    else ReefAngel.DCPump.UseMemory = true;
   }



  ////// Place your custom code below here


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

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

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 1500);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}

Re: controlling Jebao from portal

Posted: Sun Nov 30, 2014 3:52 pm
by cosmith71
With the new libraries it would be this:

Code: Select all

ReefAngel.DCPump.ActinicChannel = Sync;
  ReefAngel.DCPump.UseMemory = false;
  ReefAngel.DCPump.SetMode(Sine,75,35,15);    // This will run unless something changes it

  if (hour()>=8 && hour()<21)    //runs from 8 am to 2000 (8 PM)
  {

  if (InternalMemory.DCPumpMode_read()==11)   // Custom mode on Portal
    {
      ReefAngel.DCPump.UseMemory = false;
      ReefAngel.DCPump.SetMode(Else,65,20);
    }
    else ReefAngel.DCPump.UseMemory = true;
   }

Re: controlling Jebao from portal

Posted: Sun Nov 30, 2014 7:55 pm
by psyrob
Ok, didn't realize else mode had been added to the libraries. I can update the libraries and change my code like you have here. So is custom mode not needed in my coding to do what I want? I want it to run else all day unless I change from the portal...
And thanks again :)

Re: controlling Jebao from portal

Posted: Mon Dec 01, 2014 4:05 am
by cosmith71
You're welcome! I enjoy these exercises. Makes me better. :geek:

--Colin