Pages: [1]   Go Down
Author Topic: Temperature Probe DS18B20  (Read 630 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 89
Posts: 3458
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12428
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

float F = C * 1.8 + 32;
Logged

Rob Tillaart

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

SWEDEN
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

take a look at this sketch

* Accaldia.ino (4.17 KB - downloaded 11 times.)
Logged

0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 268
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Arduino Uno;
Mega328

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1671
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]
Logged

Pages: [1]   Go Up
Jump to: