Power outage detection?

Basic / Standard Reef Angel hardware
Post Reply
Kungpaoshizi
Posts: 52
Joined: Wed Sep 16, 2015 8:12 am

Power outage detection?

Post by Kungpaoshizi »

Is there a power outage solution for RA? (at least some way to detect the power has gone out if everything were on a ups)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Power outage detection?

Post by cosmith71 »

Yep.

You need an expansion relay box.

Plug your RA into a UPS. Plug the expansion relay box into the wall. This works by detecting when the expansion relay looses power and isn't seen anymore.

Here's how I do the code. I have it as a separate function. You'll need to edit to fit your particular setup.

Put this up in globals somewhere:

Code: Select all

boolean powerOutage=false;    // For power outage code
Put this near the end of your loop. It needs to be after anything it might affect or it won't work right.

Code: Select all

  CheckPower();    // Check for power outage and take appropriate measures.  Needs to be near the end to override everything else.
Now, put this at the very end of your code, past the final }, outside of loop, outside of everything.

Code: Select all

void CheckPower() {
  // Power Outage - turn off everything
  if (!ReefAngel.Relay.IsRelayPresent(0)) // Expansion Relay NOT present because it's not hooked up to UPS and power is out.
  {
    powerOutage=true;    // Set a flag

    // Replace all this stuff with what you want to do when the power is off
    ReefAngel.Relay.Off(Heater);    // Turn all this stuff OFF
    ReefAngel.Relay.Off(Skimmer); 
    ReefAngel.Relay.Off(Return); 
    ReefAngel.Relay.Off(Fuge); 
    ReefAngel.Relay.Off(Swabbie); 
    ReefAngel.Relay.Off(CanopyFans);
    ReefAngel.Relay.Off(Fan);
    ReefAngel.PWM.SetChannelRaw(Blues,0);    // Turn off Blues on PWM Expansion.
    ReefAngel.PWM.SetChannelRaw(Whites,16);   // Set Whites to minimal as a visual indicator.  Uses minimal power.

    ReefAngel.DCPump.UseMemory = false;      // Turn off memory/portal control of powerheads
    ReefAngel.DCPump.SetMode(Constant,30,0); // and set them to a constant 30 for emergency circulation.
  }
  // Power Restored - Turn things back on
  if (powerOutage && ReefAngel.Relay.IsRelayPresent(0))    // Has there been an outage, and is the expansion relay there again?
  {
    powerOutage=false;               // Clear the flag

    // Replace this stuff with what you need to turn back on when the power returns.
    ReefAngel.Relay.On(Skimmer);     // Turn always on things back on
    ReefAngel.Relay.On(Return);      // Everything else will return to automatic control
  }
  // If there has been no power outage, nothing happens at all.
}
Let me know if you need more assistance with this. :mrgreen:
Kungpaoshizi
Posts: 52
Joined: Wed Sep 16, 2015 8:12 am

Re: Power outage detection?

Post by Kungpaoshizi »

Does the RA work ok with modified sine or does it require a pure since wave ups?
Still determining which route to go..
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Power outage detection?

Post by cosmith71 »

I have a cheap APC UPS (certainly not sine wave) with Jebao pumps and LED's and it seems to work fine.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Power outage detection?

Post by lnevo »

Modified sine works fine for the RA but not for my return pump, so I swapped out the UPC
Post Reply