Temperature Probe DS18B20

Good Afternoon,

I have a DS18B20 temp probe that ill be using to control fans for my fish tank. I have the code figured out for reading the temp from the probe but im not sure how to use the temp information to set thresholds to turn the fans on and off. Any information is helpful. Thanks !!

if (temperature > highThreshold)
{
   digitalOutput(fanPin, HIGH);   //turn on the fan
}
else if (temperature < lowThreshold)
{
   digitalOutput(fanPin, LOW);   //turn off the fan
}

thanks for the quick response. while your at it do you know how i can convert from C to F? Thanks again

float F = C * 1.8 + 32;

take a look at this sketch

Accaldia.ino (4.17 KB)

Make sure you incorporate some hysteresis in the sketch or else the fans will be cycling on and off very rapidly.

thank you for all the great responses. I still am having trouble being able to do a digital read for the temperature reading in the code so that i can turn around and use it for the fan proton. In the DS18B20 code the "digitalWrite" is for the "Whole" and "Frac". For reference i pulled the DS18B20 code off of the arduino website. Thanks for all the help.

I don't know why you need digitalwrite, and this sounds like it is getting a lot more complicated than it needs to be. I imagine you only need the whole number anyway, and keeping to that should solve any hysteresis issues.

While I don't think you have a problem, if you really do, it may simply be caused by inappropriate code and/or bad choice of libraries (if any).

You should be able to use commands like

GetTemp(Temp) (which returns a number like 27.27)
Serial.print(Temp) and/.or lcd.print(Temp) (enabling you to see the result, 27.27)
If Temp too high, turn fan on (enabling you to do something)

You can do this using the proper Dallas temperature one-wire libraries. I believe this is worth doing, even if you are only using one sensor, as it requires less code from you.

quote author=Dustyboy007 link=topic=178650.msg1324524#msg1324524 date=1374455230]
I still am having trouble being able to do a digital read for the temperature reading in the code so that i can turn around and use it for the fan proton. In the DS18B20 code the "digitalWrite" is for the "Whole" and "Frac". For reference i pulled the DS18B20 code off of the arduino website. Thanks for all the help.

[/quote]