I feel like I must have forgotten something important because I can't control any outlets with the portal and anything set to Auto but that isn't specified in the "Setup" statement to be "On" isn't working.
Also, the Status light flashes about once per second. It's almost like the loop() is crashing each time through.
Can someone take a look and see if they can spot what is going on? Note: I changed password and ddns
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
unsigned long offtime = 0UL;
unsigned long alktime = 0UL;
////// 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 | Port7Bit | Port8Bit; // skimmer, return, center vortech
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port3Bit; // UV, outside vortechs
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit | Port7Bit; // skimmer, return
ReefAngel.WaterChangePortsE[0] = Port2Bit; // UV
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port5Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Add support for 16 channel PWM board
ReefAngel.Add16ChPWM();
// Add support for pH expansion
ReefAngel.AddPHExpansion();
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port5 ); //Lights (controlled by timer inside lights)
ReefAngel.Relay.On( Port6 ); // skimmer
ReefAngel.Relay.On( Port7 ); // return
ReefAngel.Relay.On( Port8 ); // center powerhead
ReefAngel.Relay.On( Box1_Port2 ); //UV
ReefAngel.Relay.On( Box1_Port3 ); //outside powerheads
ReefAngel.Relay.On( Box1_Port7 ); //reactor pump
////// Place additional initialization code below here
//Custom Port Labels
ReefAngel.CustomLabels[0] = "Heater"; // Port1
ReefAngel.CustomLabels[1] = "Alkdoser"; // Port2
ReefAngel.CustomLabels[2] = "Caldoser"; // Port3
ReefAngel.CustomLabels[3] = "Magdoser"; // Port4
ReefAngel.CustomLabels[4] = "Lights"; // Port5
ReefAngel.CustomLabels[5] = "Skimmer"; // Port6
ReefAngel.CustomLabels[6] = "Return"; // Port7
ReefAngel.CustomLabels[7] = "CenterV"; // Port8 will stay on via UPS when power is out
ReefAngel.CustomLabels[8] = "Swabbie"; // Box1_Port1
ReefAngel.CustomLabels[9] = "UV"; // Box1_Port2
ReefAngel.CustomLabels[10] = "OutsideV"; // Box1_Port3
ReefAngel.CustomLabels[11] = "Kalkdoser"; // Box1_Port4
ReefAngel.CustomLabels[12] = "AutoFeeder"; // Box1_Port5
ReefAngel.CustomLabels[13] = "WaterChange"; // Box1_Port6
ReefAngel.CustomLabels[14] = "Reactor"; // Box1_Port7
ReefAngel.CustomLabels[15] = "FugeLight"; // Box1_Port8
// so portal always shows custom variables
ReefAngel.CustomVar[7] = 255;
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater(Port1); // using internal memory
if (ReefAngel.Params.PHExp > 840) { // second pH probe is in tank for now so also have it turn off alk and kalk doser
ReefAngel.Relay.Off(Port2); // turn off alk doser
ReefAngel.Relay.Off(Box1_Port4); // turn off kalk doser
}
if (ReefAngel.Params.PH < 840) {
ReefAngel.DosingPumpRepeat1( Port2 ); // alk doser
adjustAlk();
} else {
ReefAngel.Relay.Off(Port2); // safety to turn it off if the pH is too high
ReefAngel.Relay.Off(Box1_Port4);
}
ReefAngel.DosingPumpRepeat2( Port3 ); // cal doser
ReefAngel.DosingPumpRepeat3( Port4 ); // mag doser
ReefAngel.StandardLights( Box1_Port1, 9, 0, 9, 5 ); // swabbie, comes on for 5 minutes each morning
if ((hour() >= 21) || (hour() < 7)) { // run fuge light on reverse photo cycle of main lights
ReefAngel.Relay.On(Box1_Port8);
} else {
ReefAngel.Relay.Off(Box1_Port8);
}
if (((hour() == 10) || (hour() == 14) || (hour() == 18) || (hour() == 22)) && (minute() < 1)) { // run autofeeder for 1 minute at 10,2,6,10
ReefAngel.Relay.On(Box1_Port5);
} else {
ReefAngel.Relay.Off(Box1_Port5);
}
// lights for invert frag system
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(2,0,InternalMemory.PWMSlopeEnd0_read()); // Violet channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(3,0,InternalMemory.PWMSlopeEnd1_read()); // Royal Blue channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(4,0,InternalMemory.PWMSlopeEnd2_read()); // White channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(5,0,InternalMemory.PWMSlopeEnd3_read()); // Cool Blue channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(6,0,InternalMemory.PWMSlopeEnd4_read(),-60,-60); // Deep Red channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(7,0,InternalMemory.PWMSlopeEnd5_read(),-60,-60); // Cyan channel, startpwm, endpwm, offsets
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(8,0,85); // Fan channel, silent up to 75 or so.
// Turn off Skimmer if Locker is full
if (ReefAngel.HighATO.IsActive())
{
ReefAngel.Relay.On(Port6);
} else {
ReefAngel.Relay.Off(Port6);
}
// Turn off things if the power goes out
if (ReefAngel.LowATO.IsActive())
{ // then power is on
if (offtime > 0) { // then power was off
ReefAngel.Relay.On(Port6); // turn on skimmer
ReefAngel.Relay.On(Port7); // turn on return
offtime = 0UL;
}
} else { // then power is off
// turn off lights, skimmer, return pump after 60 seconds, to conserve UPS power for powerheads
if (offtime == 0) offtime = now();
if ((now() - offtime) > 60) { // it has been off for 60 seconds
ReefAngel.Relay.Off(Port1); // turn off heater
ReefAngel.Relay.Off(Port2); // turn off alkdoser
ReefAngel.Relay.Off(Port3); // turn off caldoser
ReefAngel.Relay.Off(Port4); // turn off magdoser
ReefAngel.Relay.Off(Port5); // turn off Lights
ReefAngel.Relay.Off(Port6); // turn off skimmer
ReefAngel.Relay.Off(Port7); // turn off return pump
// no need to turn off ports on second power box because it isn't on UPS
ReefAngel.Relay.On(Port8); // keep on center Vortech
}
}
// This should always be the last line
ReefAngel.Portal( "AlanM", "MyPassword" );
ReefAngel.DDNS( "myddns" ); // Your DDNS is AlanM-myddns.myreefangel.com
ReefAngel.ShowInterface();
}
void adjustAlk() {
// check to see if extra alk or less alk was requested
// CustomVar is the value read on the checker
if (ReefAngel.CustomVar[2] > 0) {
int alkneeded = 150 - ReefAngel.CustomVar[2];
float alkAdjust = 0;
if (alkneeded != 0) {
alkAdjust = 5.71 * (float)alkneeded; // alkAdjust is minutes to run or pause, for 190 gallons volume, 1ppm is 7.6ml for carbonate and 1.33ml/min, so 5.71 minutes per ppm of alk. in carbonate
// if adding in bicarbonate double that amount
} else {
ReefAngel.CustomVar[2] = 0; // else it must be 0 so reset and do nothing.
alktime = 0;
return;
}
if (alktime == 0) { // it must have just gotten noticed, set the alktime global and initial port status
if (alkAdjust > 0) {
alktime = now() + (alkAdjust * 60UL); // should get rounded to integer seconds here
ReefAngel.Relay.On(Port2); // set it to on
} else {
alktime = now() - (alkAdjust * 60UL); // should get rounded to integer seconds here
ReefAngel.Relay.Off(Port2); // set it to off
}
}
else if (now() > alktime) {
//ReefAngel.Relay.Override(Port2,2); // set it back to auto, clear the override
ReefAngel.Relay.Off(Port2); // turn it off, the default
ReefAngel.CustomVar[2] = 0; // clear the custom variable
alktime = 0; // set alktime back to 0
} else { // must be less than alktime, so keep it on or off depending on if you need to add or subtract alk
if (alkAdjust > 0) {
ReefAngel.Relay.On(Port2);
}
else if (alkAdjust < 0) {
ReefAngel.Relay.Off(Port2);
}
}
}
else {
return;
}
}