Fan to kick on at set temperature?

Do you have a question on how to do something.
Ask in here.
Post Reply
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Fan to kick on at set temperature?

Post by DavidinGA »

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
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

ReefAngel.StandardFan(PortX,81,82);
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

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
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

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
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

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.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

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
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

Comment it out. Put this in the custom section inside loop
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

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
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

You can leave it, but I would comment it out or remove it to avoid confusion.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Fan to kick on at set temperature?

Post by rimai »

Ahh... Parameters are wrong. Replace this line:

Code: Select all

ReefAngel.StandardFan(Port4,81,82);
With this:

Code: Select all

ReefAngel.StandardFan(Port4,810,820);
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

K. I was wondering why I had 3 temperature digits on my heater lines and only 2 down here...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Fan to kick on at set temperature?

Post by lnevo »

Sorry forgot about that
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Fan to kick on at set temperature?

Post by DavidinGA »

Thanks I got it working.

:D
Post Reply