DHT11 Temperature and Humidity pull up resistor?

I am new to microcontrollers and I finally got my arduino weatherstation working with the DHT11 sensor and the LCD screen. I am comparing it to another store-bought temp/humidity sensor and they don't match up sometimes. I know the accuracy of the DHT11 is only +-2 degrees, but I've seen them both at 17 c, now the arduino says 18c and the other says 15c. It seems to get stuck on 18 c sometimes, but I am displaying the millis() so I know its running.

I see on some wiring diagrams that people put a 10k resistor between the data line pin #2 and the analog input on the arduino, calling it a "pull up resistor", could this help fix the problem? It seems pretty on-par with the other one until it gets to about <20 c and then it seems somewhat random.

e.g of wiring diagram including 10k resistor: http://learn.adafruit.com/system/assets/assets/000/000/578/medium800/dhtwiring.gif?1340983667

Well the data sheet says a 5K resistor which is not a real value so I would use 4K7.

Whats the accuracy of the store bought sensor you are comparing the DHT11 with.
The DHT11 is a slow sensor, which means that it takes a while to respond to temperature changes.

i have the dht-22, which calls for a 1k, and i was under the impression that the pullup is needed because these devices (11 and 22) utilize a one wire bus, not compatible with dallas onewire. also, datasheet says if mounted near any heat producing components will effect temperature output.

The DHT protocol provides a communication error check. It transmits two bytes for humidity, two bytes for temperature and one byte which is the sum of the previous four bytes. If the values received adds up to the fifth byte then there isn't (statistically speaking) a communication error. A less technical error check is if the received humidity and temperature values are vaguely believable there probably isn't a communication error. I've found that I get reliable communication with a DHT11 over about 5 meters of CAT5 network cable using only the internal pull-up of the atmega enabled on the data pin.

I suspect you are simply seeing the inherent inaccuracy of the sensor. I've also compared the DHT11 temperature reading with an LM35 and a thermistor. The DHT11 was not as accurate as the other temperature sensing elements. I regard the DHT11 temperature reading as optional information, if you really want to measure temperature to better than +-2°C accuracy use another sensor. Also remember the +-2 °C stated accuracy is approximate and the reading gets truncated or rounded to an integer value so the accuracy of individual sensors may vary by as much as +- 3°C.

Im aware of the rounding errors and the time for the sensor to adjust etc, I admit im only using the dht11 test code found here: http://www.hobbyist.co.nz/?q=documentations/wiring-up-dht11-temp-humidity-sensor-to-your-arduino. They recently updated it from the previous code which included a checksum, but for some reason it kept freezing; this is the first code ive been able to run continously for days at a time.

And it works well for the most part, it actually seems to adjust pretty well, but before I saw it flicking between 16 and 19 degrees. It normally only does that by one degree. Surely a difference of 3 degrees cant be due to truncating?

In this tutorial they dont include a pull-up resistor, and im curious to its function. If its sending the information as bit streams which is just a series of high/low pins then why does it need a resistor? Im just trying to figure out if it can explain why theres a jump in temperature.

Does it matter if I ground the dht with the gnd on the power side? Because the gnd on the digital side feels really loose, and might also be the cause of the problems above.

The pullup resistor is needed because the data line to the sensor is bidirectional.
The sensor only sends data after its been told to by the Micro .
However, depending on the code that actually reads the Sensor, some Micros have weak pullups in them
that means that the resistor may not be needed.
You would have to study the code thats actually doing the sensor reading to see if this is the case.
The resistor value isnt critical, 10K is a good value.
Also, some suppliers of the sensor send it on a small breakout board, which already has the resistor installed.
If the Sensor is jumping back and forth between degree readings 3 D apart, then there is something wrong with either the code thats reading it
or the wiring , or the sensor itself.
The Sensors are pretty rugged so its not likley to be the Sensor.
They either work properly or not at all.

mauried:
The pullup resistor is needed because the data line to the sensor is bidirectional.
The sensor only sends data after its been told to by the Micro .
However, depending on the code that actually reads the Sensor, some Micros have weak pullups in them
that means that the resistor may not be needed.
You would have to study the code thats actually doing the sensor reading to see if this is the case.
The resistor value isnt critical, 10K is a good value.
Also, some suppliers of the sensor send it on a small breakout board, which already has the resistor installed.
If the Sensor is jumping back and forth between degree readings 3 D apart, then there is something wrong with either the code thats reading it
or the wiring , or the sensor itself.
The Sensors are pretty rugged so its not likley to be the Sensor.
They either work properly or not at all.

I added a 10k pullup resistor, I didn't really notice too much difference. Maybe its slightly faster now, I dont know. This is the relay module I have: http://i01.i.aliimg.com/img/pb/906/184/488/488184906_511.jpg I know it has a built in diode but not sure about the resistor.

I saw the temperature doing the 3 degree dance again this morning, it always seems to be between 16 and 19. The other thermometer was showing around 15 so 16 was the closer one. I AM setting the relay on at 19 and off and 20... could it somehow be getting stuck after I switch the relay pin to high?

As regards to analyzing the code, well I followed the instructions and downloaded the DHT library from here: http://www.hobbyist.co.nz/?q=documentations/wiring-up-dht11-temp-humidity-sensor-to-your-arduino.

I don't understand, how do I open the library to see what the DHT.read11(dht_dpin) is doing? I am assuming the dht library I downloaded is a standard one and thus should be relatively the same? Or is that library different to the one here? Arduino Playground - HomePage

This is my code which I copied from the former above and pretty much hacked it into my current prototype. However after a quick skim I don't see any mention of of a DHT.read11() function in the latter.

#include <dht.h>

#define dht_dpin 14 //no ; here. Set equal to channel sensor is on

dht DHT;
int flip=0;
int Max=0;
int Min=99;
int setemp=0;
float potvalue=0;

#include <LiquidCrystal.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);

void setup(){
lcd.begin(16, 2); 
//Serial.begin(9600);
delay(300);//Let system settle
pinMode(12, OUTPUT);
//Serial.println("Humidity and temperature\n\n");
delay(700);//Wait rest of 1000ms recommended delay before
//accessing sensor
}//end "setup()"

void loop(){

//This is the "heart" of the program.
DHT.read11(dht_dpin);
potvalue = analogRead(A1);
setemp=(potvalue/1012)*30;

if (int(DHT.temperature)>Max) {
Max=DHT.temperature;
}

if (int(DHT.temperature)<Min) {
Min=DHT.temperature;
}

if (DHT.temperature<20)
  digitalWrite(12, HIGH); 

if (DHT.temperature>19) 
  digitalWrite(12, LOW); 

lcd.setCursor(0, 0); 
lcd.print("Temp=           ");
lcd.setCursor(6, 0);
lcd.print(int(DHT.temperature), DEC);
lcd.print("C");
if (((millis()/1000) % 15) > 7 ){
lcd.print(" Max ");
lcd.print(Max);
}
else
{
lcd.print(" Min ");
lcd.print(Min);
}
lcd.setCursor(0, 1);
lcd.print("              ");
lcd.setCursor(0, 1);
if (((millis()/1000) % 15) > 7 )
{
lcd.print("Humidity = "); 
lcd.setCursor(11, 1); 
lcd.print(int(DHT.humidity), DEC);
lcd.print("%");
}
else
{
  lcd.print(setemp);
//lcd.print(millis()/1000);
}


//Serial.print("Current humidity = ");
//Serial.print(DHT.humidity);
//Serial.print("% ");
//Serial.print("temperature = ");
//Serial.print(DHT.temperature);
//Serial.println("C ");



delay(1000);//Don't try to access too frequently... in theory
//should be once per two seconds, fastest,
//but seems to work after 0.8 second.
}// end loop()

Edit:

One more thing I can think of, and im sorry this is starting to become more programming/wiring questions. But I have the third pin on my lcd (contrast pin to resistor to ground), connected through a resistor over the breadboard seperator into the adjacent bus*, and then into my ground bus on the breadboard. But I ran out of room on the breadboard ground bus and now I have my relay ground connected to the previous adjacent bus*

I dont recall the drastic temperature jumps when the relay wasent connected, but there has always been the low temperature inaccuracy (maybe its a flaw of the DHT11?)

Note: I also have the data line pullup resistor going to a seperate empty bus, that bus is then connected to the digital A0 pin on the arduino.

Thanks guys your help has been greatly appreciated so far and will continue to be so.

Try reading the Sensor at a much slower rate.
About once every 3 seconds is a good rate.
If you read at a faster rate, the Sensor will return garbage values.

Sorry for bringing this up again, i know it's been a while.
I was testing myself a DHT11, and i found that it's very sensitive to supply voltage.

I found that it's working at 3.3V as well so i powered it from the 3.3V pin from Arduino.

I used a relay too and i found out that the relay was taken a little more current than what i expected, but enough to tamper the sensor readings. I had that bounce between the 3 degrees as well.

But changing the relay power source was a great idea, and now the DHT11 is stable.