Here's the code I just uploaded a few minutes ago. I heard the controller beep like it received the code. I'm still seeing the temp fluctuate on custom var 5.
Code: Select all
#include <Salinity.h>
#include <ReefAngel_Features.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
//*************************************************************
// Define relay box ports
// Relay Box #1
#define ControllerLight Box1_Port1
#define Skimmer Box1_Port2
#define SumpLight Box1_Port3
#define RedSea_Doser Box1_Port4
#define ReturnPump Box1_Port5
#define Heater Box1_Port6
#define RedSea_ATO Box1_Port7
#define Sump_PowerHead Box1_Port8
// Relay Box #2 - No longer working in code
// Relay Box #3
#define PowerHead1 Box3_Port1
#define T5_Actinic Box3_Port2
#define PowerHead2 Box3_Port3
#define Kessil_A Box3_Port4
#define Kessil_B Box3_Port5
#define Kessil_C Box3_Port6
#define Kessil_D Box3_Port7
#define Fans Box3_Port8
#define skimmate_locker 3
#define CUSTOM_VARIABLES
////// Place global variable code above here
byte DaylightOffset = InternalMemory.ActinicOffset_read();
int onTime = NumMins(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read())+DaylightOffset;
int offTime = NumMins(InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read())-DaylightOffset;
/*
2021-01-25 :: Testing using internal momory for lighting
*/
void setup() {
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Star();
ReefAngel.AddMultiChannelWaterLevelExpansion();
ReefAngel.AddExtraTempProbes();
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port5Bit;
ReefAngel.FeedingModePortsE[2] = Port1Bit | Port3Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port5Bit;
ReefAngel.WaterChangePortsE[2] = Port1Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPortsE[0] = Port6Bit;
ReefAngel.OverheatShutoffPortsE[2] = Port2Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit;
ReefAngel.LightsOnPortsE[2] = Port2Bit | Port4Bit | Port5Bit | 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);
// Ports that are always on
// Box 1
ReefAngel.Relay.On(RedSea_ATO);
ReefAngel.Relay.On(RedSea_Doser);
ReefAngel.Relay.On(Sump_PowerHead);
ReefAngel.Relay.On(ReturnPump);
// Box 3
ReefAngel.Relay.On(PowerHead1);
ReefAngel.Relay.On(PowerHead2);
// I/O Module Testing
//for (int IO_channel = 0; IO_channel < 6; IO_channel++) {
// ReefAngel.CustomVar[IO_channel] = ReefAngel.IO.GetChannel(IO_channel);
//}
ReefAngel.CustomVar[0] = InternalMemory.ActinicOffset_read();
ReefAngel.CustomVar[1] = InternalMemory.StdLightsOnHour_read();
ReefAngel.CustomVar[2] = InternalMemory.StdLightsOnMinute_read();
ReefAngel.CustomVar[3] = InternalMemory.StdLightsOffHour_read();
ReefAngel.CustomVar[4] = InternalMemory.StdLightsOffMinute_read();
ReefAngel.CustomVar[5] = 35;
}
void loop() {
ReefAngel.Relay.DelayedOn(Skimmer,5);
ReefAngel.StandardLights(T5_Actinic, DaylightOffset);
ReefAngel.StandardLights(Kessil_A);
ReefAngel.StandardLights(Kessil_B);
ReefAngel.StandardLights(Kessil_C, onTime/60, onTime%60, offTime/60, offTime%60);
ReefAngel.StandardLights(Kessil_D, onTime/60, onTime%60, offTime/60, offTime%60);
ReefAngel.StandardHeater(Heater);
//ReefAngel.DosingPumpRepeat1(CalDoser);
//ReefAngel.DosingPumpRepeat2(AlkDoser);
//ReefAngel.DosingPumpRepeat3(MagDoser);
ReefAngel.StandardFan(Fans);
if (!daylightsOn()) { // Night mode
ReefAngel.PWM.SetDaylight2(MoonPhase()/2);
ReefAngel.PWM.SetActinic2(MoonPhase()/2);
} else {
ReefAngel.PWM.SetDaylight2(10);
ReefAngel.PWM.SetActinic2(10);
}
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
if (ReefAngel.DisplayedMenu != FEEDING_MODE || ReefAngel.DisplayedMenu != WATERCHANGE_MODE) {
if (!daylightsOn()) { // Night mode - lower the flow
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode(ReefCrest,45,10);
}
//if (now()%SECS_PER_HOUR<10*SECS _PER_MINUTE) { //put ato code here } else { // put relay off here }
//else if (now()%(2*SECS_PER_HOUR)<(5*60*1000)) { // Run NutrientTransport mode every two hours for 5 minutes
// ReefAngel.DCPump.UseMemory = false;
// ReefAngel.DCPump.SetMode(NutrientTransport,90,30);
//}
else {
ReefAngel.DCPump.UseMemory = true;
}
}
boolean buzzer=false;
if (ReefAngel.isOverheat()) buzzer=true;
if (ReefAngel.isBusLock()) buzzer=true;
if (buzzer) ReefAngel.BuzzerOn(2); else ReefAngel.BuzzerOff();
// Lights under stand
if (!ReefAngel.IO.GetChannel(5)) {
ReefAngel.Relay.On(SumpLight);
} else {
ReefAngel.Relay.Off(SumpLight);
}
if (ReefAngel.IO.GetChannel(4)) {
ReefAngel.Relay.On(ControllerLight);
} else {
ReefAngel.Relay.Off(ControllerLight);
}
// Shut off the skimmer if the skimmate locker is full
if (ReefAngel.IO.GetChannel(3)) {
ReefAngel.Relay.On(Skimmer);
} else {
ReefAngel.Relay.Off(Skimmer);
}
// Feeding Mode Button
//if (!ReefAngel.IO.GetChannel(2) && ReefAngel.DisplayedMenu != FEEDING_MODE) {
// ReefAngel.FeedingModeStart();
//}
// If the feeding mode button is pressed:
ReefAngel.CustomVar[7] = ReefAngel.IO.GetChannel(2);
ReefAngel.CustomVar[6] = ReefAngel.DisplayedMenu;
if (!ReefAngel.IO.GetChannel(2) && ReefAngel.DisplayedMenu != FEEDING_MODE) {
ReefAngel.FeedingModeStart();
}
////// Place your custom code below here
////// Place your custom code above here
ReefAngel.Network.Cloud();
// This should always be the last line
ReefAngel.ShowTouchInterface();
}
// *****************************************************************************
// * Utility Functions
// *****************************************************************************
boolean lightsAreOn () {
return actinicsOn() || daylightsOn();
}
boolean actinicsOn () {
return ReefAngel.Relay.Status(T5_Actinic);
}
boolean daylightsOn () {
return ReefAngel.Relay.Status(Kessil_A);
}
// RA_STRING1=...
// RA_STRING2=null
// RA_STRING3=null