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
Read status of heater and fan?
- cosmith71
- Posts: 1432
- Joined: Fri Mar 29, 2013 3:51 pm
- Location: Oklahoma City
-
binder
- Posts: 2865
- Joined: Fri Mar 18, 2011 6:20 pm
- Location: Illinois
- Contact:
Re: Read status of heater and fan?
Yes. You will need to use the function bitRead().
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.
Code: Select all
// Check status of port 5
if (bitRead(ReefAngel.Relay.RelayData,Port5-1)) {
// port 5 is on
} else {
// port 5 is off
}
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
Re: Read status of heater and fan?
This also works:
The difference is that this method will report true if you override the port to always on and the other one doesn't.
Code: Select all
boolean status =ReefAngel.Relay.Status(Port5);
Roberto.
- cosmith71
- Posts: 1432
- Joined: Fri Mar 29, 2013 3:51 pm
- Location: Oklahoma City
Re: Read status of heater and fan?
Got it. Thanks guys!
--Colin
--Colin
-
KRavEN
- Posts: 104
- Joined: Sun Mar 17, 2013 8:21 am
Re: Read status of heater and fan?
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 wrote:This also works:The difference is that this method will report true if you override the port to always on and the other one doesn't.Code: Select all
boolean status =ReefAngel.Relay.Status(Port5);
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
Re: Read status of heater and fan?
Relay.Write() is called in each loop no matter what, but if the communication fails, it would pick up in the next loop.
Roberto.
