Water Level Expansion
Posted: Mon Sep 24, 2012 1:55 pm
First off, this thing is awesome!! It's going to make auto water change programming very easy!
I have programmed a basic ATO (where Port5 is my top off pump relay) along with a basic pump shut off if water is low (where Port8 is my return pump relay):
But I want to work with a timeout feature and I think maybe something similar to the heater or just make it turn on for a set number of seconds so that it isn't flipping the switch off and on when the water is fluctuating when topping off (i.e. water level is 60, top off until 62, then wait for 60 again). I am also wondering if there is an internal memory I plug into my functions and be able to adjust in portal or android (just like timeouts and changing times for lights).
Here is my full code if needed. Side note, I am trying to keep it on a standard RA board:
I have programmed a basic ATO (where Port5 is my top off pump relay) along with a basic pump shut off if water is low (where Port8 is my return pump relay):
Code: Select all
// If water level less than 60, turn on auto top off relay; else, keep it off
if (ReefAngel.WaterLevel.GetLevel()<60) ReefAngel.Relay.On(Port5);
else ReefAngel.Relay.Off(Port5);
// If water level equals 0, turn off return relay; else, keep it on
if (ReefAngel.WaterLevel.GetLevel()==0) ReefAngel.Relay.Off(Port8);
else ReefAngel.Relay.On(Port8);Here is my full code if needed. Side note, I am trying to keep it on a standard RA board:
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 <ReefAngel.h>
#include <WaterLevel.h> //Added for water level
// Initialize Buzzer variables
byte buzzer=0;
byte overheatflag=0;
byte atoflag=0;
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port4Bit | Port7Bit | Port8Bit;
ReefAngel.FeedingModePortsE[0] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port5Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port6Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port7Bit;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port1 ); //left radion
ReefAngel.Relay.On( Port2 ); //right radion
ReefAngel.Relay.On( Port8 ); //return
ReefAngel.Relay.On( Box1_Port7 ); //TBD
ReefAngel.Relay.On( Box1_Port8 ); //TBD
////// Place additional initialization code below here
InternalMemory.ATOHourInterval_write(0);
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3 );
ReefAngel.Relay.DelayedOn( Port7 );
overheatflag = InternalMemory.read( Overheat_Exceed_Flag );
atoflag = InternalMemory.read( ATO_Exceed_Flag );
////// Place your custom code below here
/* Auto feeding mode starts.
Feeder set for 17:30, start feeding mode at 17:25. */
if ( hour() == 17 && minute() == 25 && second() ==0 ) //if time is 17:25:00
{
ReefAngel.FeedingModeStart(); //start feeding mode
}
// Run Vortech during day only. Vortech is on from 09:00-20:00.
ReefAngel.StandardLights(Port4,9,0,20,0);
// If in water change mode, turn on the light in the cabinet (so I can see!)
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) ReefAngel.Relay.On(Port8);
// If water level less than 60, turn on auto top off relay; else, keep it off
if (ReefAngel.WaterLevel.GetLevel()<60) ReefAngel.Relay.On(Port5);
else ReefAngel.Relay.Off(Port5);
// If water level equals 0, turn off return relay; else, keep it on
if (ReefAngel.WaterLevel.GetLevel()==0) ReefAngel.Relay.Off(Port8);
else ReefAngel.Relay.On(Port8);
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "wolfpack" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
char text[7];
/* Drawing this:
01/01/12 00:00:00 AM
----------------------
Disp 79.9 pH 8.00
Sump 79.9 Sal 0.60
Room 77.7 WtrLvl Ok
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Moon Waning Crescent
Intensity 88%
Sunrise 06:15
Sunset 18:12
*/
/* Colors used in this script:
DefaultFGColor - For basic font and line
DefaultBGColor - For background color
PHColor - For values that may change
OutletOnBGColor - For okay water level
OutletOffBGColor - For low water level
To change colors, modify these values in ReefAngel_CustomColors.h file
*/
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(DefaultFGColor, 1, 11, 128, 11);
pingSerial();
//ReefAngel.LCD.DrawText(fcolor,bcolor,x,y,"text");
//Line 1 - Display Temp & pH
x = 8;
y = 15;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Disp");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"pH");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, x, y, 100);
//Line 2 - Sump & Salinity
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sump");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sal");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Salinity, PHColor, x, y, 10);
//Line 3 - Room
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Room");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Lvl");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.WaterLevel.GetLevel(), PHColor, x, y, 1);
//Lines 4 and 5 - Relays
x = 12;
y += 15;
// draw main relay
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
pingSerial();
}
void DrawCustomGraph()
{
}