DHT11 shows extreme temperature and humidity

:o
the serial monitors says the temparature is 640 celcius and humidity is 1709%
please help
thanks
hereis

*  DHT11/ DHT22 Sensor Temperature and Humidity Tutorial
 *  Program made by Dejan Nedelkovski,
 *  www.HowToMechatronics.com 
 */
/*
 * You can find the DHT Library from Arduino official website
 * http://playground.arduino.cc/Main/DHTLib
 */
 
#include <dht.h>
#define dataPin 8 // Defines pin number to which the sensor is connected
dht DHT; // Creats a DHT object
void setup() {
  Serial.begin(9600);
}
void loop() {
  int readData = DHT.read22(dataPin); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");
  
  delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}

my code

I don't know much about these things but are you sure it's a good idea to use DHT.read22() instead of DHT.read11() when you have a DHT11? And then not to check if there has been an error?

Steve

slipstick:
use DHT.read22() instead of DHT.read11() when you have a DHT11

Call it forum experience but that was the first I thought of when I read the subject line.

Different sensors, different return values. Don't mix them up.

Here is the barest DHT11.ino in my collection.
---> do not forget a 10k pullup resistor
---> DHT on pin 8

good luck

// single DHT 11 temp-humidity sensor on Arduino with serial monitor reporting only
// original written by Tim Stephens 2013 - Temperature Logger | tjstephens
// public domain
// modified Floris Wouterlood July 1, 2017

// based on DHT11 examples by Ladyada.
// data pin of DHT11 sensors wired to pin 10 on Arduino
// 10k pull up resistor (between data and 5V)

#include "DHT.h"

float h, t;
DHT DHT_sens(8, DHT11); //datapin sensor to pin 10 Arduino

void setup()
{

DHT_sens.begin();

Serial.begin (9600);
Serial.println ("===============================================");
Serial.println ("Bare DHT11 temp-humidity sensor - June 30, 2017");
Serial.println ("===============================================");
Serial.println (" ");
}

void loop(){

// ================== read from buffer and display =========================

h = DHT_sens.readHumidity();
t = DHT_sens.readTemperature();

delay (1000); // pause a second
Serial.print ("Humidity: ");
Serial.print (h,0); // zero decimal
Serial.print (" %\t");
Serial.print ("Temperature: ");
Serial.print (t,1); // one decimal
Serial.println (" *C");
delay (1000); // pause a second

}

comments say // data pin of DHT11 sensors wired to pin 10 on Arduino, but because I noted that your DHT11 is on pin 8, I changed the ino to accomodate a DHT on pin 8. Succes, photoncatcher