Now for a code question. I now need to turn a relay on and off based on an if statement. That if statement will include the temp of the boiler output, the storage tank temp, a setpoint temperature and a differential. I will add the following to the top of the code to initialize the relay pin and to set the last two variables:
byte boiler[8] = {0x10, 0xCE, 0xE3, 0x0F, 0x01, 0x08, 0x00, 0xA4};
byte storage[8] = {0x10, 0xC0, 0x08, 0x64, 0x00, 0x08, 0x00, 0xB2};
int relayPin = 12; // Relay connected to digital pin 12
int setpoint = 175; // Set the desired storage maximum temp in Fahrenheit here
int differential = 10; // Set the differential between source temp and storage temp in Fahrenheit here
Then I need to add the if statement to the loop at the end of the code. My problem is that I am not sure what each temp that has been floated is being called to use in the statement. They appear to both be called temp and printed to serial. I need to use those temps. This is what I have worked out so far and have simply called them (boiler) and (storage) for now. Anyone know how to do this?
// ########### L O O P ###########
void loop(void) {
//search_devices(); //enable this line to get sensor device id. comment out when finished
float temp;
temp = get_temp(boiler);
Serial.print("Temp = ");
Serial.println(temp, DEC);
temp = get_temp(storage);
Serial.print("Temp = ");
Serial.println(temp, DEC);
//Turn Relay on/off routine
if ((boiler) > (storage) + (differential)) //check source temp for differential
{
digitalWrite (relayPin, HIGH); //if temp is above x degrees turn pin "ON"
}
else if ((storage) > (setpoint)) //check storage temp against setpoint
{
digitalWrite (relayPin, LOW); //if temp is below x degree turn pin "OFF"
}
else
{
digitalWrite (relayPin, LOW); //if temp is below x degree turn pin "OFF"
}
delay(1000*60); //1 minute loop
}