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 thoughts on “How To Use DS18B20 Water Proof Temperature Sensor”
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
Thanks Tim for appreciation as well as your input.
Best Regards,
IoTBoys
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?
Hi Tim,
Its because of safety, else it will burn.
Best Regards,
IoTBoys
“Its because of safety, else it will burn.”
No, that’s not what pull-up resistors are for
hey ,i also didn’t use resistor but i am getting -127 celcius ,,,,
where is my error please notice me
I don’t know why I cant get the right data ? Do we really need a pull-up resistor as Tim said ?
Hi Jack,
Pull up register is not required, but you can try with that.
can this sensor measure temperature of Soil?
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.
My serial monitor keeps giving C-127 while the water is boiling, is there something wrong in my code?
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
I am having the same problem with -127c too
I am having the same problem. Did you find a solution?
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??
same problem how to rectify it help me?
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,
Yes Anuna, You can use many sensor just need to point each sensor with different pin.
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
i wonder why my sensor keep reading -127 celcius all the time ? I do follow all the step
hi my serial monitor always showing -127 C … plz tell me how can i fix this..
Same problem bro
Same problem bro. How to fix this
Sir,this is good project but pls Tel how to implement iot in this project pls..
My serial keep giving C-127 F-196
i got same as u
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
I am using Arduino mega 2560 and the sensor is giving -127c and -127F. What is the problem
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
Hello Sir I get -127C and -192F would you like to help me to find the error i did same as you
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?