Fan to kick on at set temperature?

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

Posts: 83
Joined: Fri Jun 07, 2013 11:26 am
PostPosted: Wed Oct 15, 2014 1:04 pm
I want to be able to turn a fan on in my canopy at a set temperature and then have it turn off either when the water temp drops or at a set time; how do I do that?

Say I want the fan to kick on when the water hits 82F and then kick off if it hits 81F or at a set time (the end of the mh light cycle).


Thanks

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 <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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 845 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on

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


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

void loop()
{
    ReefAngel.StandardHeater( Port1,795,800 );
    ReefAngel.StandardHeater( Port2,794,800 );
    ReefAngel.StandardLights( Port3,24,0,15,0 );   ////scrubber lights 12am-3pm  15hrs on 9off
    ReefAngel.StandardLights( Port4,16,0,24,0 );  ////Canopy Fan 4pm to 12am
    ReefAngel.StandardLights( Port5,16,0,23,0 ); ////Metal Halide 4pm to 11pm
    ReefAngel.DosingPumpRepeat( Port6,0,660,10 ); /////mag 720min = 11hrs  15ml day
    ReefAngel.DosingPumpRepeat( Port7,0,360,26 );  /////alk 360min = 6hrs  78ml day
    ReefAngel.DosingPumpRepeat( Port8,0,300,21 );  ////cal 300min = 5hrs   78.75ml day 3cups per gal
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,60,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
else if (hour()==8 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,85,20);
else if (hour()>=8 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,75,40 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,85,4 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ReefCrest,56,20 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( LongPulse,80,5 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( LongPulse,75,14 );
else if (hour()==23 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,90,5);
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

{
   ReefAngel.AddWifi();
}
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "davidinga" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );   
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}

User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Oct 15, 2014 1:54 pm
ReefAngel.StandardFan(PortX,81,82);

Posts: 83
Joined: Fri Jun 07, 2013 11:26 am
PostPosted: Wed Oct 15, 2014 2:02 pm
Didn't know their was a fan code. Lol

So...

ReefAngel.StandardFan(Port4,81,82);

Kicks the fans on at 82f and off at 81f?

Am I able to code in a window of time where that applies too?
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Oct 15, 2014 3:14 pm
Yeah we just need to wrap it in an if statement with the times you want. Are you using internal memory for your MH?
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Oct 15, 2014 6:18 pm
How about this instead of a time window? (this is easier to code/read)

Code: Select all
if (ReefAngel.Relay.Status(Port5))
  ReefAngel.StandardFan(Port4,81,82))
else
  ReefAngel.Relay.Off(Port4);


This nice thing about that is that if you change your MH schedule or change it to use memory, it won't matter here.

If your halides are on then it will look to use the fan if necessary. Otherwise fan is off.

Posts: 83
Joined: Fri Jun 07, 2013 11:26 am
PostPosted: Wed Oct 15, 2014 9:33 pm
lnevo wrote:How about this instead of a time window? (this is easier to code/read)

Code: Select all
if (ReefAngel.Relay.Status(Port5))
  ReefAngel.StandardFan(Port4,81,82))
else
  ReefAngel.Relay.Off(Port4);


This nice thing about that is that if you change your MH schedule or change it to use memory, it won't matter here.

If your halides are on then it will look to use the fan if necessary. Otherwise fan is off.


Sweet.

So where would I put that code and what do I do with the existing code I have for the fan?
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Oct 16, 2014 3:25 am
Comment it out. Put this in the custom section inside loop

Posts: 83
Joined: Fri Jun 07, 2013 11:26 am
PostPosted: Thu Oct 16, 2014 12:57 pm
Does my code look correct?



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 <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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 845 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on

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


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

void loop()
{
    ReefAngel.StandardHeater( Port1,795,800 );
    ReefAngel.StandardHeater( Port2,794,800 );
    ReefAngel.StandardLights( Port3,24,0,15,0 );   ////scrubber lights 12am-3pm  15hrs on 9off
    ReefAngel.StandardLights( Port4,16,0,24,0 );  ////Canopy Fan 4pm to 12am
    ReefAngel.StandardLights( Port5,16,0,23,0 ); ////Metal Halide 4pm to 11pm
    ReefAngel.DosingPumpRepeat( Port6,0,660,10 ); /////mag 720min = 11hrs  15ml day
    ReefAngel.DosingPumpRepeat( Port7,0,360,26 );  /////alk 360min = 6hrs  78ml day
    ReefAngel.DosingPumpRepeat( Port8,0,300,21 );  ////cal 300min = 5hrs   78.75ml day 3cups per gal
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,60,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
else if (hour()==8 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,85,20);
else if (hour()>=8 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,75,40 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,85,4 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ReefCrest,56,20 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( LongPulse,80,5 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( LongPulse,75,14 );
else if (hour()==23 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,90,5);
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

{
   ReefAngel.AddWifi();
}

{
if (ReefAngel.Relay.Status(Port5))
  ReefAngel.StandardFan(Port4,81,82))
else
  ReefAngel.Relay.Off(Port4);
}
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "davidinga" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );   
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}



What about the line:

ReefAngel.StandardLights( Port4,16,0,24,0 ); ////Canopy Fan 4pm to 12am

Do I leave that in there like it is or what???
User avatar
Posts: 5361
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Oct 16, 2014 3:44 pm
You can leave it, but I would comment it out or remove it to avoid confusion.

Posts: 83
Joined: Fri Jun 07, 2013 11:26 am
PostPosted: Sat Oct 18, 2014 1:20 pm
The code is not working.

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 <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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 845 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on

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


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

void loop()
{
    ReefAngel.StandardHeater( Port1,795,800 );
    ReefAngel.StandardHeater( Port2,794,800 );
    ReefAngel.StandardLights( Port3,24,0,15,0 );   ////scrubber lights 12am-3pm  15hrs on 9off
   
    ReefAngel.StandardLights( Port5,16,0,23,0 ); ////Metal Halide 4pm to 11pm
    ReefAngel.DosingPumpRepeat( Port6,0,660,10 ); /////mag 720min = 11hrs  15ml day
    ReefAngel.DosingPumpRepeat( Port7,0,360,26 );  /////alk 360min = 6hrs  78ml day
    ReefAngel.DosingPumpRepeat( Port8,0,300,21 );  ////cal 300min = 5hrs   78.75ml day 3cups per gal
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,60,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
else if (hour()==8 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,85,20);
else if (hour()>=8 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,75,40 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,85,4 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ReefCrest,56,20 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( LongPulse,80,5 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( LongPulse,75,14 );
else if (hour()==23 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,90,5);
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

{
   ReefAngel.AddWifi();
}

{
if (ReefAngel.Relay.Status(Port5))
  ReefAngel.StandardFan(Port4,81,82))
else
  ReefAngel.Relay.Off(Port4);
}
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "davidinga" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );   
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}





I click "Verify" and it says:

sketch_Oct_18_2014_Metal_Halides.cpp: In function 'void loop()':
sketch_Oct_18_2014_Metal_Halides:114: error: expected `;' before ')' token



So...I changed the error to this:

Code: Select all
{
if (ReefAngel.Relay.Status(Port5))
  ReefAngel.StandardFan(Port4,81,82);
else
  ReefAngel.Relay.Off(Port4);
}



Which passed Verify. So I uploaded that to the RA+ and my fan port continues to run like before (my water temp on the probe is 80.6F btw).


What am I doing wrong here?

Thanks
Next

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 3 guests

cron