
In this article we are showing how to use DS18B20 one wire water proof temperature sensor.
With the help of DS18B20 one wire temperature sensor we can measure the temperature from -55℃ To 125℃ with accuracy of ±5 .
Components Required :-
- 1 x Arduino uno board
- 1 x USB cable
- 1 x DS18B20 Temperature Sensor
- 3 x Jumper wire (Male to Male)
Additional Library :-
Installation Instruction is available here
Connection :-
Sketch/Source Code :-
#include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 5 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); float Celcius=0; float Fahrenheit=0; void setup(void) { Serial.begin(9600); sensors.begin(); } void loop(void) { sensors.requestTemperatures(); Celcius=sensors.getTempCByIndex(0); Fahrenheit=sensors.toFahrenheit(Celcius); Serial.print(" C "); Serial.print(Celcius); Serial.print(" F "); Serial.println(Fahrenheit); delay(1000); }
- 31 Comments
- Connection DS18B20 Temperature Sensor
- DS18B20 Temperature Sensor
- DS18B20 Water Proof
- How To Use DS18B20 Temperature Sensor
- How to Use Temperature Sensor
- How To Use Water Proof Sensor
- Use DS18B20 One Wire
- Use DS18B20 One Wire Water Proof
- Use Thermal Temperature Sensor
- Water Proof Temperature Sensor
Tim Smith
Hi. Great tutorial, thanks. Quick note, I used the waterproof DS18B20 from Sparkfun instead of the Elenker shown above. This required a pull-up resistor in order to complete the project. Again, thanks… Tim
IoT Boys
Thanks Tim for appreciation as well as your input.
Best Regards,
IoTBoys
Linda Whitfield
Tim, why did you use a pull-up resistor? I’m using the same sensor as well, and it’s just outputting the same values. Is that why it is doing that?
IoT Boys
Hi Tim,
Its because of safety, else it will burn.
Best Regards,
IoTBoys
bob
“Its because of safety, else it will burn.”
No, that’s not what pull-up resistors are for
mithu
hey ,i also didn’t use resistor but i am getting -127 celcius ,,,,
where is my error please notice me
Jack
I don’t know why I cant get the right data ? Do we really need a pull-up resistor as Tim said ?
IoT Boys
Hi Jack,
Pull up register is not required, but you can try with that.
Ravi
can this sensor measure temperature of Soil?
IoT Boys
No, DS18B20 Digital Thermometer provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device. For soil temperature measurement you can use 109SS-L sensor.
Elsa
My serial monitor keeps giving C-127 while the water is boiling, is there something wrong in my code?
IoT Boys
Hi Elsa,
Definitely there is something wrong, so what I suggest to do check proper wiring once otherwise most probably your sensor is not working fine so check with other sensor.
Best Regards,
IoTBoys
jack
I am having the same problem with -127c too
jack
I am having the same problem. Did you find a solution?
Huntikhtk
Hi, Im using this in an Arduino Mega 2560. I dont know if i have to put a pull-up resistor (and if i have to do, how and where i connect it), it uploads fine but the serial monitor always give -127 C. Can someone help me??
Naveen
same problem how to rectify it help me?
Anuja
Hello Sir,
Can we use six sensors in Arduino for data logging ? Actually, I want to make a data logger with 6 channels.
Please help.
Thanking you in anticipation.
Regards,
IoT Boys
Yes Anuna, You can use many sensor just need to point each sensor with different pin.
Akshay Patil
Hello. I wanted to measure whether human skin is in contact with something for my project. I was thinking about using this sensor fpr measurement of skin temp. Can I do it with this device
izzuan
i wonder why my sensor keep reading -127 celcius all the time ? I do follow all the step
madhawa
hi my serial monitor always showing -127 C … plz tell me how can i fix this..
Mark Stephen Abroguena
Same problem bro
Mark Stephen Abroguena
Same problem bro. How to fix this
Swapnil Patel
Sir,this is good project but pls Tel how to implement iot in this project pls..
Ahmed
My serial keep giving C-127 F-196
pema
i got same as u
Akeyan
Sir im having the problem of sensor showing wrong value like 127 celicus i tried using different sensors but the problem still remained the same please help why is this error occuring.
Thankyou
FOYSOL MAHMUD
I am using Arduino mega 2560 and the sensor is giving -127c and -127F. What is the problem
pema Loday
I get same as you i use mega 2560 as well as i check with Uno but i got -127.00 C and -196 F
pema Loday
Hello Sir I get -127C and -192F would you like to help me to find the error i did same as you
Cath
Hi, I tried to follow the codes u provided above but it said “One_Wire_Bus” was not declared in this scope. what should I do?