Get count when relay is on or off

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

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Tue Jan 30, 2018 2:08 pm
Hello,

I'm wondering if there are some ways to count how many times relay is turned on or off in the arduino? For example: when we use temp probes in order to switch on/off heater: if temp less than 25 turn on heater and if more than 26 turn off heater. And if during the day temp drops 3 times and heater is turned on 3 times - so is it possible to calculate such thing and use somewhere else in the code?

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Tue Jan 30, 2018 2:46 pm
You can count for a day and store the data in a custom variable.
It would show up as custom variable.
Roberto.

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Tue Jan 30, 2018 2:51 pm
rimai wrote:You can count for a day and store the data in a custom variable.
It would show up as custom variable.


But how to write such code in order to have such count? If I put code in the loop section when temp is less 25 then add 1 to the count - the count grows each milisecond
Image

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Tue Jan 30, 2018 7:17 pm
You need a variable to control that.
Code: Select all
static boolean control=false;
if (ReefAngel.Relay.IsOn(Port1) && control==false)
{
  control=true;
  ReefAngel.CustomVar[0]++;
}
if (ReefAngel.Relay.IsOff(Port1) && control==true)
{
  control=false;
}
Roberto.

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Wed Jan 31, 2018 12:10 am
Thanks!

By the way is there any possibility to have more custom variables that could be seen in the app? Or at least have some of them as text (not as number)?
Image
User avatar
Posts: 2737
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Wed Jan 31, 2018 5:23 am
custom variables are visible in my android app.

Sent from my XT1585 using Tapatalk

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Wed Jan 31, 2018 5:24 am
rimai wrote:You need a variable to control that.
Code: Select all
static boolean control=false;
if (ReefAngel.Relay.IsOn(Port1) && control==false)
{
  control=true;
  ReefAngel.CustomVar[0]++;
}
if (ReefAngel.Relay.IsOff(Port1) && control==true)
{
  control=false;
}


I'm getting compile error :(

error: 'class RelayClass' has no member named 'IsOn'
error: 'class RelayClass' has no member named 'IsOff'

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Wed Jan 31, 2018 5:43 am
binder wrote:custom variables are visible in my android app.

Sent from my XT1585 using Tapatalk


Only 7 are available and all of them are number which cannot exceed ~300
I would like to have more variables shown on android app or have them as text (as I'm trying to display some information for reporting failures in my reef)
Image

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Wed Jan 31, 2018 6:53 pm
Sorry. Try this:
Code: Select all
static boolean control=false;
if (ReefAngel.Relay.Status(Port1)==true && control==false)
{
  control=true;
  ReefAngel.CustomVar[0]++;
}
if (ReefAngel.Relay.Status(Port1)==false && control==true)
{
  control=false;
}
Roberto.
User avatar
Posts: 2737
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Wed Jan 31, 2018 9:00 pm
Armetas wrote:
binder wrote:custom variables are visible in my android app.

Sent from my XT1585 using Tapatalk


Only 7 are available and all of them are number which cannot exceed ~300
I would like to have more variables shown on android app or have them as text (as I'm trying to display some information for reporting failures in my reef)
Ahhhh... gotcha. the libraries would have to be modified to allow for larger values or to display text instead.
most likely it would have to be additional custom variables added instead of the same ones...or maybe not (at least for getting larger values). the text would require separate variables.

Sent from my XT1585 using Tapatalk
Next

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 3 guests

cron