Page 1 of 1

Cannot Calibrate Water Level Sensor

Posted: Fri Mar 04, 2016 1:16 am
by hnnhflns
As the title suggests, we cannot get the water level sensor to calibrate. We have read through every water level sensor post for the past 2 years, but still nothing works. Setting the 0 value for the sensor goes off without a hitch, but when the sensor is lowered into the water to set the 100 value, there is no reading on the sensor (ie the value does not change as the sensor is submerged.

There was a slight hiccough with the SoftwareSerial library that was not allowing the code to compile at first, but updating SoftwareSerial.cpp solved that problem. I saw another suggestion to update or change the RA_Joystick.h, but I haven't been able to find that library in the RA Program Files.

Any other suggestions or solutions? We are trying to set-up our ATO system.
Also, where is the RA_Joystick library located in the Program Files so that I can update it?
Reinstalling the Arduino software did not update the libraries, it only set us backwards so I have to go back and at least update the SoftwareSerial library.

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


// Define Relay Ports by Name
#define DT_Pump            1
#define Heater             2
#define UV                 3
#define Swabbie            4
#define Ozone_Pump         5
#define Skimmer            6
#define Fan                7
#define Frag_Tank          8

#define Kalkwasser         Box1_Port1
#define Desk_Can_Lights    Box1_Port2
#define DT_White           Box1_Port3
#define DT_Blue            Box1_Port4
#define Powerheads         Box1_Port5
#define Refuge_Light       Box1_Port6
#define Moonlights         Box1_Port7
#define ATO_Pump           Box1_Port8

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

// Does not need to be global.
// unsigned long ATOUpdate=0;

static time_t LastATO=millis();    // For de-bounced ATO


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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddORPExpansion();  // ORP Expansion Module
    ReefAngel.AddPHExpansion();  // pH Expansion Module
    ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit;
    ReefAngel.FeedingModePortsE[0] = Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit;
    ReefAngel.WaterChangePortsE[0] = Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port8Bit;
    ReefAngel.LightsOnPortsE[0] = Port3Bit | Port4Bit | Port6Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port5Bit | Port6Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port6Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 835 );
    //Set Standard Menu
    ReefAngel.AddStandardMenu();
    //Webserver Authentication
    ReefAngel.Network.WifiAuthentication("hnnhflns");
    //DDNS Server
    ReefAngel.DDNS("300");
    

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port5 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port2,765,768 );
    ReefAngel.Relay.DelayedOn( Port3,10 );
    ReefAngel.DosingPumpRepeat( Port4,0,480,60 );
    ReefAngel.StandardLights( Port5,9,0,14,0 );
    ReefAngel.Relay.DelayedOn( Port6,10 );
    ReefAngel.StandardFan( Port7,808,810 );
    ReefAngel.StandardLights( Port8,0,0,8,0 );
    ReefAngel.StandardLights( Box1_Port3,14,0,22,0 );
    ReefAngel.StandardLights( Box1_Port4,11,0,23,59 );
    ReefAngel.StandardLights( Box1_Port6,23,0,0,0 );
    ReefAngel.StandardLights( Box1_Port7,23,0,1,0 );
          // *******************  Debounced ATO code. Activate ATO no more than every 30 seconds.  *******************
//if (ReefAngel.WaterLevel.GetLevel(0) < 34) LastATO=millis();    // Start a timer
//if (millis()-LastATO<30000 && millis()-LastATO>10)     // Has it been less than 30,000 ms? (30 secs)
//  ReefAngel.Relay.Off(ATO_Pump);                         // If so, make sure the topoff pump is off
//  else
    ReefAngel.WaterLevelATO( Box1_Port8,ATO_Pump,600,75,90 );                     // Otherwise, use the normal topoff routine.
  
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( Constant,50,10 );
    ReefAngel.DCPump.DaylightChannel = None;
    ReefAngel.DCPump.ActinicChannel = None;
    ReefAngel.DCPump.ExpansionChannel[0] = None;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = None;
    ReefAngel.DCPump.ExpansionChannel[5] = None;
    
          //Mix Kalkwasser
static unsigned long Kalk_Mixing = 0;

static unsigned long stopTime = 0;
static byte prevWL=0;

if (ReefAngel.WaterLevel.GetLevel(1)==100 && prevWL<100) {
  stopTime=now()+7200; // Get time one hour from now.
}
prevWL = ReefAngel.WaterLevel.GetLevel(1); // Store the water level

if (now() < stopTime) { ReefAngel.Relay.On(Kalkwasser); } else { ReefAngel.Relay.Off(Kalkwasser); } 
  

  // Delay WL ATO after water change
  static time_t wcTimer=0;
  if (ReefAngel.DisplayedMenu == WATERCHANGE_MODE) wcTimer=now();

     
      // First 10 minutes after WC disable ATO
  if (now()-wcTimer >= 0 && now()-wcTimer < 600)
    ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);
    
  // Disable ATO if ATO High IsActive()
  if (ReefAngel.HighATO.IsActive()) 
    ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);
    
    
    


    ////// Place your custom code below here
    
    
     //Beginning of Jebao Control through Actinic and Daylight ports.
    if (hour()<1 || hour()>=8) 
    {
        ReefAngel.PWM.SetActinic(20);
        ReefAngel.PWM.SetDaylight(20);
    }
    else if (hour()>=8 && hour()<15)
    {
      ReefAngel.PWM.SetDaylight( TidalSwellMode(30,true) ); // Tidal Swell at 40% on sync mode
      ReefAngel.PWM.SetActinic( TidalSwellMode(30,false) ); // Tidal Swell at 40% on anti-sync mode
    }
    else if (hour()>=15 && hour()<17)
    {
      ReefAngel.PWM.SetDaylight( ReefCrestMode(100,85,true) ); // ReefCrest at 100% + - 85 on sync mode
      ReefAngel.PWM.SetActinic( ReefCrestMode(100,85,false) ); // ReefCrest at 100% + - 85 on anti-sync mode
    }
    else if (hour()>=17 && hour()<19)
    {
      ReefAngel.PWM.SetDaylight( NutrientTransportMode(90,100,2000,true) ); // Nutrient Transport on sync mode
      ReefAngel.PWM.SetActinic( NutrientTransportMode(90,100,2000,false) ); // Nutrient Transport on anti-sync mode
    }
    else if (hour()>=19 && hour()<21)
    {
      ReefAngel.PWM.SetDaylight( ReefCrestMode(100,85,true) ); // ReefCrest at 100% + - 85 on sync mode
      ReefAngel.PWM.SetActinic( ReefCrestMode(100,85,false) ); // ReefCrest at 100% + - 85 on anti-sync mode
    }
    else if (hour()>=21 && hour()<22)
    {
      ReefAngel.PWM.SetDaylight( ElseMode(100,85,true )); // ElseMode on sync mode, 100 +/- 85%
      ReefAngel.PWM.SetActinic( ElseMode(100,85,false )); // ElseMode on sync mode, 100 +/- 85%
    }
    else if (hour()>=22 && hour()<23)
    {
      ReefAngel.PWM.SetDaylight( TidalSwellMode(80,true) ); // Tidal Swell at 40% on sync mode
      ReefAngel.PWM.SetActinic( TidalSwellMode(80,false) ); // Tidal Swell at 40% on anti-sync mode
    }
    else if (hour()>=23 && hour()<1)
    { 
      ReefAngel.PWM.SetDaylight( LongPulseMode(0,20,10,true) ); // Long pulse at 20% with 10s pulse on sync mode
      ReefAngel.PWM.SetActinic( LongPulseMode(0,20,10,false) ); // Long pulse at 20% with 10s pulse on anti sync mode
    }
    //End of Jebao Control
    
    

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

    // This should always be the last line
    ReefAngel.Portal( "hnnhflns" );
    ReefAngel.DDNS( "300" ); // Your DDNS is hnnhflns-300.myreefangel.com
    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();

    // Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,57, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,57, ReefAngel.WaterLevel.GetLevel() );

ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,66,66, "WL 1:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel(1) );

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 104, TempRelay);
    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}






Re: Cannot Calibrate Water Level Sensor

Posted: Sat Mar 05, 2016 5:28 pm
by rimai
You shouldn't need to change anything if you are using the latest libraries v1.1.3

Re: Cannot Calibrate Water Level Sensor

Posted: Sat Mar 05, 2016 7:58 pm
by hnnhflns
I am almost positive the unit is no good. It seemed to be the issue cause ming our relays to flicker uncontrollably. With it disconnected there were no issues with it plugged in the relays would randomly flicker on and off while the display would say the ports were staying constant either off or on.

We tried completely uninstalling the Reef Angel wizard the reinstalled it. Reprogrammed the code multiple times. I tried it plugged directly into three different relays also tried it in the USB expansion. It never registered any value change it always said 0 on all four water level channels. Both with the probe out of water and submerged. Even if left it for 20 mins the value never changes.

I am going to be down your way next week maybe we can meet up. I want to buy a reef Angel plus board for another controller I have.