Get count when relay is on or off

Do you have a question on how to do something.
Ask in here.
Post Reply
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Get count when relay is on or off

Post by Armetas »

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?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Get count when relay is on or off

Post by rimai »

You can count for a day and store the data in a custom variable.
It would show up as custom variable.
Roberto.
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Get count when relay is on or off

Post by rimai »

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.
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

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
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Get count when relay is on or off

Post by binder »

custom variables are visible in my android app.

Sent from my XT1585 using Tapatalk
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

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'
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Get count when relay is on or off

Post by rimai »

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.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Get count when relay is on or off

Post by binder »

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
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

rimai wrote: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;
}
Thank you. It works perfectly ;)
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

binder wrote:
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
Is there a way who could change the libraries for such purpose. And how about android app? Will it handle longer variables? Or even text?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Get count when relay is on or off

Post by binder »

Armetas wrote:
Is there a way who could change the libraries for such purpose. And how about android app? Will it handle longer variables? Or even text?
yes, it is possible to change the libraries around to do this. what i would suggest is creating a separate discussion topic/thread that we can discuss it in more detail of what you are wanting to accomplish. then we can create a testing branch for the libraries to test out functionality. if all goes well, then the changes could get merged into the main branch of the libraries.
then i could find some time to create a special build of my android app to help test and display the variables.
so that’s how i would suggest handling this so there’s a clear, open discussion on what is desired and we can move forward from there.


Sent from my iPad using Tapatalk
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Get count when relay is on or off

Post by rimai »

Why don't you just use alert emails for that?
You can type anything on email alerts.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Get count when relay is on or off

Post by binder »

and yes, roberto’s idea would be the simplest and easiest to do.

one issue with sending text is the size. the more text on the controller, the bigger the code and harder it is to maintain. you are also limited with the options and changing them is harder. the email alerts are changed much easier without modifying the libraries.


Sent from my iPad using Tapatalk
Armetas
Posts: 82
Joined: Sat Mar 29, 2014 1:55 pm

Re: Get count when relay is on or off

Post by Armetas »

rimai wrote:Why don't you just use alert emails for that?
You can type anything on email alerts.
But email alerts are outside the controller. Im writing code in the arduino ir order to track some things to catch when there is a problem and even now my all custom variables are fully occupied, im even saving like 31, 32, 120 values which represent for example: 32 - water in issue when changing water on 3rd time. I hope that you get what im trying to achieve
Image
Post Reply