(SKU:RB-02S014)DHT11溫濕度傳感器

來自ALSROBOT WiKi
2015年5月11日 (一) 10:5426wd討論 | 貢獻(xiàn)的版本

跳轉(zhuǎn)至: 導(dǎo)航、 搜索
P-789.jpg

目錄

概述

DHT11數(shù)字溫濕度傳感器是一款含有已校準(zhǔn)數(shù)字信號輸出的溫濕度復(fù)合傳感器。它應(yīng)用專用的數(shù)字模塊采集技術(shù)和溫濕度傳感技術(shù),確保產(chǎn)品具有極高的可靠性與卓越的長期穩(wěn)定性。傳感器包括一個(gè)電阻式感濕元件和一個(gè)NTC測溫元件,并與一個(gè)高性能8位單片機(jī)相連接。因此該產(chǎn)品具有品質(zhì)卓越、超快響應(yīng)、抗干擾能力強(qiáng)、性價(jià)比極高等優(yōu)點(diǎn)。每個(gè)DHT11傳感器都在極為精確的濕度校驗(yàn)室中進(jìn)行校準(zhǔn)。校準(zhǔn)系數(shù)以程序的形式儲存在OTP內(nèi)存中,傳感器內(nèi)部在檢測信號的處理過程中要調(diào)用這些校準(zhǔn)系數(shù)。單線制串行接口,使系統(tǒng)集成變得簡易快捷。超小的體積、極低的功耗,信號傳輸距離可達(dá)20米以上,使其成為各類應(yīng)用甚至最為苛刻的應(yīng)用場合的最佳選則。DHT11數(shù)字溫濕度傳感器模塊為3針PH2.0封裝。連接方便。

規(guī)格參數(shù)

  1. 供電電壓:3-5.5V
  2. 供電電流:最大2.5mA
  3. 溫度范圍:0-50℃ 誤差±2℃
  4. 濕度范圍:當(dāng)環(huán)境溫度在 0 ℃時(shí)為30~90%RH
           當(dāng)環(huán)境溫度在25℃時(shí)為20~90%RH 
           當(dāng)環(huán)境溫度在50℃時(shí)為20~80%RH
  1. 響應(yīng)時(shí)間: 1/e(63%) 6-30s
  2. 測量分辨率分別為 8bit(溫度)、8bit(濕度)
  3. 采樣周期間隔不得低于1秒鐘
  4. 模塊尺寸:15mm×34mm

產(chǎn)品圖片和引腳定義

傳感器引腳的定義是

  • S:輸出信號
  • +:電源(VCC)
  • -:地(GND)
引腳的定義是

連接示意圖

P-33.jpg

模塊的使用

使用傳感器連接線將濕度傳感器連接到Arduino傳感器擴(kuò)展板的模擬口0 上如示意圖所示。然后將代碼編譯后下載到 Arduino里,就可以在串口助手窗口上顯示測得的當(dāng)前值(注:Arduino串口助手波特率調(diào)到19200 )。Arduino實(shí)驗(yàn)代碼如下。
實(shí)例代碼:
#define DHT11_PIN 0      // ADC0 UNO接到模擬口0   mega接PIN37
byte read_dht11_dat()
{
	byte i = 0;
	byte result=0;
	for(i=0; i< 8; i++){
	     while(!(PINC & _BV(DHT11_PIN)));  // wait for 50us
	     delayMicroseconds(30);
	     if(PINC & _BV(DHT11_PIN)) 
	     result |=(1<<(7-i));
             while((PINC & _BV(DHT11_PIN)));  // wait '1' finish
	}
	return result;
}
void setup()
{
	DDRC |= _BV(DHT11_PIN);
	PORTC |= _BV(DHT11_PIN);
	  Serial.begin(19200);
Serial.println("Ready");
	}
	
void loop()
{
	byte dht11_dat[5];
	byte dht11_in;
	byte i;
	// start condition
	// 1. pull-down i/o pin from 18ms
	PORTC &= ~_BV(DHT11_PIN);
	delay(18);
	PORTC |= _BV(DHT11_PIN);
	delayMicroseconds(40);
	DDRC &= ~_BV(DHT11_PIN);
	delayMicroseconds(40);
	dht11_in = PINC & _BV(DHT11_PIN);
	if(dht11_in){
		Serial.println("dht11 start condition 1 not met");
		return;
	}
	delayMicroseconds(80);
	dht11_in = PINC & _BV(DHT11_PIN);
	if(!dht11_in){
		Serial.println("dht11 start condition 2 not met");
		return;
	}
	delayMicroseconds(80);
	// now ready for data reception
	for (i=0; i<5; i++)
		dht11_dat[i] = read_dht11_dat();
	DDRC |= _BV(DHT11_PIN);
	PORTC |= _BV(DHT11_PIN);
  byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
	// check check_sum
	if(dht11_dat[4]!= dht11_check_sum)
	{
		Serial.println("DHT11 checksum error");
	}
	Serial.print("Current humdity = ");
	Serial.print(dht11_dat[0], DEC);
	Serial.print(".");
	Serial.print(dht11_dat[1], DEC);
	Serial.print("%  ");
	Serial.print("temperature = ");
	Serial.print(dht11_dat[2], DEC);
	Serial.print(".");
	Serial.print(dht11_dat[3], DEC);
	Serial.println("C  ");
	delay(2000);
}

編譯代碼后下載到Arduino中,打開串口助手即可看見實(shí)際測量的溫度與濕度。

P-44.jpg
→視頻演示  運(yùn)用Arduino DHT11溫濕度傳感器制作溫濕度報(bào)警器]

→購買地址 DHT11數(shù)字溫濕度傳感器 http://m.gharee.com/goods.php?id=72]