controlling Jebao from portal
Posted: Thu Nov 27, 2014 3:20 pm
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...
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;
}
}