Power outage alert

User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

So would I have to make a junction between the serial connection or can the master controller feed off the slave if there was a battery set connected to the 5v/gnd lines?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

The master could feed off of the slave, but it is really not designed for that.
The best option I see is to use a small UPC. It will maintain RA long enough for your email alert.
Roberto.
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

Makes sense. I'll just get something like this....http://www.amazon.com/CyberPower-CP425S ... 60&sr=1-17. I was just thinking about the options and a small battery pack is really inexpensive.

-Jon
Treamaya
Posts: 24
Joined: Wed Jul 06, 2011 7:18 pm

Re: Power outage alert

Post by Treamaya »

Any suggestions on how to hook up to a APC battery back up system? I currently have one on both my PC, router and another on the tank. There are 4 outlets (out of 8) on the UPS that are battery backed up. Here is what I am thinking...

-use one of the non-battery backed outlets with the suggested wall wart to indicate loss of power.
-use one battery backed outlet for the RA
-use one battery backed outlet to plug the relay box into
-program the ATO port used to indicate the loss of power, to shut down everything except the return and skimmer (for oxygenation).
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

Yes, that would work great!!
Just make sure not to feed more than 5VDC into the ATO port.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

What kind of wall wart would you suggest? I tried looking a few up but have no idea which one to get or how I would connect it to the pwm port. I would like to integrate this into my controller as well. Do you think this kind of thing might be useful to provide on your guys' online store?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

You can use any regulated 5VDC walwart. The best ones are the ones made for cell phones and have a USB plug in it. USB uses 5VDC as standard.
Get a good quality one or you will end up frying the controller. I've seen them output more than 5VDC.
Roberto.
Treamaya
Posts: 24
Joined: Wed Jul 06, 2011 7:18 pm

Re: Power outage alert

Post by Treamaya »

What about a 3vdc supply? You said not more than 5vdc, so what is the LO threshold that indicates loss of power?

You are very right about the 5Vdc wall warts, I checked several and they were all off. Most were in the 7vdc range. One of my 12vdc supplies was actually at 17vdc!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

3VDC should work too.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

Found a usb charger like you described for an old blackberry. Says 5V output @ 700mA, I'll verify the 5V with a multimeter but assuming its accurate this should work? If both my ATO ports are in use can I use any of the ports on the relay box?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

No :(
It has to be one of the ATO ports.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

Okay, tested out the adapter and it seems to put out around 4.95-5.17 VDC. I'm assuming this will be okay to hookup using my ATO High switch port? That said, could you give an example of code I test if power did fail? For example, I would like it to deactivate port 1 and 2 on the main relay box along with port 3 and 4 on the relay expansion box. Once power is restored I would then like to enable the disabled relays. Thanks in advance!
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

Try this.

On setup():

Code: Select all

digitalWrite(highATOPin,LOW);
Your loop() need to look like this:

Code: Select all

void loop()
{


  // Your code goes above here
  if (!digitalRead(highATOPin))
  {
    ReefAngel.Relay.Off(Port1);
    ReefAngel.Relay.Off(Port2);
    ReefAngel.Relay.Off(Box1_Port3);
    ReefAngel.Relay.Off(Box1_Port4);
  }
  ReefAngel.ShowInterface();
}
ShowInterface() has to be the last line and the check has to be right above it.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

So it looks like I shorted the ATO high port out.

I made sure to connect up the adapter with the correct +/- sides using indications on the existing ATO switch cables. When I hooked up the adapter to the ATO high port my tank lights flashed on and the red status light started blinking. I shut off the adapter (I had it plugged into a surge strip for easy on/off).

Now the ATO high port indicates there's no power going to it, even though the float switch is all the way down. Just to make sure it wasn't the actual float switch, I hooked up the other one and got the same indication. I went ahead and modified my ATO code so that it will at least top the tank off, as I was using the ATO high as a safety in case the pump or something malfunctioned. But I had to take that out, since it registers as open instead of closed keeping the ATO pump from engaging.

Thought I was doing everything right... :(
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

Do you still have this on the setup()?

Code: Select all

digitalWrite(highATOPin,LOW);
If so, you are disabling the port for use as ATO as it is actually using pull-down instead of pull-up.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

No, I reverted back to my old code to make sure it wasn't something that I had done since. Also the RA Client shows the ATO Hi as red, normally it's green since the switch is all the way down making contact.
Here's my code just in case:

Code: Select all

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

#define Daylight            1
#define AutoTopOff          2
#define Heater              3
#define Return              4
#define WavemakerL          5
#define WavemakerR          6
#define LEDs                7
#define Refugium            8
#define AlkDoser            13
#define CaDoser             14
#define AclHeater           17
#define GFO                 18 

void setup()
{
   randomSeed(analogRead(0)); //wm stuff 
    ReefAngel.Init();  //Initialize controller   
    ReefAngel.FeedingModePorts = B00111000;
//    ReefAngel.WaterChangePorts = B00000000;
//    ReefAngel.OverheatShutoffPorts = B00000101;
//    ReefAngel.LightsOnPorts = B00000001;
    // Ports that are always on
    ReefAngel.Relay.On(Return);
    ReefAngel.Relay.On(GFO);
//WaveMaker stuff
    ReefAngel.Timer[1].SetInterval(random(15,35));
    ReefAngel.Timer[1].Start(); 
    ReefAngel.Relay.On(WavemakerL);
}

void loop()
{
    ReefAngel.ShowInterface();
    
//    ReefAngel.StandardFan(Chiller,775,783); Removed for ATO function
//    ReefAngel.StandardHeater(Heater,785,79); 
    ReefAngel.StandardLights(Daylight,10,0,21,00);  //Daylight schedule 10:00am - 9:00pm
    ReefAngel.StandardLights(Refugium,21,0,10,0);  //Refugium schedule 9:00pm - 10:00am
    ReefAngel.StandardLights(LEDs,9,00,22,00);  //LED schedule 9:00am - 10:00pm
    ATOFailSafe(AutoTopOff); //ATO Stuff  
//Heater Temp Settings
// Turn on Heaters when the temp < 78.8 degrees
          if ( ReefAngel.Params.Temp1 < 788 ) ReefAngel.Relay.DelayedOn(Heater, 1);
          // Turn off Heaters when the temp > 78.6 degrees
          if ( ReefAngel.Params.Temp1 >= 791 ) ReefAngel.Relay.Off(Heater);
//Acclimation Heater Temp 2 settings
       // Turn on AclHeater when the temp < 78.8 degrees
          if ( ReefAngel.Params.Temp2 < 788 ) ReefAngel.Relay.DelayedOn(AclHeater, 1);
          // Turn off AclHeater when the temp > 79.1 degrees
          if ( ReefAngel.Params.Temp2 >= 791 ) ReefAngel.Relay.Off(AclHeater);
//Wavemaker
    if ( ReefAngel.Timer[1].IsTriggered() )
      {
        ReefAngel.Timer[1].SetInterval(random(15,30));
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.Toggle(WavemakerL); //port 5
        ReefAngel.Relay.Toggle(WavemakerR); //port 6
       }
//Dose Ca
                   if ( ReefAngel.DisplayedMenu == DEFAULT_MENU ) //Ca Doser - Only works if Main screen is showing
              {
               /* && = and || = or
               Hours between 12am and 8am
               minute must be 0 (top of the hour)
               seconds less than 2 (up to 2 seconds)
               */
               if ( ((hour() >= 0) && (hour() <= 8)) && (minute() == 0) && //dose time
                   (second() < 2) ) //dose duration
               {
                  ReefAngel.Relay.On(CaDoser);
               }
               else
               {
                  ReefAngel.Relay.Off(CaDoser);
               }
            }
  
//Dose Alk
                   if ( ReefAngel.DisplayedMenu == DEFAULT_MENU ) //Alk Doser - Only works if Main screen is showing
              {
               /* && = and || = or
               Hours between 12:05am and 8:05am
               minute must be 0 (top of the hour)
               seconds less than 2 (up to 2 seconds)
               */ 
               if ( ((hour() >= 0) && (hour() <= 8)) && (minute() == 5) && //dose time
                   (second() < 2) ) //dose duration
               {
                  ReefAngel.Relay.On(AlkDoser);
               }
               else
               {
                  ReefAngel.Relay.Off(AlkDoser);
               }
            }  
}

void ATOFailSafe(byte ATO) //changed port to fATO
{
   // Check for the low switch
   /*
   If the Low switch is active, meaning the float is opposite the end with the two wires,
        we are empty so we should turn on the pump.  Otherwise, we are full, so turn off the port.
   */
   if ( ReefAngel.LowATO.IsActive() )
   {
      ReefAngel.LowATO.StartTopping();
      ReefAngel.Relay.On(ATO);
   }
   else
   {
      ReefAngel.LowATO.StopTopping();
      ReefAngel.Relay.Off(ATO);
   }
}
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

PM me if you want to replace.
I went back and read what you wrote and I think the confusion was on the part where you followed the markings on the ATO cable.
The ATO float switches use the same pinout as the PWM output ports.
You can find the pinout in the user manual.
Roberto.
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

Okay, yeah that's def it I'll shoot you a PM.
Image
tkeracer619
Posts: 160
Joined: Thu Nov 24, 2011 9:50 pm
Location: Golden, CO

Re: Power outage alert

Post by tkeracer619 »

Treamaya wrote:
You are very right about the 5Vdc wall warts, I checked several and they were all off. Most were in the 7vdc range. One of my 12vdc supplies was actually at 17vdc!

How about a 5v supply that outputs 30v...

My poor ReefAngel... she didn't deserve that. She didn't do anything to anyone.

:? wallwarts...


Shout out to the creator of our angels... he takes good care of them. Roberto, this next drink is for you. 8-)
Image
chase
Posts: 101
Joined: Fri Sep 16, 2011 8:26 am

Re: Power outage alert

Post by chase »

rimai wrote:PM me if you want to replace.
I went back and read what you wrote and I think the confusion was on the part where you followed the markings on the ATO cable.
The ATO float switches use the same pinout as the PWM output ports.
You can find the pinout in the user manual.
PM Sent
Image
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

I'm wondering, what do you leave on "life support" in case of a power outage and a switch to battery power. I'm thinking that it may not be much more than the RA unit, relay box, & power heads in the tank for circulation as they draw very little power.

-Jon
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

I only leave circulation on.
Roberto.
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

I'm curious if there is a better way to monitor for power. I have it set up on the IO expansion and if it changes from high to low, then the power to most of the relays is turned off. The problem (atleast I think it may be a problem) is that if anything breaks down the connection across the I2C communication, then the system essentially goes into shut down thinking the power feed has dropped. Any thoughts?

Thanks,
Jon
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

Use the ATO port for that
Roberto.
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

Thanks,

I suppose that would be the best way to get around the issue. I didn't do that initailly because I'd then have to code in the logic for the standard ATO if one of them (low or high) was coming from the IO expansion instead of using the ReefAngel.StandardATO function.

-Jon
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

Looking at the StandardATO code a bit in the library, will this work if I receive a signal from the IO expansion for the LowATO? I figure it is best to use that one in case of a communication error as I would rather the sump go low than to overflow.

Thanks,
Jon

Code: Select all

//Set the Low ATO to the IO device, receive IOLowATO = 1 or 0
	byte IOLowATO = 0;
//Temp timeout
        unsigned long TempTimeout = ATOTimeout;
	TempTimeout *= 1000;
	/*
	Is the low switch active (meaning we need to top off) and are we not currently topping off
	Then we set the timer to be now and start the topping pump
	*/
    if (IOLowATO == 1)
    {
        ReefAngel.LowATO.Timer = millis();
        ReefAngel.LowATO.StartTopping();
        ReefAngel.Relay.On(Box1_Port1);  //ATO pump on Box1 Port 1
    }
// If the high switch is activated
    if ( ReefAngel.HighATO.IsActive() )
    {
		ReefAngel.Relay.Off(Box1_Port1);
    }
    /*
    If the current time minus the start time of the ATO pump is greater than the specified timeout value
    AND the ATO pump is currently running:
    We turn on the status LED and shut off the ATO pump
    This prevents the ATO pump from contniously running.
    */
	if ( (millis()-LowATO.Timer > TempTimeout) && IOLowATO==1 )
	{
		ReefAngel.LED.On();
		ReefAngel.Relay.Off(Box1_Port1);
        }
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

I don't think so.
IOLowATO would always be 0 in that code.
Roberto.
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Power outage alert

Post by jsclownfish »

Maybe I oversimplified trying to limit the post. It would be broken up like this. The status of the lowATO should come from the I/O..

Code: Select all

//Set the Low ATO to the IO device, receive IOLowATO = 1 or 0
   byte IOLowATO = 0;
//Temp timeout
   unsigned long TempTimeout = ATOTimeout;
   TempTimeout *= 1000;

void setup()
.....
void loop()
.....
   GetFlow();
   /*
   Is the low switch active (meaning we need to top off) and are we not currently topping off
   Then we set the timer to be now and start the topping pump
   */
    if (IOLowATO == 1)
    {
        ReefAngel.LowATO.Timer = millis();
        ReefAngel.LowATO.StartTopping();
        ReefAngel.Relay.On(Box1_Port1);  //ATO pump on Box1 Port 1
    }
// If the high switch is activated
    if ( ReefAngel.HighATO.IsActive() )
    {
      ReefAngel.Relay.Off(Box1_Port1);
    }
    /*
    If the current time minus the start time of the ATO pump is greater than the specified timeout value
    AND the ATO pump is currently running:
    We turn on the status LED and shut off the ATO pump
    This prevents the ATO pump from contniously running.
    */
   if ( (millis()-LowATO.Timer > TempTimeout) && IOLowATO==1 )
   {
      ReefAngel.LED.On();
      ReefAngel.Relay.Off(Box1_Port1);
        }
void GetFlow()
{
  Wire.requestFrom(7,8);
  if(Wire.available())
  {
    for (int a=0;a<10;a++)
      IOIn[a]=Wire.read();
  }
  Flow0=(IOIn[1]<<8)+IOIn[2];
  Flow1=(IOIn[3]<<8)+IOIn[4];
  Power=IOIn[5];
  Overflow=IOIn[6];
  Reservoir=IOIn[7];
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Power outage alert

Post by rimai »

I think it works.
Roberto.
greydmv
Posts: 3
Joined: Sat May 05, 2012 8:06 pm

Re: Power outage alert

Post by greydmv »

How did this turn out? I am very interested in this.
Post Reply