Read status of heater and fan?

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Read status of heater and fan?

Post by cosmith71 »

Is there a way to read if the heater and fan are on? I'd like to do a custom screen where the color of the temp reading changes with the status of the heater and fans.

Thanks,

--Colin
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Read status of heater and fan?

Post by binder »

Yes. You will need to use the function bitRead().

Code: Select all

// Check status of port 5
if (bitRead(ReefAngel.Relay.RelayData,Port5-1)) {
  // port 5 is on
} else {
  // port 5 is off
}
That code example will read the bit value of port5 and return a 1 if it's ON and a 0 if it's OFF. You will just need to replace the Port5 with whatever port you have your heater or fan plugged in.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Read status of heater and fan?

Post by rimai »

This also works:

Code: Select all

boolean status =ReefAngel.Relay.Status(Port5);
The difference is that this method will report true if you override the port to always on and the other one doesn't.
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Read status of heater and fan?

Post by cosmith71 »

Got it. Thanks guys!

--Colin
KRavEN
Posts: 104
Joined: Sun Mar 17, 2013 8:21 am

Re: Read status of heater and fan?

Post by KRavEN »

rimai wrote:This also works:

Code: Select all

boolean status =ReefAngel.Relay.Status(Port5);
The difference is that this method will report true if you override the port to always on and the other one doesn't.
Looking at the code it looks like either method is just reading the value of the relay status parameters. There is no Wire call to get the status of the port from the I2C relay device. What happens if a Relay.On() call is made but not a Relay.Write() or if there were some communication failure with the relay and the Relay.Write() didn't work?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Read status of heater and fan?

Post by rimai »

Relay.Write() is called in each loop no matter what, but if the communication fails, it would pick up in the next loop.
Roberto.
Post Reply