New Code Not Running After Upload?

Basic / Standard Reef Angel hardware
Post Reply
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

New Code Not Running After Upload?

Post by Piper »

I'm running into an odd problem this morning and can't figure out what I'm doing wrong. I've uploaded new code via Remote Upload from the Wizard. I've done this a dozen or more times this morning trying to get something working. After a little testing, I think my new code is not actually making it through. The RA* beeps like it received the new code but my changes do not seem to be taking effect. I finally figured this out by statically setting ReefAngel.CustomVar[5] = 35; Earlier this morning I had it set to ReefAngel.CustomVar[5] = ReefAngel.Params.Temp[4]; It's still reporting the temp in the uapp which leads me to believe it's not taking the code. Am I losing my marbles here? And I overlooking something really simple maybe:

Here's the code I just uploaded a few minutes ago. I heard the controller beep like it received the code. I'm still seeing the temp fluctuate on custom var 5.

Code: Select all

#include <Salinity.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_TS.h>
#include <RA_TouchLCD.h>
#include <RA_TFT.h>
#include <RA_TS.h>
#include <Font.h>
#include <RA_Wifi.h>
#include <RA_Wiznet5100.h>
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_ATO.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 <RA_CustomLabels.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <PAR.h>
#include <DCPump.h>
#include <ReefAngel.h>
#include <SoftwareSerial.h>

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

//*************************************************************
// Define relay box ports
// Relay Box #1
#define  ControllerLight    Box1_Port1
#define  Skimmer            Box1_Port2
#define  SumpLight          Box1_Port3
#define  RedSea_Doser       Box1_Port4
#define  ReturnPump         Box1_Port5
#define  Heater             Box1_Port6
#define  RedSea_ATO         Box1_Port7
#define  Sump_PowerHead     Box1_Port8

// Relay Box #2 - No longer working in code

// Relay Box #3
#define  PowerHead1         Box3_Port1
#define  T5_Actinic         Box3_Port2
#define  PowerHead2         Box3_Port3
#define  Kessil_A           Box3_Port4
#define  Kessil_B           Box3_Port5
#define  Kessil_C           Box3_Port6
#define  Kessil_D           Box3_Port7
#define  Fans               Box3_Port8

#define  skimmate_locker    3


#define CUSTOM_VARIABLES

////// Place global variable code above here
byte DaylightOffset = InternalMemory.ActinicOffset_read();
int onTime          = NumMins(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read())+DaylightOffset;
int offTime         = NumMins(InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read())-DaylightOffset;


/*

2021-01-25 :: Testing using internal momory for lighting

*/

void setup() {
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Star();
    
    ReefAngel.AddMultiChannelWaterLevelExpansion();
    ReefAngel.AddExtraTempProbes();
    
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePortsE[0] = Port2Bit | Port5Bit;
    ReefAngel.FeedingModePortsE[2] = Port1Bit | Port3Bit;
 
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePortsE[0] = Port2Bit | Port5Bit;
    ReefAngel.WaterChangePortsE[2] = Port1Bit | Port3Bit;
 
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPortsE[0] = Port6Bit;
    ReefAngel.OverheatShutoffPortsE[2] = Port2Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit;
 
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit;
    ReefAngel.LightsOnPortsE[2] = Port2Bit | Port4Bit | Port5Bit | 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(830);

    // Ports that are always on
    // Box 1
    ReefAngel.Relay.On(RedSea_ATO);
    ReefAngel.Relay.On(RedSea_Doser);
    ReefAngel.Relay.On(Sump_PowerHead);
    ReefAngel.Relay.On(ReturnPump);
    
    // Box 3
    ReefAngel.Relay.On(PowerHead1);
    ReefAngel.Relay.On(PowerHead2);

    // I/O Module Testing
    //for (int IO_channel = 0; IO_channel < 6; IO_channel++) {
    //    ReefAngel.CustomVar[IO_channel] = ReefAngel.IO.GetChannel(IO_channel);
    //}
    
    ReefAngel.CustomVar[0] = InternalMemory.ActinicOffset_read();
    ReefAngel.CustomVar[1] = InternalMemory.StdLightsOnHour_read();
    ReefAngel.CustomVar[2] = InternalMemory.StdLightsOnMinute_read();
    ReefAngel.CustomVar[3] = InternalMemory.StdLightsOffHour_read();
    ReefAngel.CustomVar[4] = InternalMemory.StdLightsOffMinute_read();
    ReefAngel.CustomVar[5] = 35;
}

void loop() {
    ReefAngel.Relay.DelayedOn(Skimmer,5);

    ReefAngel.StandardLights(T5_Actinic, DaylightOffset);
    ReefAngel.StandardLights(Kessil_A);
    ReefAngel.StandardLights(Kessil_B);
    ReefAngel.StandardLights(Kessil_C, onTime/60, onTime%60, offTime/60, offTime%60);
    ReefAngel.StandardLights(Kessil_D, onTime/60, onTime%60, offTime/60, offTime%60);

    ReefAngel.StandardHeater(Heater);

    //ReefAngel.DosingPumpRepeat1(CalDoser);
    //ReefAngel.DosingPumpRepeat2(AlkDoser);
    //ReefAngel.DosingPumpRepeat3(MagDoser);

    ReefAngel.StandardFan(Fans);

    if (!daylightsOn()) {   // Night mode
        ReefAngel.PWM.SetDaylight2(MoonPhase()/2);
        ReefAngel.PWM.SetActinic2(MoonPhase()/2);
    } else {
        ReefAngel.PWM.SetDaylight2(10);
        ReefAngel.PWM.SetActinic2(10);
    }

    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    
    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;

 
    if (ReefAngel.DisplayedMenu != FEEDING_MODE || ReefAngel.DisplayedMenu != WATERCHANGE_MODE) {
        if (!daylightsOn()) {   // Night mode - lower the flow
            ReefAngel.DCPump.UseMemory = false;
            ReefAngel.DCPump.SetMode(ReefCrest,45,10);
        }
        //if (now()%SECS_PER_HOUR<10*SECS _PER_MINUTE) { //put ato code here } else { // put relay off here }
        //else if (now()%(2*SECS_PER_HOUR)<(5*60*1000)) {  // Run NutrientTransport mode every two hours for 5 minutes
        //    ReefAngel.DCPump.UseMemory = false;
        //    ReefAngel.DCPump.SetMode(NutrientTransport,90,30);
        //}
        else {
            ReefAngel.DCPump.UseMemory = true;
        }
    }

    boolean buzzer=false;
    if (ReefAngel.isOverheat()) buzzer=true;
    if (ReefAngel.isBusLock()) buzzer=true;
    if (buzzer) ReefAngel.BuzzerOn(2); else ReefAngel.BuzzerOff();
    
    
    // Lights under stand
    if (!ReefAngel.IO.GetChannel(5)) {
        ReefAngel.Relay.On(SumpLight);
    } else {
        ReefAngel.Relay.Off(SumpLight);
    }
    if (ReefAngel.IO.GetChannel(4)) {
        ReefAngel.Relay.On(ControllerLight);
    } else {
        ReefAngel.Relay.Off(ControllerLight);
    }

    // Shut off the skimmer if the skimmate locker is full
    if (ReefAngel.IO.GetChannel(3)) {
        ReefAngel.Relay.On(Skimmer);
    } else {
        ReefAngel.Relay.Off(Skimmer);
    }

    // Feeding Mode Button
    //if (!ReefAngel.IO.GetChannel(2) && ReefAngel.DisplayedMenu != FEEDING_MODE) {
    //    ReefAngel.FeedingModeStart();  
    //}

    // If the feeding mode button is pressed:
    ReefAngel.CustomVar[7] = ReefAngel.IO.GetChannel(2);
    ReefAngel.CustomVar[6] = ReefAngel.DisplayedMenu;
    if (!ReefAngel.IO.GetChannel(2) && ReefAngel.DisplayedMenu != FEEDING_MODE) {
        ReefAngel.FeedingModeStart();
    }
    

    ////// Place your custom code below here


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

    ReefAngel.Network.Cloud();
    // This should always be the last line
    ReefAngel.ShowTouchInterface();
}

// *****************************************************************************
// * Utility Functions
// *****************************************************************************

boolean lightsAreOn () {
  return actinicsOn() || daylightsOn();
}

boolean actinicsOn () {
  return ReefAngel.Relay.Status(T5_Actinic);
}

boolean daylightsOn () {
  return ReefAngel.Relay.Status(Kessil_A);
}

// RA_STRING1=...
// RA_STRING2=null
// RA_STRING3=null
User avatar
brennyn21
Posts: 83
Joined: Mon Nov 23, 2020 5:40 pm

Re: New Code Not Running After Upload?

Post by brennyn21 »

Check your SD card in your reefangel it probably went bad. If you have a spare one try swapping it out. You can remove it and insert it into your PC and if your PC isn't able to read it then it's definitely gone bad.
Sincerely, Brennyn
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: New Code Not Running After Upload?

Post by Piper »

No luck there. The old card reads/writes fine on the laptop. Also tried a new card. Still sounds like it's updating but it's not taking the code.
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: New Code Not Running After Upload?

Post by Piper »

I plugged in to the RA* via USB cable and uploaded that way and it took.
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: New Code Not Running After Upload?

Post by Piper »

It might have something to do with the Cloud Hub. I had that plugged into the laptop earlier today. I unplugged it before uploading the most recent time and it took. I'll test that out more later this weekend.
User avatar
brennyn21
Posts: 83
Joined: Mon Nov 23, 2020 5:40 pm

Re: New Code Not Running After Upload?

Post by brennyn21 »

That is very odd, I had the same issue with my star, where it would download the new firmware and then reboot but never install the new firmware. My issue was the SD Card. Make sure the SD Card is formatted as FAT format.
Sincerely, Brennyn
Post Reply