ATO Reservoir refill every few days

Do you have a question on how to do something.
Ask in here.

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Wed Jun 21, 2017 12:38 pm
Ok, so after a really long trip out of town, I have returned!
It would appear that the code for the ATO reservoir refill does not function as hoped. Actually it does nothing. Can someone please take a look at it and tell me what needs to be done to fix it?
I really appreciate all your help on this.
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Wed Jun 21, 2017 4:34 pm
I think it would be easier to just do this:
Code: Select all
ReefAngel.Relay.Set(Port1,(now%129600)<10800));

I have not tested, but it may be worth a try.
129600=number of seconds in 3 days
10800=number of seconds in 3 hours
It will turn on for 10800 seconds every 129600 seconds.
It will always turn on starting at midnight.
Roberto.

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Thu Jun 22, 2017 4:05 pm
Ok, so remove this
Code: Select all
// Set this to the port your solenoid is on.
#define ROSolenoid Box2_Port6

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=6;
  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.
    startedAt=now();
    refillActive=true;
  }
 
  if ( now()-startedAt == runFor*SECS_PER_HOUR && refillActive) {
    ReefAngel.Relay.Override(ROSolenoid,0); // Back to automatic mode
    refillActive=true;
    startedAt=0;
  }


And make it look like this


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
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // 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
    ReefAngel.Relay.Set(Box1_Port6,(now%129600)<10800));
    ////// 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 = false; //ignore programming and use memory locations if true
    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( Lagoon,40,66 );
    }
    else
    {
    // Normal power
    ReefAngel.DCPump.SetMode( Constant,70,10 );
    }
    ////// Place your custom code above here
   
    // This should always be the last line
    ReefAngel.Portal( "spotted" );
    ReefAngel.DDNS( "7730.homeip.net:2000" ); // Your DDNS is spotted-7730.homeip.net:2000.myreefangel.com
    ReefAngel.ShowInterface();
}
// Set this to the port your solenoid is on.


and is that new code in the right place? The line right above

////// Place additional initialization code below here

Or should it go above this line:

////// Place your custom code above here
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Jun 22, 2017 5:23 pm
It has to be on loop section or it will only work at boot and never again.
setup() section only happens on boot and loop() section happens all the time.
Roberto.

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Mon Jun 26, 2017 9:35 am
Ok I tried this and got an error mesage. Here's the code and I hope it's in the correct place.
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
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // 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 = false; //ignore programming and use memory locations if true
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ReefAngel.Relay.Set(Box2_Port6,(now%129600)<10800));

    ////// 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( Lagoon,40,66 );
    }
    else
    {
    // Normal power
    ReefAngel.DCPump.SetMode( Constant,70,10 );
    }


    ////// Place your custom code above here
   
    // This should always be the last line
    ReefAngel.Portal( "spotted" );
    ReefAngel.DDNS( "7730.homeip.net:2000" ); // Your DDNS is spotted-7730.homeip.net:2000.myreefangel.com
    ReefAngel.ShowInterface();
}


Here's my error:

The following features were automatically added:
Watchdog Timer
Version Menu

The following features were detected:
Wifi Attachment
Relay Expansion Module
DC Pump Control (Jebao/Tunze)
Dimming Signal
2014 Main Screen
Extra Font - Medium Size (8x8 pixels)
Metal Halide Setup
Number of Relay Expansion Modules: 2
Simple Menu
sketch_jun26.cpp: In function 'void loop()':
sketch_jun26:87: error: invalid operands of types 'time_t ()()' and 'long int' to binary 'operator%'
sketch_jun26:87: error: expected `;' before ')' token




Help please!
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Jun 26, 2017 3:33 pm
Sorry, I forgot the parenthesis.
Try this:
Code: Select all
ReefAngel.Relay.Set(Box2_Port6,((now()%129600)<10800));
Roberto.

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Fri Jul 07, 2017 10:46 am
Hi Roberto, I'm trying to check if this change is working, but I get no info on the relay activity in the portal. It says that there is no data.
The portal itself shows current data, but nothing in relay activity or in web chart.
Can you point me in the right direction?
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Jul 07, 2017 10:48 am
You may need to update the firmware of wifi attachment:
viewtopic.php?f=3&t=4601
Roberto.

Posts: 96
Joined: Thu May 10, 2012 5:46 am
Location: Sunny (and hot) South Florida
PostPosted: Sun Jul 09, 2017 3:12 pm
Ok, I ran the ttl file to make sure all was good, but I still cant get any data on the web portal for relay activity or for web chart.
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sun Jul 09, 2017 4:39 pm
Can you post the tera term result?
Roberto.
PreviousNext

Return to How do I code ...

Who is online

Users browsing this forum: Bing [Bot] and 4 guests