Here is what I am wanting to do:
1) If port8 (ATO pump) is on for longer than 3 minutes, I want to turn off port8 and send an email alert. (Either my ATO float is stuck, or ATO reservoir is low) //avoid system over fill
2) If HighATO is inactive for longer than 5 minutes, I want an alert email sent. (ATO pump failure, major system leak, ato reservoir low) //avoid system low volume
3) I would like to incorporate automatic monthly temperature adjustments similar to what "hedrickms" put together. I tried his code, and it wouldn't compile.
4) I would like my actinic lights to follow actual sunrise/sunset times with daylights coming on 2 hours later, and shutting off 2 hours before. Hopefully, within a year, I will upgrade my t5's to Radions, and get even more custom in the lighting area.
Thanks in advance for any assistance.
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
int avgph[10];
unsigned long totalavgph=0;
byte avgindex=0;
void DrawCustomMain()
{
byte x;
byte y = 2;
char text[7];
// *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
int TempColor; // Color for drawing temperature
boolean FanOn = ReefAngel.Relay.Status(Port5); // Get the status of the fan relay
boolean HeatOn = ReefAngel.Relay.Status(Port6); // Get the status of the heater relay
if (HeatOn)
{
TempColor = COLOR_NAVY; // Blue text, too cold, heater is on
}
if (FanOn)
{
TempColor = COLOR_RED; // Red text, too warm, fan is on
}
if (!HeatOn && !FanOn)
{
TempColor = COLOR_GREEN; // Green text, no fan or heater on
}
// ***********************************************************************************
int pHColor; // Color for drawing pH
boolean LowpH = (ReefAngel.Params.PH < 780) ; // Check for Low pH Value
boolean HighpH = (ReefAngel.Params.PH > 850); // Check for High pH Value
if (LowpH)
{
pHColor = COLOR_NAVY; // Blue text, Low pH value
}
if (HighpH)
{
pHColor = COLOR_RED; // Red text, High pH value
}
if (!LowpH && !HighpH)
{
pHColor = COLOR_GREEN; // Green text, pH acceptable
}
// ***********************************************************************************
ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,DefaultBGColor, 6, 3, "Thunder Reef",Font8x8); // Put a banner at the top
ReefAngel.LCD.DrawDate(6, 119); // Put the date and time at the bottom
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 12, 132, 12); // Draw a cyan line under the banner
x = 6;
y += MENU_START_ROW*1.4; // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
ReefAngel.LCD.DrawLargeText(COLOR_BLUE, COLOR_WHITE, x, y+1, " Temp pH");
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10); // Get T1 temp and convert
x = 2;
y += MENU_START_ROW*1.6;
ReefAngel.LCD.DrawHugeNumbers(COLOR_BLACK, TempColor, x, y, text); // Draw the temperature, white numbers on a colored background
ConvertNumToString(text, ReefAngel.Params.PH, 100); // Get pH reading and convert
x = 2;
y = MENU_START_ROW*2.6;
ReefAngel.LCD.DrawHugeNumbers(COLOR_YELLOW, pHColor, x+65, y+6, text); // Put pH on the screen
x += 6;
y += MENU_START_ROW*3.3;
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Sump Level",Font8x8); // Draw the Sump Float switch status
if (ReefAngel.HighATO.IsActive()) {
ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
} else {
ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
}
x += 6;
y += MENU_START_ROW*2.0;
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Skimmer Cup",Font8x8); // Draw the Skimmer Cup Float switch status
if (ReefAngel.LowATO.IsActive()) {
ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
} else {
ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
}
byte TempRelay = ReefAngel.Relay.RelayData; // Code for drawing the relay box
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);
}
void DrawCustomGraph()
{
}
////// 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 = Port7Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 830 );
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
ReefAngel.CustomLabels[0]="Return";
ReefAngel.CustomLabels[1]="Daylights";
ReefAngel.CustomLabels[2]="Actinics";
ReefAngel.CustomLabels[3]="Fuge Light";
ReefAngel.CustomLabels[4]="Sump Fan";
ReefAngel.CustomLabels[5]="Heater";
ReefAngel.CustomLabels[6]="Skimmer";
ReefAngel.CustomLabels[7]="ATO";
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Port2,10,0,18,0 ); // Daytime bulbs 10:00 am - 6:00 pm
ReefAngel.StandardLights( Port3,8,0,20,0 ); // Actinic bulbs 8:00 am - 8:00 pm
ReefAngel.StandardLights( Port4,17,30,10,30 ); // Refugium light 5:30 pm - 10:30 am
ReefAngel.StandardFan( Port5,785,787 );
ReefAngel.StandardHeater( Port6,783,785 );
////// Place your custom code below here
if (hour()>=9 && hour()<11)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,55,10,true) ); // Long pulse at 55% with 10s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,55,10,false) ); // Long pulse at 55% with 10s pulse on Anti-sync mode
}
else if (hour()>=11 && hour()<12)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,60,5,true) ); // Long pulse at 60% with 5s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,60,5,false) ); // Long pulse at 60% with 5s pulse on Anti-sync mode
}
else if (hour()>=12 && hour()<13)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,65,2,true) ); // Long pulse at 65% with 2s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,65,2,false) ); // Long pulse at 65% with 2s pulse on Anti-sync mode
}
else if (hour()>=13 && hour()<14)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,71,680,true) ); // Short pulse at 71% with 680ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,71,680,false) ); // Short pulse at 71% with 680ms pulse on Anti-sync mode
}
else if (hour()>=14 && hour()<15)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,78,680,true) ); // Short pulse at 78% with 680ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,78,680,false) ); // Short pulse at 78% with 680ms pulse on Anti-sync mode
}
else if (hour()>=15 && hour()<16)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,87,680,true) ); // Short pulse at 87% with 680ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,87,680,false) ); // Short pulse at 87% with 680ms pulse on Anti-sync mode
}
else if (hour()>=16 && hour()<17)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,78,680,true) ); // Short pulse at 78% with 680ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,78,680,false) ); // Short pulse at 78% with 680ms pulse on Anti-sync mode
}
else if (hour()>=17 && hour()<18)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,71,680,true) ); // Short pulse at 71% with 680ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,71,680,false) ); // Short pulse at 71% with 680ms pulse on Anti-sync mode
}
else if (hour()>=18 && hour()<19)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,65,2,true) ); // Long pulse at 65% with 2s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,65,2,false) ); // Long pulse at 65% with 2s pulse on Anti-sync mode
}
else if (hour()>=19 && hour()<20)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,60,5,true) ); // Long pulse at 60% with 5s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,60,5,false) ); // Long pulse at 60% with 5s pulse on Anti-sync mode
}
else if (hour()>=20 && hour()<21)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,55,10,true) ); // Long pulse at 55% with 10s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,55,10,false) ); // Long pulse at 55% with 10s pulse on Anti-sync mode
}
else
{
ReefAngel.PWM.SetDaylight( ReefCrestMode(40,10,true) ); // reefcrest at 40% +/- 10% on sync mode (night mode)
ReefAngel.PWM.SetActinic( ReefCrestMode(40,10,true) ); // reefcrest at 40% +/- 10% on sync mode (night mode)
}
if( ReefAngel.DisplayedMenu==FEEDING_MODE )
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
if(ReefAngel.LowATO.IsActive()) // Float switch in Skimmer Cup
{
ReefAngel.Relay.On(Port7);
}
else
{
ReefAngel.Relay.Off(Port7); // Turn off Skimmer when Cup full.
}
if(ReefAngel.HighATO.IsActive()) // Float switch in Sump
{
ReefAngel.Relay.Off(Port8);
}
else
{
ReefAngel.Relay.On(Port8); // Turn on ATO when sump level drops.
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "DmnYnkee" );
ReefAngel.ShowInterface();
}