Problem with relay shield or some mistake with code?

johnwasser:
The code looks OK. What values are displayed for "Temperature for the device 1 is: "?

Hi John,
The values i think that are correct...initially i test my room temperature, and the values are about 21°C .

The serial monitor show me this:
Temperature for the device 1 is: 21.37
a
Temperature for the device 1 is: 21.44
a
So the code as you say is correct...now i dont understand if i write the if condition like that my switch magically work well.. its strange isn't it?

Working code (like blink example):

if(sensors.getTempCByIndex(0)<=40)
{
digitalWrite(5, HIGH);
Serial.println("a");
delay(1000);
digitalWrite(5, LOW);
Serial.println("b ");
}

Thanks John