I am switching from a pump based float switch ATO to a solenoid valve/float valve system.
This frees up my 2 float switch ports.
I want to use one in my container that holds skimmer waste. When the float switch is active (the container is full), I want to shut off the protein skimmer port. I've had my skimmer pump water and overflow the container twice since I've had the tank and I would like to not have to clean up the mess again. This would also give me peace of mind to wet skim as I am afraid to at the moment.
I want to use the other one in my return chamber of my sump. When it's active, I want to turn the solenoid port off. (If my float valve fails, this sensor will tell me that the water level has rose above the valve. and will prevent any more flow)
I've seen some solutions, however, I still want to honor my other settings of water change and feeding mode to turn off the protein skimmer.
How do I code this?
Turn ports off with float switch activation
Re: Turn ports off with float switch activation
Look at the CheckSwitches function in my INO (look at my signature for link)
As long as the new statements come after any previous you shouldn't have a problem. Feel free to post the code and we can help you review it
As long as the new statements come after any previous you shouldn't have a problem. Feel free to post the code and we can help you review it
Re: Turn ports off with float switch activation
I took a glance at your code and it seems to be what I am looking for. I'm at work right now, so I can't write a version for my system just yet, but I will post back with my code when I get a chance.
Might be a little while due to the holidays and having to finish shopping and what not. Thanks for offering to help
Might be a little while due to the holidays and having to finish shopping and what not. Thanks for offering to help
Re: Turn ports off with float switch activation
Alright, I took a stab at it while adhering to KISS (Keep It Simple Stupid)
I implemented my own checkSwitches method. Would you mind giving it a second look? I also added schedules for the ATO solenoid and the RODI reservoir solenoid and added a hardcoded doser (as I understand it, you can only have 3 for internal memory) for this round of code.
I don't really know any other way to test it without uploading it to my display tank, which I would like to have someone look it all over for quality assurance before I do so just in case I missed something
Here is my code:
Thanks for your help!
I implemented my own checkSwitches method. Would you mind giving it a second look? I also added schedules for the ATO solenoid and the RODI reservoir solenoid and added a hardcoded doser (as I understand it, you can only have 3 for internal memory) for this round of code.
I don't really know any other way to test it without uploading it to my display tank, which I would like to have someone look it all over for quality assurance before I do so just in case I missed something
Here is my code:
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 <PAR.h>
#include <WiFiAlert.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
//Feeding Mode Ports (Gyre Wavemaker, Return Pump, Protein Skimmer, Reactor Pump)
ReefAngel.FeedingModePorts = Port2Bit | Port3Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port6Bit;
//Water Change Ports(Gyre Wavemaker, Return Pump, Protein Skimmer, Reactor Pump)
ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
ReefAngel.WaterChangePortsE[0] = Port4Bit | Port6Bit;
//Lights on ports (not sure if I even need to initialiize these since I'm not using them. Leaving it in here for now)
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
//Overheat Ports (Heater-R, Sump Light, LED-R, Heater-M, LED-L, Heater-L, Protein Skimmer, Reactor Pump)
ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port3Bit | Port4Bit | Port6Bit;
// Use T2 (display tank) as Temp Probe, and use T3 (sump) as Overheat probe
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T3_PROBE;
// Ports that are always on
//Gyre Wavemaker
ReefAngel.Relay.On( Port2 );
//Return Pump
ReefAngel.Relay.On( Port3 );
//LED-R
ReefAngel.Relay.On( Port5 );
//LED-L
ReefAngel.Relay.On( Box1_Port1 );
//Reactor Pump
ReefAngel.Relay.On( Box1_Port6 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
//Heater-R
ReefAngel.StandardHeater( Port1 );
//Sump light
ReefAngel.MoonLights( Port4 );
//Heater-M
ReefAngel.StandardHeater( Port6 );
//Alkalinity Doser
ReefAngel.DosingPumpRepeat1( Port7 );
//Calcium Doser
ReefAngel.DosingPumpRepeat2( Port8 );
//ATO solenoid active from 7pm-8pm
ReefAngel.StandardLights(Port2,19,0,20,0);
//Heater-L
ReefAngel.StandardHeater( Box1_Port3 );
//Protein Skimmer
ReefAngel.Relay.DelayedOn( Box1_Port4 );
//RODI Reservoir solenoid active from 7am - 10am
ReefAngel.StandardLights(Port2,7,0,10,0);
//Magnesium Doser on every 60 minutes with 10 minute offset for 19 seconds
ReefAngel.DosingPumpRepeat( Box1_Port7,10,60,19 );
//KALK Doser
ReefAngel.DosingPumpRepeat3( Box1_Port8 );
//Check float switches
CheckSwitches();
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "KCReefer" );
ReefAngel.DDNS( "Leonard" ); // Your DDNS is KCReefer-Leonard.myreefangel.com
ReefAngel.ShowInterface();
}
void CheckSwitches() {
static WiFiAlert switchAlert;
// Turn off protein skimmer if skimmate container is full (High ATO)
if (!ReefAngel.HighATO.IsActive()) { // switch on by default
switchAlert.Send("skimmate+level+alarm!+protein+skimmer+disabled.");
ReefAngel.Relay.Override(Box1_Port4,0);
}
//Turn of ATO solenoid if sump water level is high (Low ATO) and not in feeding or water change mode
if(!ReefAngel.DisplayedMenu==FEEDING_MODE && !ReefAngel.DisplayedMenu==WATERCHANGE_MODE){
if(ReefAngel.LowATO.IsActive()) { //swith off by default
switchAlert.Send("sump+full+alarm!+ATO+solenoid+disabled.");
ReefAngel.Relay.Override(Box1_Port2,0);
}
}
}
Re: Turn ports off with float switch activation
Well there were a few issues:
1) I had port 2 assigned to both solenoid valves (copy/paste error). port 2 is my wavemaker so it was not coming on and I could not figure out why at first
2) The float switch in the sump that is supposed to turn off the ATO solenoid is not overriding the value when on.
The protein skimmer switch turns off the protein skimmer appropriately though, so part of the checkSwitches method works. Not sure why the second part of the method isn't turning off the solenoid valve ...
here is the snippet of code that is supposed to turn off the ATO solenoid if low ATO is on and not in feeding or water change mode:
Here is my corrected code that is now active on my controller:
1) I had port 2 assigned to both solenoid valves (copy/paste error). port 2 is my wavemaker so it was not coming on and I could not figure out why at first
2) The float switch in the sump that is supposed to turn off the ATO solenoid is not overriding the value when on.
The protein skimmer switch turns off the protein skimmer appropriately though, so part of the checkSwitches method works. Not sure why the second part of the method isn't turning off the solenoid valve ...
here is the snippet of code that is supposed to turn off the ATO solenoid if low ATO is on and not in feeding or water change mode:
Code: Select all
//Turn of ATO solenoid if sump water level is high (Low ATO) and not in feeding or water change mode
if(!ReefAngel.DisplayedMenu==FEEDING_MODE && !ReefAngel.DisplayedMenu==WATERCHANGE_MODE){
if(ReefAngel.LowATO.IsActive()) { //swith off by default
switchAlert.Send("sump+full+alarm!+ATO+solenoid+disabled.");
ReefAngel.Relay.Override(Box1_Port2,0);
}
}
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 <PAR.h>
#include <WiFiAlert.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
//Feeding Mode Ports (Gyre Wavemaker, Return Pump, Protein Skimmer, Reactor Pump)
ReefAngel.FeedingModePorts = Port2Bit | Port3Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port6Bit;
//Water Change Ports(Gyre Wavemaker, Return Pump, Protein Skimmer, Reactor Pump)
ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
ReefAngel.WaterChangePortsE[0] = Port4Bit | Port6Bit;
//Lights on ports (not sure if I even need to initialiize these since I'm not using them. Leaving it in here for now)
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
//Overheat Ports (Heater-R, Sump Light, LED-R, Heater-M, LED-L, Heater-L, Protein Skimmer, Reactor Pump)
ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port3Bit | Port4Bit | Port6Bit;
// Use T2 (display tank) as Temp Probe, and use T3 (sump) as Overheat probe
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T3_PROBE;
// Ports that are always on
//Gyre Wavemaker
ReefAngel.Relay.On( Port2 );
//Return Pump
ReefAngel.Relay.On( Port3 );
//LED-R
ReefAngel.Relay.On( Port5 );
//LED-L
ReefAngel.Relay.On( Box1_Port1 );
//Reactor Pump
ReefAngel.Relay.On( Box1_Port6 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
//Heater-R
ReefAngel.StandardHeater( Port1 );
//Sump light
ReefAngel.MoonLights( Port4 );
//Heater-M
ReefAngel.StandardHeater( Port6 );
//Alkalinity Doser
ReefAngel.DosingPumpRepeat1( Port7 );
//Calcium Doser
ReefAngel.DosingPumpRepeat2( Port8 );
//ATO solenoid active from 7pm-8pm
ReefAngel.StandardLights(Box1_Port2,19,0,20,0);
//Heater-L
ReefAngel.StandardHeater( Box1_Port3 );
//Protein Skimmer
ReefAngel.Relay.DelayedOn( Box1_Port4 );
//RODI Reservoir solenoid active from 7am - 10am
ReefAngel.StandardLights(Box1_Port5,7,0,10,0);
//Magnesium Doser on every 60 minutes with 10 minute offset for 19 seconds
ReefAngel.DosingPumpRepeat( Box1_Port7,10,60,19 );
//KALK Doser
ReefAngel.DosingPumpRepeat3( Box1_Port8 );
//Check float switches
CheckSwitches();
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "KCReefer" );
ReefAngel.DDNS( "Leonard" ); // Your DDNS is KCReefer-Leonard.myreefangel.com
ReefAngel.ShowInterface();
}
void CheckSwitches() {
static WiFiAlert switchAlert;
// Turn off protein skimmer if skimmate container is full (High ATO)
if (!ReefAngel.HighATO.IsActive()) { // switch on by default
switchAlert.Send("skimmate+level+alarm!+protein+skimmer+disabled.");
ReefAngel.Relay.Override(Box1_Port4,0);
}
//Turn of ATO solenoid if sump water level is high (Low ATO) and not in feeding or water change mode
if(!ReefAngel.DisplayedMenu==FEEDING_MODE && !ReefAngel.DisplayedMenu==WATERCHANGE_MODE){
if(ReefAngel.LowATO.IsActive()) { //swith off by default
switchAlert.Send("sump+full+alarm!+ATO+solenoid+disabled.");
ReefAngel.Relay.Override(Box1_Port2,0);
}
}
}
Re: Turn ports off with float switch activation
Looks like it should work. Does the low switch port change when you flip it manually? Might need some Serial.println and view in monitor to verify if its getting into your if statement. The code looks ok though...
Re: Turn ports off with float switch activation
The low ATO port changes when it is flipped that's why I'm confused because as you said, the code looks like it should work.
I'm going to add some print lines and serial into it once I get a new cable. During the last push of the code, some pins got caught and tore a wire out. I had to take off the case and hold contact between the wire and the pin to push code (since I had the copy paste error for my port 2 loaded onto the controller) I had decided to remap my relays right before it too.
You can imagine how much fun I was having.
Here's what it looks like right now. I could not get it to go back in. I'm not much of an electrical engineer:
http://i.imgur.com/kYiI1VVh.jpg
Image was too large for inline viewing. Too lazy to resize it.
I'm going to add some print lines and serial into it once I get a new cable. During the last push of the code, some pins got caught and tore a wire out. I had to take off the case and hold contact between the wire and the pin to push code (since I had the copy paste error for my port 2 loaded onto the controller) I had decided to remap my relays right before it too.
You can imagine how much fun I was having.
Here's what it looks like right now. I could not get it to go back in. I'm not much of an electrical engineer:
http://i.imgur.com/kYiI1VVh.jpg
Image was too large for inline viewing. Too lazy to resize it.