sabato 21 luglio 2018

DHT11, Arduino Temperature and humidity Sensor.



The DHT11 is a basic,  low-cost digital temperature and humidity sensor.It's fairly simple to use, but requires careful timing to grab data. 



Technical Details


    Low Cost    3 to 5V power and I/O    2.5mA max current    Good for 20-80% humidity readings with 5% accuracy    Good for 0-50°C temperature readings ±2°C accuracy    No more than 1 Hz sampling rate (once every second)    Body size 15.5mm x 12mm x 5.5mm   


Test sketch


//

//   FILE:  dht11_test1.pde

// PURPOSE: DHT11 library test sketch for Arduino

//

#include <dht11.h>

dht11 DHT;

#define DHT11_PIN 7
void setup(){
Serial.begin(9600);
Serial.println("DHT TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT11LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop(){
int chk;
Serial.print("DHT11, \t");
chk = DHT.read(DHT11_PIN);    // READ DATA
switch (chk){
case DHTLIB_OK: 
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAT DATA

Serial.print(DHT.humidity,1);
Serial.print(",\t");
Serial.println(DHT.temperature,1);
delay(1000);
}


    A tutorial on how to connect a DHT11  Sensor to your 

    Arduino

Canale Telegram Leocity IOT

Ecco il link per il materiale delle lezioni : https://t.me/CorsoIOTDaVinci