: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
}
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?
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)
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