Logging some things

Do you have a question on how to do something.
Ask in here.
Post Reply
lucho
Posts: 80
Joined: Fri Mar 02, 2012 8:11 am

Logging some things

Post by lucho »

Hi, I am trying to log the number of seconds that my ATO, and my dosing pumps are on, and then show them as custom variables. For the ATO, I am trying to get this to be cummulative for a day, and record the last 3 days (3 variables). Basically every midnight it should store that day's number into a different variable and the prior day's number into another.

It is not working, though. I am getting my "ATOcount" variable to show lower numbers instead of higher numbers until I get to midnight. I am not sure what is wrong. Here is the code for the logging:

Defining the variables in the global section, and the custom variables:

// Place global variable code below here
int tiempo=now();
int ATOcount=0;
int DP1count=0;
int DP2count=0;

// Define Portal Variables
#define Var_DTime 0
#define Var_LogATO 1
#define Var_LogATO2 2
#define Var_LogATO3 3
#define Var_LogDP1 4
#define Var_LogDP2 5


The logging function:

void logging()
{
if (tiempo != now()) {
if (ReefAngel.Relay.Status(ATOPump)) {
ATOcount++;
ReefAngel.CustomVar[Var_LogATO]=ATOcount;
}
if (ReefAngel.Relay.Status(DPump1)) {
DP1count++;
ReefAngel.CustomVar[Var_LogDP1]=DP1count;
}
if (ReefAngel.Relay.Status(DPump2)) {
DP2count++;
ReefAngel.CustomVar[Var_LogDP2]=DP2count;
}
tiempo = now();
}
if (now()%SECS_PER_DAY==0) {
ReefAngel.CustomVar[Var_LogATO3]=ReefAngel.CustomVar[Var_LogATO2];
ReefAngel.CustomVar[Var_LogATO2]=ATOcount;
ATOcount = 0;
ReefAngel.CustomVar[Var_LogATO]=ATOcount;
}
}


Thanks!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Logging some things

Post by lnevo »

The custom variables only accept a byte and you are using an int to store them. This will cause it to wrap from 255 back to 0. You need to store maybe minutes instead in the custom variable. I use ml in those variables, take a look at LogDosing function in my INO to see how I'm logging it.
lucho
Posts: 80
Joined: Fri Mar 02, 2012 8:11 am

Re: Logging some things

Post by lucho »

Thanks Lee. I also realizes that y needed to use long and not int for the tiempo variable, so that it could record the full now(). I split the info into 2 variables, one for min and one for seconds. That should work for now and I still have unused custom variables. I may not need to monitor this as closely in the future, though
Post Reply