Logging some things

Do you have a question on how to do something.
Ask in here.

Posts: 80
Joined: Fri Mar 02, 2012 8:11 am
PostPosted: Wed Sep 17, 2014 8:21 pm
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)) {
if (ReefAngel.Relay.Status(DPump1)) {
if (ReefAngel.Relay.Status(DPump2)) {
tiempo = now();
if (now()%SECS_PER_DAY==0) {
ATOcount = 0;

User avatar
Posts: 5420
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Sep 18, 2014 3:40 am
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.

Posts: 80
Joined: Fri Mar 02, 2012 8:11 am
PostPosted: Thu Sep 18, 2014 7:25 am
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

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 1 guest