Code: Select all
#include <ReefAngel_Features.h>
#include <Salinity.h>
#include <Globals.h>
#include <RA_TS.h>
#include <RA_TouchLCD.h>
#include <RA_TFT.h>
#include <RA_TS.h>
#include <Font.h>
#include <RA_Wifi.h>
#include <RA_Wiznet5100.h>
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_ATO.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 <RA_CustomLabels.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <PAR.h>
#include <DCPump.h>
#include <ReefAngel.h>
#include <SoftwareSerial.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.Star();
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
ReefAngel.AddPHExpansion(); // pH Expansion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = Port7Bit | Port8Bit; //UV and UV Pump-off.
ReefAngel.FeedingModePortsE[1] = Port7Bit; //Skimmer-off.
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[1] = Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[2] = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.OverheatShutoffPortsE[1] = Port1Bit | Port3Bit | Port5Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[1] = Port1Bit; // Powermodule Fixture On.
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_read(); // trying this code to see if it pulls internal memory overheat temp.
// Ports that are always on
ReefAngel.Relay.On( Box1_Port3 ); // Gyres always on.
ReefAngel.Relay.On( Box1_Port8 ); // UV Pump always on.
ReefAngel.Relay.On( Box2_Port1 ); // Powermodule Lights/Fans always on.
ReefAngel.Relay.On( Box2_Port4 ); // Return Pump always on.
////// Place additional initialization code below here
InternalMemory.FeedingTimer_write(7200); // sets feeding mode to 2 hours (only used for coral feeding)... shuts down UV bulb, UV pump, and skimmer.
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Box2_Port3 ); //Using Internal Memory Standard Lights to run Refugium Light.
ReefAngel.StandardHeater2( Box1_Port2 );
ReefAngel.StandardHeater2( Box2_Port5 );
ReefAngel.StandardFan2( Box2_Port6 ); //Sump Fans
ReefAngel.Relay.DelayedOn( Box2_Port7 ); //Skimmer
ReefAngel.WaterLevelATO( 1,Box3_Port2 ); //ATO pump-DC relay box.
ReefAngel.StandardHeater( Box1_Port7,789,800 ); //Manages UV bulb on/off based on tank temp.
if (hour() <=12 || hour() >= 19 ) ReefAngel.DosingPumpRepeat1( Box3_Port1 ); // Run kalk stirrer dosing pump if <=12:00 pm OR >=7:00 pm.
//ReefAngel.DosingPumpRepeat1( Box3_Port1 ); // Pump dosing kalk-DC Relay Box.- old code.
ReefAngel.DosingPumpRepeat( Box1_Port4,20,30,900 ); // Stirrer on/off-- 20 min offset, starts every 30 minutes, 15 minute run time (60 seconds * 15 minutes = 900).
if ( ReefAngel.Params.PHExp >= 100 && ReefAngel.Params.PHExp<= 620 ) ReefAngel.Relay.Off( Box1_Port1 ); //*** This line must occur BEFORE the CO2Control line*** Keeps Failsafe to shut-off Carbondoser at low Ca reactor pH, while keeping Carbondoser 'on' in the event pH Expansion value is lost or crazy reading <= 1.00.
ReefAngel.CO2Control( Box1_Port1, InternalMemory.CO2ControlOff_read(), InternalMemory.CO2ControlOn_read(), true ); //Turns on/off Carbon Doser (CaR CO2 Doser) based on Internal Memory values using pH Expansion probe's readings.
ReefAngel.CO2Control( Box1_Port6,785,790 ); //FAILSAFE that turns off Ca Reactor Recirculation Pump (CaR Recirc Pump) if tank pH <= 7.85 and back on at 7.90. NOTE: THIS IS THE ONLY REFERENCE TO Box1_Port6 and can't be REM'd out without adding a line for Box1_Port6.
ReefAngel.CO2Control( Box2_Port8,785,790 ); //FAILSAFE that turns off Ca Reactor Fill Pump (CaR Fill Pump) if tank pH <= 7.85 and back on at 7.90. NOTE: THIS IS THE ONLY REFERENCE TO Box2_Port8 and can't be REM'd out without adding a line for Box2_Port8.
boolean buzzer=false;
// if ( ReefAngel.isATOTimeOut() ) buzzer=true;
if ( ReefAngel.isOverheat() ) buzzer=true;
if ( buzzer ) ReefAngel.BuzzerOn(2); else ReefAngel.BuzzerOff();
if ( ReefAngel.Params.PH > 851 ) ReefAngel.Relay.Off( Box3_Port1 ); //FAILSAFE that turns off Kalk Stirrer dosing if tank pH > 8.51.
//if ( hour(now()) >= 15 && hour(now()) <= 18 ) ReefAngel.Relay.Off( Box3_Port1 ); //Turns kalk stirrer off from 3:00 pm - 6:00 pm to help balance daily pH (prevent late afternoon pH spikes). - don't want to use.
//if ( hour(now()) >= 3 && hour(now()) <= 5 ) ReefAngel.Relay.Off( Box1_Port1 ); //Turns Carbondoser off from 3:00 am - 5:00 am to help balance daily alkalinity and to offset higher Ca reactor pH during daytime hours.
if ( ReefAngel.Params.PH < 790 ) ReefAngel.Relay.Off( Box1_Port1 ); //FAILSAFE that turns off Carbon Doser if tank pH < 7.90.
//if ( ReefAngel.WaterLevel.GetLevel(1) <= 63 ) ReefAngel.Relay.Off( Box1_Port1 ); //FAILSAFE that turns off Carbon Doser if sump water level <= 63.
//if ( ReefAngel.WaterLevel.GetLevel(1) <= 63 ) ReefAngel.Relay.Off( Box1_Port6 ); //FAILSAFE that turnsoff Ca Reactor Recirculation Pump if sump water level <= 63.
//if ( ReefAngel.WaterLevel.GetLevel(1) <= 63 ) ReefAngel.Relay.Off( Box2_Port8 ); //FAILSAFE that turnsoff Ca Reactor Fill Pump if sump water level <= 63.
////// Place your custom code below here
////// Place your custom code above here
ReefAngel.Network.Cloud();
// This should always be the last line
ReefAngel.ShowTouchInterface();
}
// RA_STRING1=U2FsdGVkX1+BrIhUnNJiKHbFL6wohK41+33EQ2nHfFo=
// RA_STRING2=U2FsdGVkX1+EmuJjuPrMWBEHac9zWSjiW8ZytHk/q+M=
// RA_STRING3=Chloe's House-2.4
// RA_LABEL LABEL_ACTINIC=Actinic
// RA_LABEL LABEL_DAYLIGHT=Daylight
// RA_LABEL LABEL_PORT11=Main LEDs
// RA_LABEL LABEL_PORT12=Heater 2
// RA_LABEL LABEL_PORT13=Gyre Pumps
// RA_LABEL LABEL_PORT14=Kalk Stirrer
// RA_LABEL LABEL_PORT15=Salt Mix Tank
// RA_LABEL LABEL_PORT16=Co2 Control
// RA_LABEL LABEL_PORT17=Unused
// RA_LABEL LABEL_PORT18=Unused
// RA_LABEL LABEL_PORT21=Main T5s
// RA_LABEL LABEL_PORT22=Light Fans
// RA_LABEL LABEL_PORT23=Refugium LED
// RA_LABEL LABEL_PORT24=Return Pump
// RA_LABEL LABEL_PORT25=Heater 1
// RA_LABEL LABEL_PORT26=Sump Fans
// RA_LABEL LABEL_PORT27=Skimmer
// RA_LABEL LABEL_PORT28=ATO Pump