How to use the trigger options in the Portal
Re: How to use the trigger options in the Portal
i don't use ReefAngel.Portal() is the server to get the value. i don't have space for send parameters...
Re: How to use the trigger options in the Portal
work
<RA>
<T1>268</T1>
<T2>0</T2>
<T3>0</T3>
<PH>642</PH>
<R>11</R>
<RON>0</RON>
<ROFF>255</ROFF>
<ATOLOW>0</ATOLOW>
<ATOHIGH>1</ATOHIGH>
<EM>0</EM>
<REM>0</REM>
<PWMA>0</PWMA>
<PWMD>0</PWMD>
<C0>0</C0>
<C1>0</C1>
<C2>0</C2>
<C3>0</C3>
<C4>0</C4>
<C5>0</C5>
<C6>0</C6>
<C7>0</C7>
</RA>
<RA>
<T1>268</T1>
<T2>0</T2>
<T3>0</T3>
<PH>642</PH>
<R>11</R>
<RON>0</RON>
<ROFF>255</ROFF>
<ATOLOW>0</ATOLOW>
<ATOHIGH>1</ATOHIGH>
<EM>0</EM>
<REM>0</REM>
<PWMA>0</PWMA>
<PWMD>0</PWMD>
<C0>0</C0>
<C1>0</C1>
<C2>0</C2>
<C3>0</C3>
<C4>0</C4>
<C5>0</C5>
<C6>0</C6>
<C7>0</C7>
</RA>
Re: How to use the trigger options in the Portal
i put this trigger:
T1 <= 24 Temp too less
T1 >= 27.5 Temp too high
RON > 0 Relay force on
ROFF < 255 Relay force off
C0 = 1 ATO Alarm
C1 = 1 Overheat Alarm
T1 <= 24 Temp too less
T1 >= 27.5 Temp too high
RON > 0 Relay force on
ROFF < 255 Relay force off
C0 = 1 ATO Alarm
C1 = 1 Overheat Alarm
Re: How to use the trigger options in the Portal
i try the ATO Alarm , C0=1... but i see that the alarm don't arrive.
so i try to connect to wifi of the controller... but not work. /wifi or /r99 nothing ......
i restart my controller, but nothing the web server don't respond....
i try to clear the ato alarm and..... magically the web server work!
there is some bug to customs ?
so i try to connect to wifi of the controller... but not work. /wifi or /r99 nothing ......
i restart my controller, but nothing the web server don't respond....
i try to clear the ato alarm and..... magically the web server work!
there is some bug to customs ?
Re: How to use the trigger options in the Portal
The alarm is only sent when the data is sent to the portal. If you are only sending the data every 3 minutes, then it can take up to 3 minutes for the alarm to be sent once it is triggered. Also, make sure you are setting the alarm / custom variable BEFORE the call to Portal() (or webbanner()). Otherwise, the value will not be sent until the next time it is sent (which could be another 3 minutes later).
Re: How to use the trigger options in the Portal
the problem is not the alarm...but the internal web server of the RA.
When the ato alarm is on and the c0=1 the internal web server of the RA don't work.
when i write on my browser ip:2000/wifi o /r99 it not answer
When the ato alarm is on and the c0=1 the internal web server of the RA don't work.
when i write on my browser ip:2000/wifi o /r99 it not answer
Re: How to use the trigger options in the Portal
This is the code I use to test:
With this features:
When I pull the data without timeout, I get this:
When I pull data with the timeout, I get this:
I could not get the same behavior you experienced.
Can you post your code and features?
Code: Select all
#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <ReefAngel.h>
void setup()
{
ReefAngel.Init();
}
void loop()
{
ReefAngel.SingleATO(true,Port1,4,1);
if ( InternalMemory.read(ATO_Single_Exceed_Flag) == 1 )
{
ReefAngel.CustomVar[0]=1;
}
else
{
ReefAngel.CustomVar[0]=0;
}
ReefAngel.ShowInterface();
}
Code: Select all
#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__
#define DisplayLEDPWM
#define wifi
#define SIMPLE_MENU
#define ENABLE_EXCEED_FLAGS
#define CUSTOM_VARIABLES
#endif // __REEFANGEL_FEATURES_H__
Code: Select all
HTTP/1.1 200 OK
Server: ReefAngel
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/xml
Content-Length: 257
<RA><T1>0</T1><T2>0</T2><T3>0</T3><PH>505</PH><R>0</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>0</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>20</PWMA><PWMD>20</PWMD><C0>0</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
Code: Select all
HTTP/1.1 200 OK
Server: ReefAngel
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/xml
Content-Length: 257
<RA><T1>0</T1><T2>0</T2><T3>0</T3><PH>504</PH><R>0</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>0</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>20</PWMA><PWMD>20</PWMD><C0>1</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
Can you post your code and features?
Roberto.
Re: How to use the trigger options in the Portal
this is my pde
if you want, this evening i retry it
with the new version the dosingpump repeat don't work.... or i' m not able....// Autogenerated file by RAGen (v1.2.1.158), (02/21/2012 19:09)
// RA_022112_1909.ino
//
// This version designed for v0.9.0 or later
/* The following features are enabled for this File:
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
#define CUSTOM_MAIN
#define ENABLE_ATO_LOGGING
#define ENABLE_EXCEED_FLAGS
#define CUSTOM_VARIABLES
*/
#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 <ReefAngel.h>
int DP3_Timer = InternalMemory.DP1Timer_read() * 4;
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 10, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 10, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
byte x = 8;
byte y = 45;
char text[7];
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x, y, "DP1:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+25, y, InternalMemory.DP1Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+37, y, "DP2:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+62, y, InternalMemory.DP2Timer_read());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+75, y, "DP3:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+101, y, DP3_Timer);
x = 6;
y += MENU_START_ROW+6;
y -= 3;
ReefAngel.LCD.Clear(COLOR_BLACK, x, y, 124, y);
y +=1;
ReefAngel.LCD.Clear(COLOR_BLUE, x+1, y, 123, y+10);
y +=11;
ReefAngel.LCD.Clear(COLOR_BLACK, x, y, 124, y);
ReefAngel.LCD.Clear(COLOR_BLACK, x, y-11, x, y+16);
ReefAngel.LCD.Clear(COLOR_BLACK, 124, y-11, 124, y+16);
ReefAngel.LCD.DrawText(COLOR_WHITE, COLOR_BLUE, x+40, y-9, "Alarms");
y += 6;
x += 2;
byte fcolor;
// This is for the LOW Ato switch
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+2, y,"ATO:");
if ( InternalMemory.read(ATO_Single_Exceed_Flag) == 1 )
{
// add in InternalMemory.write(700, 1) when ato is tripped
// add in InternalMemory.write(700, 0) when ato is cleared
fcolor = COLOR_RED;
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+30, y, "YES");
}
else
{
fcolor = COLOR_GREEN;
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+30, y, "NO ");
}
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, x+55, y,"OverH:");
if ( InternalMemory.read(Overheat_Exceed_Flag) == 1 )
{
// add in InternalMemory.write(701, 1) when overheat is tripped
// add in InternalMemory.write(701, 0) when overheat is cleared
fcolor = COLOR_RED;
strcpy(text, "YES");
}
else
{
fcolor = COLOR_GREEN;
strcpy(text, "NO ");
}
ReefAngel.LCD.DrawText(fcolor, DefaultBGColor, x+94, y, text);
ReefAngel.LCD.Clear(COLOR_BLACK, x-2, y+11, 124, y+11);
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 95, TempRelay);
}
void DrawCustomGraph()
{
// ReefAngel.LCD.DrawGraph(5, 5);
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit(1); // set to Celsius Temperature
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
int DP3_Timer = InternalMemory.DP1Timer_read() * 4;
}
void loop()
{
// Specific functions
ReefAngel.StandardFan(Port1);
ReefAngel.MHLights(Port2);
// ReefAngel.DosingPump1(Port3);
//ReefAngel.DosingPumpRepeat(Port3, 0, 360, InternalMemory.DP1Timer_read());
ReefAngel.Relay.DelayedOn(Port4, 5);
// ReefAngel.DosingPump2(Port5);
//ReefAngel.DosingPumpRepeat(Port5, 10, 360, InternalMemory.DP2Timer_read());
ReefAngel.SingleATOHigh(Port6);
ReefAngel.StandardHeater(Port8);
ReefAngel.DosingPump(Port3, 1, 23, 20, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 05, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 11, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port3, 1, 17, 00, InternalMemory.DP1Timer_read());
ReefAngel.DosingPump(Port5, 2, 23, 30, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 05, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 11, 10, InternalMemory.DP2Timer_read());
ReefAngel.DosingPump(Port5, 2, 17, 10, InternalMemory.DP2Timer_read());
// ReefAngel.DosingPump(Port7, 23, 20, DP3_Timer); // Setup Dosing Pump 3 Oligo
ReefAngel.ShowInterface();
if ( InternalMemory.read(ATO_Single_Exceed_Flag) == 1 )
{
ReefAngel.CustomVar[0]=1;
}
else
{
ReefAngel.CustomVar[0]=0;
}
if ( InternalMemory.read(Overheat_Exceed_Flag) == 1 )
{
ReefAngel.CustomVar[1]=1;
}
else
{
ReefAngel.CustomVar[1]=0;
}
}
if you want, this evening i retry it
Re: How to use the trigger options in the Portal
Did you download 0.9.2 for the dosing pump fix?
I'll look over your code to see what I get.
I'll look over your code to see what I get.
Roberto.
Re: How to use the trigger options in the Portal
Just to confirm, but you do have this on the features file, righ?
Code: Select all
#define ENABLE_EXCEED_FLAGS
Roberto.
Re: How to use the trigger options in the Portal
I tested your code and got the same thing I posted earlier.
Seems it is working fine here.
Seems it is working fine here.
Roberto.
Re: How to use the trigger options in the Portal
i try it now...and it's work
<RA><T1>266</T1><T2>0</T2><T3>0</T3><PH>924</PH><R>11</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>0</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>0</PWMA><PWMD>0</PWMD><C0>1</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
<RA><T1>266</T1><T2>0</T2><T3>0</T3><PH>924</PH><R>11</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>0</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>0</PWMA><PWMD>0</PWMD><C0>1</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
Re: How to use the trigger options in the Portal
Hi,
i enable the Portal in my .ino code, and it' s work.
Now, i have the ATO in Alarms :
<RA><T1>270</T1><T2>0</T2><T3>0</T3><PH>665</PH><R>15</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>1</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>0</PWMA><PWMD>0</PWMD><C0>1</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
i set the trigger, but the portal don't send the email.
What is wrong ?
i enable the Portal in my .ino code, and it' s work.
Now, i have the ATO in Alarms :
<RA><T1>270</T1><T2>0</T2><T3>0</T3><PH>665</PH><R>15</R><RON>0</RON><ROFF>255</ROFF><ATOLOW>0</ATOLOW><ATOHIGH>1</ATOHIGH><EM>0</EM><REM>0</REM><PWMA>0</PWMA><PWMD>0</PWMD><C0>1</C0><C1>0</C1><C2>0</C2><C3>0</C3><C4>0</C4><C5>0</C5><C6>0</C6><C7>0</C7></RA>
i set the trigger, but the portal don't send the email.
What is wrong ?
Re: How to use the trigger options in the Portal
Roberto, have any news?
Re: How to use the trigger options in the Portal
Yes, it should've been fixed a while ago.
Sorry I forgot to post.
Can you try?
Sorry I forgot to post.
Can you try?
Roberto.
Re: How to use the trigger options in the Portal
i don't try it....rimai wrote:Yes, it should've been fixed a while ago.
Sorry I forgot to post.
Can you try?
but,
do you think is possible add at the trigger a lable ?
for example i set this:
T1 <= 23.7
T1 >= 27.5
RON > 0
C0 = 1
C1 = 1
Is possible add a lable, so the email object use it ?
Like :
T1 <= 23.7 Label: Water temp too low
T1 >= 27.5 Label: Water temp too high
RON > 0 Label: test
C0 = 1 Label: ATO Alarm
C1 = 1 Label: Overheat Alarm
Do you think is possible configure a rearm ?
TNX
Re: How to use the trigger options in the Portal
I think it already sends the trigger as well as the actual value, so you know exactly what happened.
The trigger is always active and will send alerts every consecutive hour if the alert condition is still active.
The trigger is always active and will send alerts every consecutive hour if the alert condition is still active.
Roberto.
Re: How to use the trigger options in the Portal
I am trying to do similar. I would like to set a custom variable when the ATO timeout is exceeded. The code compiles fine, but my custom variable is not set for some reason. Here are (I think) the relevant portions of my ino file:
When compiling I get this output, which I think indicates the exceed flagging is enabled, and which I think is required for the custom ATO function to set the ato flag properly:
What the heck am I missing?
Code: Select all
/* The following features are enabled for this File:
#define DisplayImages
#define SetupExtras
#define OverheatSetup
#define DateTimeSetup
#define VersionMenu
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define DosingPumpIntervalSetup
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define CUSTOM_MAIN
#define COLORS_PDE
#define ENABLE_ATO_LOGGING
#define ENABLE_EXCEED_FLAGS
#define IOEXPANSION
#define FONT_8x8
#define FONT_8x16
#define FONT_12x16
#define NUMBERS_8x8
#define NUMBERS_8x16
#define NUMBERS_12x16
#define NUMBERS_16x16
#define CUSTOM_VARIABLES
*/
#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <Timer.h>
#include <Memory.h>
#include <IO.h>
#include <ReefAngel.h>
#include <RA_PWM.h>
#include <avr/pgmspace.h>
.
.
.
void MyCustomATO(int ATOTimeout)
{
/*
This function works as follows:
When it's time to topoff the system, we check the levels of each
of the three reservoirs. If a reservoir is empty, we set a custom
flag to indicate it's empty on the portal and we do not start that
pump. Otherwise, we clear the custom flag for the reservoir and
start the pump.
The function monitors the switch levels like normal.
Monitor the status of the reservoirs while topping off.
When the high switch is triggered (aka, finished topping off),
ALL ports are turned off regardless of status (doesn't hurt to do this).
If the timeout occurs, the LED light comes on and all ports are
turned off just like when we finish topping off.
*/
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
if ( ReefAngel.LowATO.IsActive() && ( !ReefAngel.LowATO.IsTopping()) )
{
ReefAngel.LowATO.Timer = millis();
ReefAngel.LowATO.StartTopping();
// Check the level of each reservoir
// If empty, set the alert and don't start topping off
// otherwise if not empty, clear the alert and start topping
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
// Monitor levels while topping off, to prevent a reservoir from running dry
// Might need to remove this check here -- Nope, this seems to work fine.
if ( ReefAngel.LowATO.IsTopping() )
{
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
if ( ReefAngel.HighATO.IsActive() )
{
ReefAngel.LowATO.StopTopping(); // stop the low ato timer
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
}
if ( (millis()-ReefAngel.LowATO.Timer > TempTimeout) && ReefAngel.LowATO.IsTopping() )
{
ReefAngel.LED.On();
#ifdef ENABLE_EXCEED_FLAGS
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}
.
.
.
loop section:
//If the ATO float switch is stuck, and the topoff pump timeout flag is set, then set C5=1
if ( InternalMemory.read(ATO_Exceed_Flag) == 1 )
{
ReefAngel.CustomVar[5]=1;
}
else
{
ReefAngel.CustomVar[5]=0;
}
Code: Select all
The following feature was automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Dimming Signal
I/O Expansion Module
Wifi
Relay Expansion Module
Number of Relay Expasions: 1
Custom Main Screen
Custom Menu
Number of Menu Options: 9
Custom Variable
Exceed Flagging
Extra Font - Medium Size (8x8 pixels)
Extra Font - Large Size (8x16 pixels)
Extra Font - Extra Large Size (12x16 pixels)
Extra Font - Numbers Only - Medium Size (8x8 pixels)
Extra Font - Numbers Only - Large Font (8x16 pixels)
Extra Font - Numbers Only - Extra Large Font (12x16 pixels)
Extra Font - Numbers Only - Huge Font (16x16 pixels)
Date/Time Setup Menu
Binary sketch size: 41,740 bytes (of a 258,048 byte maximum)
Re: How to use the trigger options in the Portal
Just to be sure, you do have MyCustomATO() inside loop(), correct?
Other than that, everything looks good.
Does the red status led turn on when the you get ato timeout?
Other than that, everything looks good.
Does the red status led turn on when the you get ato timeout?
Roberto.
Re: How to use the trigger options in the Portal
Yes, MyCustomATO() is inside loop(), and the red status light comes on. I just retested it all to make sure, too. Here is the (now lengthy) code:
Code: Select all
/* The following features are enabled for this File:
#define DisplayImages
#define SetupExtras
#define OverheatSetup
#define DateTimeSetup
#define VersionMenu
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define DosingPumpIntervalSetup
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define CUSTOM_MAIN
#define COLORS_PDE
#define ENABLE_ATO_LOGGING
#define ENABLE_EXCEED_FLAGS
#define IOEXPANSION
#define FONT_8x8
#define FONT_8x16
#define FONT_12x16
#define NUMBERS_8x8
#define NUMBERS_8x16
#define NUMBERS_12x16
#define NUMBERS_16x16
#define CUSTOM_VARIABLES
*/
#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <Timer.h>
#include <Memory.h>
#include <IO.h>
#include <ReefAngel.h>
#include <RA_PWM.h>
#include <avr/pgmspace.h>
////// Place global variable code below here
// Initialize Buzzer variables
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long buzzerinterval = 1000; // interval at which to sound buzzer (milliseconds)
long previousMillis = 0;
////// Place global variable code above here
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Date / Time";
prog_char menu7_label[] PROGMEM = "Version";
prog_char menu8_label[] PROGMEM = "Turn ON/OFF Skimmer";
prog_char menu9_label[] PROGMEM = "Turn Off Skimmer";
// Group the menu entries together
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label,
menu4_label, menu5_label, menu6_label,
menu7_label, menu8_label, menu9_label
};
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayVersion();
}
void MenuEntry8()
{
ReefAngel.Relay.Toggle(Box1_Port8);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Box1_Port8);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 119);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// draw main relay
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
pingSerial();
// draw 1st expansion relay
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif // RelayExp
}
void DrawCustomGraph()
{
// Change the 45 to adjust the horizontal position of the text
ReefAngel.LCD.DrawGraph(5, 5);
}
void CheckReservoirStatus(byte channel, byte pump)
{
if ( ReefAngel.IO.GetChannel(channel) )
{
// If empty, shutoff the port, trigger alert
ReefAngel.CustomVar[channel] = 1;
ReefAngel.Relay.Off(pump);
}
else
{
// If not empty, turn on the port, clear alert
ReefAngel.CustomVar[channel] = 0;
ReefAngel.Relay.On(pump);
}
}
void MyCustomATO(int ATOTimeout)
{
/*
This function works as follows:
When it's time to topoff the system, we check the levels of each
of the three reservoirs. If a reservoir is empty, we set a custom
flag to indicate it's empty on the portal and we do not start that
pump. Otherwise, we clear the custom flag for the reservoir and
start the pump.
The function monitors the switch levels like normal.
Monitor the status of the reservoirs while topping off.
When the high switch is triggered (aka, finished topping off),
ALL ports are turned off regardless of status (doesn't hurt to do this).
If the timeout occurs, the LED light comes on and all ports are
turned off just like when we finish topping off.
*/
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
if ( ReefAngel.LowATO.IsActive() && ( !ReefAngel.LowATO.IsTopping()) )
{
ReefAngel.LowATO.Timer = millis();
ReefAngel.LowATO.StartTopping();
// Check the level of each reservoir
// If empty, set the alert and don't start topping off
// otherwise if not empty, clear the alert and start topping
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
// Monitor levels while topping off, to prevent a reservoir from running dry
// Might need to remove this check here -- Nope, this seems to work fine.
if ( ReefAngel.LowATO.IsTopping() )
{
CheckReservoirStatus(0, Port5);
CheckReservoirStatus(1, Port6);
CheckReservoirStatus(2, Box1_Port5);
}
if ( ReefAngel.HighATO.IsActive() )
{
ReefAngel.LowATO.StopTopping(); // stop the low ato timer
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
}
if ( (millis()-ReefAngel.LowATO.Timer > TempTimeout) && ReefAngel.LowATO.IsTopping() )
{
ReefAngel.LED.On();
#ifdef ENABLE_EXCEED_FLAGS
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Initialize the custom menu
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port8Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port7Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port4Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port2Bit | Port5Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port5Bit | Port6Bit | Port8Bit;
// Ports that are always on
ReefAngel.Relay.On(Port3);
ReefAngel.Relay.On(Port8);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.Relay.On(Box1_Port7);
ReefAngel.Relay.On(Box1_Port8);
////// Place additional initialization code below here
ReefAngel.OverheatProbe = T1_PROBE; // Use Temperature probe 1 to check for overheat
////// Place additional initialization code above here
}
void loop()
{
// Specific functions that use Internal Memory values
ReefAngel.StandardLights(Port1,23,0,2,0); // Moon lights on 23:00-02:00
ReefAngel.StandardHeater(Port2,780,790); // 800w heater on at 78.0, off at 79.0
ReefAngel.MHLights(Port4); // MH on 14:00-22:00, delay 15m if power fails
ReefAngel.StandardLights(Port7,21,0,13,0); // Sump lights on 21:00-13:00
ReefAngel.MHLights(Box1_Port1); // MH on 14:00-22:00, delay 15m if power fails
ReefAngel.StandardHeater(Box1_Port2); // 250w heater on at 78.5, off at 79.0
ReefAngel.StandardLights(Box1_Port3); // Actinics on 13:00-23:00
////// Place your custom code below here
//ATO function
MyCustomATO(InternalMemory.ATOTimeout_read());
//Notify when sump level is low
if ( ReefAngel.IO.GetChannel(4) )
{
ReefAngel.CustomVar[4]=1;
// If the sump level is about to cavitate the pumps, then sound the alarm
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > buzzerinterval) {
// save the last time the buzzer turned on
previousMillis = currentMillis;
// if the buzzer is off turn it on and vice-versa:
if (ReefAngel.PWM.GetDaylightValue() == 0)
ReefAngel.PWM.SetDaylight(25);
else
ReefAngel.PWM.SetDaylight(0);
}
}
else
{
// Turn the buzzer off when the sump level is above cavitation levels
ReefAngel.PWM.SetDaylight(0);
ReefAngel.CustomVar[4]=0;
}
//If the ATO float switch is stuck, and the topoff pump timeout flag is set, then set C5=1
if ( InternalMemory.read(ATO_Exceed_Flag) == 1 )
{
ReefAngel.CustomVar[5]=1;
}
else
{
ReefAngel.CustomVar[5]=0;
}
//Vodka dosing
if ( ReefAngel.IO.GetChannel(3) ) //Check there is vodka in the reservoir
{
ReefAngel.Relay.Off(Box1_Port6); //If no vodka, then set a variable and turn off the port
ReefAngel.CustomVar[3]=1;
}
else //If there is vodka, then dose
{
ReefAngel.CustomVar[3]=0;
ReefAngel.DosingPumpRepeat1(Box1_Port6);
}
////// Place your custom code above here
// This sends all the data to the portal
// Do not add any custom code that changes any relay status after this line
// The only code after this line should be the ShowInterface function
ReefAngel.Portal("btorrenga");
// This should always be the last line
ReefAngel.ShowInterface();
}
Re: How to use the trigger options in the Portal
How about the other custom variables??
Are they working?
Are they working?
Roberto.
Re: How to use the trigger options in the Portal
All the other variables are working great. I have been testing them all afternoon and am very pleased.
Re: How to use the trigger options in the Portal
Try doing this instead to see what values you are getting:
Technically, it should be the same thing, but simplified.
Code: Select all
ReefAngel.CustomVar[5]=InternalMemory.read(ATO_Exceed_Flag);
Roberto.
Re: How to use the trigger options in the Portal
Getting some results now. The values I have seen reported in the portal have been 181, 191, 255 and 255. I am not sure how those numbers are determined, but at least something is happening. I assumed the value of ATO_Exceed_Flag would be 1 or 0 only. How is the value determined?
Re: How to use the trigger options in the Portal
Weird.
It should be 0 or 1.
This line writes 1 and when you clear ATO timeout, it writes 0.
It should be 0 or 1.
Code: Select all
InternalMemory.write(ATO_Exceed_Flag, 1);
Roberto.
Re: How to use the trigger options in the Portal
I would expect that behavior, too. I have cleared the ATO and now ATO_Exceed_Flag is reporting to the portal as 254.
Re: How to use the trigger options in the Portal
Can you add this to your loop() and open Tools->Serial Monitor and see what you get?
Make sure to set Serial Monitor to use 57600 baud.
Code: Select all
Serial.print("CustomVar[5]: ");
Serial.println(InternalMemory.read(ATO_Exceed_Flag));
Roberto.
Re: How to use the trigger options in the Portal
what is the water level variable? I'd like to see a graph.