checkpower weird issue

Do you have a question on how to do something.
Ask in here.
Post Reply
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

checkpower weird issue

Post by sabo »

I'm trying to get my RA to turn off my main light when the power goes out. It works as expected, but when I plug my ethernet module into my RA it turns off the light. im quite baffled why this is happening. The only thing I need to turn off is the light, as all the other ancillary equepment is on the second relay box.

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>
#include <WiFiAlert.h>

// Define Custome Memory Locations

#define Mem_B_SkimmerWL      100
#define Mem_B_PHDayPower     101
#define Mem_B_PHNightPower   102
#define Mem_B_PHDuration     103
#define Mem_I_ChillerPumpT   104
#define Mem_B_CPumpMax       106
#define Mem_B_CPumpMin       107

////// Place global variable code below here

#define Return       1
#define Pwm_Exp      2
#define ATI          3
#define Modem        4
#define Jebao1_Rhs   5
#define Jebao2_Rhs   6
#define Jebao1_Lhs   7
#define Jebao2_Lhs   8

#define ATO         Box1_Port1
#define Fuge_Led    Box1_Port2
#define Heater1     Box1_Port3
#define Skimmer     Box1_Port4
#define Heater2     Box1_Port5
#define Kamoar      Box1_Port6
#define Swabby      Box1_Port7
#define CPump       Box1_Port8

////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature
    
    ReefAngel.AddStandardMenu();  // Add Standard Menu

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    ReefAngel.FeedingModePortsE[0] = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    ReefAngel.WaterChangePortsE[0] = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port4Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port5Bit;
    // Use T2 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );


    // Ports that are always on
    ReefAngel.Relay.On( Pwm_Exp );
    ReefAngel.Relay.On( Return );
    ReefAngel.Relay.On( Kamoar );
    ReefAngel.Relay.On( CPump );
    ReefAngel.Relay.On( Modem );

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

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

void loop()
{
    ReefAngel.DayLights( Fuge_Led );
    ReefAngel.Relay.DelayedOn( Skimmer );
    ReefAngel.StandardHeater( Heater1 );
    ReefAngel.StandardHeater( Heater2 ); 
    ReefAngel.WaterLevelATO( ATO );
    

    ////// Place your custom code below here
    
    //////CheckPower();
    
    static boolean powerOutage=false;
    static WiFiAlert powerAlert;

  // Power Outage - turn off everything
    if (ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) // Expansion Relay present
    {
      ReefAngel.Relay.On( ATI );
    }
    else
    {
      ReefAngel.Relay.Off( ATI );
      powerOutage=true;
      powerAlert.Send("Power+out!");
    }
    
   /////// if (ReefAngel.WaterLevel.GetLevel() < InternalMemory.read(Mem_B_SkimmerWL) ) ReefAngel.Relay.Override(Skimmer, 0);
    
    if (ReefAngel.LowATO.IsActive())
      {
        ReefAngel.Relay.On(Skimmer);
      }
     else
      {
        ReefAngel.Relay.Off(Skimmer);
      }
      
    ReefAngel.DosingPumpRepeat1(Swabby);
    
   /* if (ReefAngel.Params.Temp[T2_PROBE] < InternalMemory.read(Mem_I_ChillerPumpT))  //if temp less that set temp, chiller
      {                                                                             //pump to idle, otherwise set power
         ReefAngel.PWM.SetChannel(5, InternalMemory.read(Mem_B_CPumpMin) );
      }
    else
      {
         ReefAngel.PWM.SetChannel(5, InternalMemory.read(Mem_B_CPumpMax) );
      }*/
         
    if (hour()>=6 && hour()<12)
      {
         ReefAngel.PWM.SetDaylight( ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
         ReefAngel.PWM.SetActinic( ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
         ReefAngel.Relay.Off( Jebao1_Lhs );
         ReefAngel.Relay.Off( Jebao2_Lhs );
         ReefAngel.Relay.On( Jebao1_Rhs );
         ReefAngel.Relay.On( Jebao2_Rhs );
      }
    else if (hour()>=12 && hour()<18)
      {
        ReefAngel.PWM.SetChannel( 0, ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetChannel( 1, ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Rhs );
        ReefAngel.Relay.Off( Jebao2_Rhs );
        ReefAngel.Relay.On( Jebao1_Lhs );
        ReefAngel.Relay.On( Jebao2_Lhs );
      }
    else if (hour()>=18 && hour()<24)
      {
        ReefAngel.PWM.SetDaylight( ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetActinic( ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Lhs );
        ReefAngel.Relay.Off( Jebao2_Lhs );
        ReefAngel.Relay.On( Jebao1_Rhs );
        ReefAngel.Relay.On( Jebao2_Rhs );
      }
    else
      {
        ReefAngel.PWM.SetChannel( 0, ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetChannel( 1, ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Rhs );
        ReefAngel.Relay.Off( Jebao2_Rhs );
        ReefAngel.Relay.On( Jebao1_Lhs );
        ReefAngel.Relay.On( Jebao2_Lhs );
      }


    ////// Place your custom code above here

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

/////  void CheckPower() {
    
///// }
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: checkpower weird issue

Post by sabo »

After a bit of fiddling, I don't think its the Ethernet module. It started flicking on and off after a while. Then I tried a different port on my USB expansion for the relay and it appears to be behaving. I've had problems with my water level module reading all over the place and it seemed to be related to the USB expansion too. I'm starting to think it may be a bit dodgy. Is it a standard USB expansion like you can get at electronics shops? I'd like to try another one to see if fixes a few niggling issues I've had since day dot. My expansion relay box cycles some relays very quickly, plus the other things has me thinking the USB expansion is causing all of it as its the common denominater.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: checkpower weird issue

Post by sabo »

Bleh. And when I turn the power off my RA doesn't seem to like the power from the inverter and loops at boot and resets with one relay clicking. Its a sinewave 300w inverter so I don't know why it isn't working.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: checkpower weird issue

Post by sabo »

No one?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: checkpower weird issue

Post by lnevo »

Ethernet module or wifi? Might be a conflict with that. Not many are using it.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: checkpower weird issue

Post by sabo »

I'm thinking its the USB expansion. When I first uploaded the code I couldn't understand why it wasn't working. Turns out the relay that my light is on appears to be stuck on. I can't turn it off with the app either. So I moved it to another spot and the check power function works as expected. However if I move wires the light goes off so I'm presuming the expansion loses communication. This and the fact my water level module plays up leads me to think the USB expansion is faulty/noisy. Will a standard USB hub work?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: checkpower weird issue

Post by lnevo »

No it wont work with a usb hub.
Post Reply