Setting Reminders

Would you like to help?
Share your walkthrough tutorial with others
Post Reply
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Setting Reminders

Post by binder »

GreenVF wrote:Hi Inevo
Thanks for your response.
I think my problem is where in my code to add "checkReminders(); in my main loop and also were to add the function.
My code is all from the wizard. except where I tried to add the reminders. I'm a total noob when it comes down to coding. I do have the wifi module , and reef angel plus.

and then the errors
sketch_aug03a.cpp: In function 'void loop()':
sketch_aug03a:86: error: 'checkReminders' was not declared in this scope
sketch_aug03a:91: error: a function-definition is not allowed here before '{' token
sketch_aug03a:101: error: a function-definition is not allowed here before '{' token
sketch_aug03a:145: error: expected `}' at end of input
Your code cuts off the closing of the file. You placed all of the code inside the loop when only checkReminders(); needed to be in there. Here's what it should look like:

Code: Select all

void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port2Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit;
    // 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( Port8 );

    ////// Place additional initialization code below here
    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.Relay.DelayedOn( Port1 );
    ReefAngel.Relay.DelayedOn( Port2 );
    ReefAngel.StandardHeater( Port3 );
    ReefAngel.StandardHeater( Port4 );
    ReefAngel.ActinicLights( Port5 );
    ReefAngel.DayLights( Port6 );
    ReefAngel.MoonLights( Port7 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    ReefAngel.PWM.SetActinic( MoonPhase() );
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = AntiSync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;

    ////// Place your custom code below here
    checkReminders();  // functions are defined below


    ////// Place your custom code above here
	
    // This should always be the last line
    ReefAngel.Portal( "GreenVF" );
    ReefAngel.ShowInterface();
}


// Reminder Code is listed below
void checkReminders()
{
   // grab the current time and use it for processing the reminders
   // do it this way to prevent rollover errors...just in case
   time_t t = now();
   remindTraceElements(t);
   remindWaterChange(t);
   remindMonthly(t);
}

void remindTraceElements(time_t t)
{
   // Sunday = 1, Monday = 2, etc
   if ((weekday(t) == 2) || (weekday(t) == 5)) {
      // Every monday and thursday at 10pm
      if ((hour(t) == 22) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Add+Trace+Elements");
      }
   }
}

void remindWaterChange(time_t t)
{
   if (weekday() == 4) {
      // Every wednesday at 8pm
      if ((hour(t) == 20) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Water+Change+Time");
      }
   }
}

void remindMonthly(time_t t)
{
   // Every 1st of the month at 8pm
   if (day(t) == 1) {
      if ((hour(t) == 20) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Change+filter+pads");
      }
   }
}

void sendReminder(char* msg)
{
   static WifiAlert r;
        // No delay, for immediate sending
   r.SetDelay(0);
   // No spaces are allowed in the msg
   r.Send(msg);
}
I moved things around for you and it should be just fine.
GreenVF
Posts: 8
Joined: Tue Apr 21, 2015 5:03 am
Location: AUSTRALIA

Re: Setting Reminders

Post by GreenVF »

Thank you Binder
Much appreciated. Got it now compiling. I also found a I had a few errors that I managed to sort out.
note to self. case sensitive and I had to include WifiAlert.h file
Here is the completed working code for now.
Attachments
newsetup.ino
(3.94 KiB) Downloaded 542 times
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Setting Reminders

Post by binder »

awesome. glad you got it compiling.

yeah, things are case sensitive.


Sent from my iPad mini
Post Reply