Hello, i have problem with my 18b20. Suddenly it started to show the wrong temperature. I seen many people have this problem but there is no answear how to fix it. I use 4,7k resistor seperated from the 18b20. I'm using dallastemperature --> test library. Arduino placed in a large distance from the sensor. I have 19 degrees in room. 18b20 show 23-25. There is the problem ?
Try not standing near it when measuring, you will radiate heat at it and distort the measurement.
Better still use a fan for force-convect the air around it and you'll get a better (and faster) measure of true air temperature.
Mounting the device in a shiny metal tube will reflect most of the radiant heat too if you want to try that.
Remember heat is carried by radiation as well as conduction and convection, and this is a significant effect if a human being is leaning over a small black piece of plastic - skin temperature radiates about 500W/m^2 into free space (ie the sky on a clear night), and about 50W/m^2 indoors to the walls.
These devices are laser-trimmed and very accurate close to room temperature. You see a standard deviation of about 0.1 deg C if you setup a big bunch of them and force-convect - ie about 350ppm in absolute temperature terms.
BTW if you bought cheap knock-off DS18B20's from china all bets are off, these are likely to be clones or factory rejects.
jarossis: There is the problem ?
I think the answer is - "yes".
You might start by testing the accuracy of the source that says "19".
Your code is not easy to read but, if you are using the dallas temperature library and are getting any sort of result, I guess it is kosher.