Spotted's Code

Share you PDE file with our community

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Mon Feb 29, 2016 8:25 am
So here's my code. I have in here scheduled times for activating feed mode at 2 different times a day. It coincides with an automatic feeder that I've got. I haven't yet modified the auto feeder to be run by my Reef Angel, but that is in future plans. The timer on the auto feeder is not as accurate as the Reef Angel, so having my controller run it will be awesome!!
I have code in here to refill my ATO reservoir every 3 days for 2 hours (many thanks to lnevo for the help).
I really am just throwing this up here to help with BACKUP!! I lost a previous version of my code when a hard drive crashed on my back drive (ironic) :oops: .
I also want to thank everyone who has helped me develop this code. Not being a coder, this forum has greatly helped me in the care of my beloved fish. Thank you so very much!!
So here it is:
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

////// 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 = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed

    // Ports that are always on
    ReefAngel.Relay.On( Port3 ); //Sump Powerhead. Main Relay Port 3
    ReefAngel.Relay.On( Port4 );//Display Lights
    ReefAngel.Relay.On( Port5 ); //Display Tank Power Heads MaiRelay Port 5
    ReefAngel.Relay.On( Port8 ); //Return Pump Relay 1 Port 8
    ReefAngel.Relay.On( Box1_Port1 ); //ATS Air Pump. Relay 2 Port 1
    ReefAngel.Relay.On( Box1_Port2 ); //Media Reactor. Relay 2 Port 2
    ReefAngel.Relay.On( Box1_Port3 ); //Aqualifter. Relay 2 Port 3
    ReefAngel.Relay.Off( Box2_Port8 );//Referencing Relay 3
    ////// Place additional initialization code below here

    ////// Place additional initialization code above here

void loop()
    ReefAngel.SingleATOLow( Port1 );
    ReefAngel.Relay.DelayedOn( Port7 ); //Skimmer Relay 1 Port 7
    ReefAngel.MHLights( Box1_Port4 ); //ATS Light Relay 2 Port 4
    ReefAngel.DCPump.UseMemory = true; //ignore programming and use memory locations
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if ((now()%SECS_PER_DAY==31320)) //if it is 8:42 AM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE
    if ((now()%SECS_PER_DAY==67320)) //if it is 6:42 PM
    {ReefAngel.FeedingModeStart();} //START FEEDING MODE
    if (hour()>=22 || hour()<9)
    { // Sleep mode - slow things down
    ReefAngel.DCPump.SetMode( ReefCrest,25,10 );
    // Normal power
    ReefAngel.DCPump.SetMode( ReefCrest,50,10 );
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "spotted" );
    ReefAngel.DDNS( "" ); // Your DDNS is
// Set this to the port your solenoid is on.
#define ROSolenoid Box2_Port1

void RefillATO() {
  static boolean refillActive=false; // Flag to determine if we've initiated the refill.
  static time_t startedAt=0;
  byte startAt=23;
  byte runFor=2;
  byte runEvery=3;
  if ( now()+(startAt*SECS_PER_HOUR) % (runEvery*SECS_PER_DAY)==0 ) {
    ReefAngel.Relay.Override(ROSolenoid,1); // We turn on the solenoid port.
  if ( now()-startedAt == runFor*SECS_PER_HOUR && refillActive) {
    ReefAngel.Relay.Override(ROSolenoid,0); // Back to automatic mode

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest