Can you adding debugging commands and customize SMS alerts?
Posted: Thu Jan 03, 2013 4:17 pm
I have a few questions that I hope someone can help me with. I am attempting to get 3 dosing pumps working and I am using code that I have found in various posts from the forum. I cannot determine if the pumps are running as expected because I am not at home to observe them. I have been checking the Relay status section of the web portal but I don't see any activity for the pumps during the times they should be running. I do however see activity for other devices (ex. power head, heater, ATO and lights). So I would like to insert some debugging commands to send SMS messages or email messages so I can determine if my "if" statements are working as expected. Or is there a debugger that I can use to set breakpoints to test the code?
Here is the Sketch that I am currently using...
Also is there anyway to send custom SMS alerts beyond the ones listed below?
/* List of the possible alert codes.
WifiSendAlert(0)="Nothing"
WifiSendAlert(1)="Auto top-off timeout"
WifiSendAlert(2)="Water temperature too high"
WifiSendAlert(3)="Water temperature too low"
WifiSendAlert(4)="Lights temperature too high"
WifiSendAlert(5)="PH too high"
WifiSendAlert(6)="PH too low Alert"
Thank you in advance for your assistance.
Here is the Sketch that I am currently using...
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 <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
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// // Use T1 probe as temperature and overheat functions
// ReefAngel.TempProbe = T1_PROBE;
// ReefAngel.OverheatProbe = T1_PROBE;
// // Set the Overheat temperature setting
// InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port5 ); // Hydor powerhead
}
////// Place additional initialization code below here
// Setup SMS alerts
void WifiSendAlert(byte id, boolean IsAlert)
{
static byte alert_status;
if (IsAlert)
{
if ((alert_status & 1<<(id-1))==0)
{
alert_status|=1<<(id-1);
Serial.print("GET /status/alert.asp?e=3141234567@vtext.com&id=");
Serial.println(alert_status,DEC);
Serial.println("\n\n");
}
}
else
{
if (id==0)
{
alert_status=0;
delay(900);
}
else
{
alert_status&=~(1<<(id-1));
}
}
}
// Tunze short pulse functions
byte TunzeShortPulse(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync)
{
byte tspeed=0;
PulseMinSpeed=constrain(PulseMinSpeed,0,100);
PulseMaxSpeed=constrain(PulseMaxSpeed,0,100);
tspeed=(millis()%(PulseDuration*2)<PulseDuration?PulseMinSpeed:PulseMaxSpeed);
if (PulseSync)
return tspeed;
else
return (tspeed==PulseMinSpeed)?PulseMaxSpeed:PulseMinSpeed;
}
////// Place additional initialization code above here
void loop()
{
//*** Dosing Pumps *** added 12-27-12
// ReefAngel.DosingPumpRepeat( Port2,0,60,240 );
// ReefAngel.DosingPumpRepeat( Port3,0,60,240 );
// ReefAngel.DosingPumpRepeat( Port4,0,60,240 );
//*** Heater *** added 12-27-12
ReefAngel.StandardHeater( Port7,755,765 );
//*** Refugium Light *** added 12-27-12
ReefAngel.StandardLights( Port8,20,0,8,0 );
////// Place your custom code below here
/* List device attached to each port on the Relay Box.
Port 1 - ATO
Port 2 - Dosing Pump KH
Port 3 - Dosing Pump CA
Port 4 - Dosing Pump MG
Port 5 - Hydor Koralia (future) Tunze 6105 Powerhead
Port 6 - Unused (future) Tunze 6105 Powerhead
Port 7 - Heater
Port 8 - Sump LED Light
*/
// Night mode for Tunze powerheads starts at 10:00 pm and stops at 8:00 am.
if ( (hour() >=22) || (hour() <=8) ){
ReefAngel.PWM.SetActinic( TunzeShortPulse(30,30,10,true) );
ReefAngel.PWM.SetDaylight( TunzeShortPulse(30,50,5,false) ); }
else {
// Day mode for Tunze powerheads
ReefAngel.PWM.SetActinic( TunzeShortPulse(30,50,2,true) );
ReefAngel.PWM.SetDaylight( TunzeShortPulse(30,90,2,false) ); }
// THIS SECTION OF CODE IS NOT WORKING AS EXPECTED
// Dose Alk one time per hour for 1 minute between 8:00 pm and 5:00 am.
if ( hour() >=20 || hour() <5) {
ReefAngel.DosingPumpRepeat( Port2,0,60,60 ); }
else {
ReefAngel.Relay.Off( Port2 ); }
// Dose CA and MG one time per hour for 1 minute between 9:00 am and 6:00 pm.
if ( hour() >=9 && hour() <18) {
ReefAngel.DosingPumpRepeat( Port3,0,60,60 );
ReefAngel.DosingPumpRepeat( Port4,0,60,60 ); }
else {
ReefAngel.Relay.Off( Port3 );
ReefAngel.Relay.Off( Port4 ); }
// END OF SECTION THAT IS NOT WORKING CORRECTLY
/* List of the possible alert codes.
WifiSendAlert(0)="Nothing"
WifiSendAlert(1)="Auto top-off timeout"
WifiSendAlert(2)="Water temperature too high"
WifiSendAlert(3)="Water temperature too low"
WifiSendAlert(4)="Lights temperature too high"
WifiSendAlert(5)="PH too high"
WifiSendAlert(6)="PH too low Alert"
Let's say you would like to receive a high water temperature alert.
The line you have to add is:
if (ReefAngel.Params.Temp1>820) WifiSendAlert(2);
*/
// Send SMS text message alert if temp2 is less than 74.5 degrees.
if (ReefAngel.Params.Temp[2]<74.5 && ReefAngel.Params.Temp[2]>0) WifiSendAlert(3,true);
// Send SMS text message alert if temp3 is greater than 82 degrees.
if (ReefAngel.Params.Temp[2]>820 && ReefAngel.Params.Temp[2]<1850) WifiSendAlert(2,false);
//// Send SMS text message alert if temp1 is less than 74.5 degrees.
//if (ReefAngel.Params.Temp[1]<74.5 && ReefAngel.Params.Temp[1]>0) WifiSendAlert(3,true);
// Send SMS text message alert if temp is greater than 82 degrees.
//if (ReefAngel.Params.Temp[1]>820 && ReefAngel.Params.Temp[1]<1850) WifiSendAlert(2,false);
//*** ATO *** added 12-29-12
// Shutoff ATO if ATO reservoir is empty or if the sump is going to overflow.
if (!ReefAngel.LowATO.IsActive() || !ReefAngel.HighATO.IsActive()){
ReefAngel.Relay.Off (Port1);
WifiSendAlert(1,true);} // Send SMS text message alert "Auto top-off timeout".
else {
ReefAngel.Relay.On (Port1);}
////// Place your custom code above here
// This should always be the last line
// ReefAngel.AddWifi();
ReefAngel.Portal( "mudcat1" );
ReefAngel.ShowInterface();
}
/* List of the possible alert codes.
WifiSendAlert(0)="Nothing"
WifiSendAlert(1)="Auto top-off timeout"
WifiSendAlert(2)="Water temperature too high"
WifiSendAlert(3)="Water temperature too low"
WifiSendAlert(4)="Lights temperature too high"
WifiSendAlert(5)="PH too high"
WifiSendAlert(6)="PH too low Alert"
Thank you in advance for your assistance.