Go Down

Topic: Temperature Probe DS18B20 (Read 985 times) previous topic - next topic

Dustyboy007

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 !!

UKHeliBob

Code: [Select]
if (temperature > highThreshold)
{
   digitalOutput(fanPin, HIGH);   //turn on the fan
}
else if (temperature < lowThreshold)
{
   digitalOutput(fanPin, LOW);   //turn off the fan
}
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Dustyboy007

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

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

ingvartage

take a look at this sketch

jerseyguy1996

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

Dustyboy007

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.

Nick_Pyner

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]

Go Up