特價

DHT12 數字溫濕度感測器模組 單總線 和 I2C 通信 DHT11升級版

NT$175 NT$150

20 件庫存

描述

DHT12 數字溫濕度感測器模組 單總線 和  I2C 通信 DHT11升級版

DHT12 數字溫濕度感測器模組 是經典 DHT11 濕度溫度傳感器的升級版本,它完全向下兼容,更精確並增加了I2C接口。

  • 1. 可以檢測周圍環境的濕度和溫度
  • 2. 傳感器採用DHT12,支持單總線和I2C通訊
  • 3. 濕度測量範圍:20%-95%(0度-50度範圍)濕度測量誤差:+-5%
  • 4. 溫度測量範圍:0度-50度溫度測量誤差:+-2度
  • 5. 工作電壓2.7V-5.5V
  • 6. 輸出形式數字輸出
  • 7. 設有固定螺栓孔,方便安裝
  • 8. 小板PCB尺寸:2.1cm * 1.3cm


模塊接口說明(4線製)

  • 1.   VCC外接2.7V-5.5V
  • 2.  SDA串行數據,雙向口
  • 3.  GND外接GND
  • 4.  SCL串行時鐘,輸入口(單總線時接地)

 

特徵:

  • 體積小巧
  • 低功耗
  • 低電壓工作
  • 標準I2C和 1線 接口。

感應範圍

  • 溫度:-20〜+ 60℃ 濕度:20-95 RH
  • 濕度:分辨率:0.1%RH
  • 重複: – + 1%RH
  • 精度25℃@ – + 5RH
  • 溫度:分辨率:0.1C
  • 重複: – + 0.2C
  • 精度: 25C @ – + 0.5C
  • 功率:DC 2.7-5.5V
  • 正常電流1mA
  • 待機電流60uA
  • 採樣週期:> 2秒

引腳接口:1. VDD 2. SDA 3. GND 4. SCL(作為1線使用時連接至GND)

如何將DHT12連接到Arduino Uno  arduino和 dht12

DHT22 函數庫下載 https://github.com/xreef/DHT12_sensor_library

#include "Arduino.h"
 
#include <DHT12.h>
 
// Set dht12 i2c comunication on default Wire pin
DHT12 dht12;
 
void setup()
{
Serial.begin(112560);
// Start sensor handshake
dht12.begin();
}
int timeSinceLastRead = 0;
 
void loop()
{
// Report every 2 seconds.
if(timeSinceLastRead > 2000) {
// Reading temperature or humidity takes about 250 milliseconds!
// Read temperature as Celsius (the default)
float t12 = dht12.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f12 = dht12.readTemperature(true);
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h12 = dht12.readHumidity();
 
bool dht12Read = true;
// Check if any reads failed and exit early (to try again).
if (isnan(h12) || isnan(t12) || isnan(f12)) {
Serial.println("Failed to read from DHT12 sensor!");
 
dht12Read = false;
}
 
if (dht12Read){
// Compute heat index in Fahrenheit (the default)
float hif12 = dht12.computeHeatIndex(f12, h12);
// Compute heat index in Celsius (isFahreheit = false)
float hic12 = dht12.computeHeatIndex(t12, h12, false);
// Compute dew point in Fahrenheit (the default)
float dpf12 = dht12.dewPoint(f12, h12);
// Compute dew point in Celsius (isFahreheit = false)
float dpc12 = dht12.dewPoint(t12, h12, false);
 
Serial.print("DHT12=> Humidity: ");
Serial.print(h12);
Serial.print(" %t");
Serial.print("Temperature: ");
Serial.print(t12);
Serial.print(" *C ");
Serial.print(f12);
Serial.print(" *Ft");
Serial.print(" Heat index: ");
Serial.print(hic12);
Serial.print(" *C ");
Serial.print(hif12);
Serial.print(" *F");
Serial.print(" Dew point: ");
Serial.print(dpc12);
Serial.print(" *C ");
Serial.print(dpf12);
Serial.println(" *F");
}
timeSinceLastRead = 0;
}
delay(100);
timeSinceLastRead += 100;
 
}

輸出結果

DHT12 =>濕度:33.70%溫度:20.20 * C 68.36 * F熱指數:19.16 * C 66.48 * F露點:3.60 * C 38.48 * F
DHT12 =>濕度:39.70%溫度:20.60 * C 69.08 * F熱指數:19.75 * C 67.55 * F露點:6.34 * C 43.41 * F
DHT12 =>濕度:44.60%溫度:21.20 * C 70.16 * F熱指數:20.54 * C 68.97 * F露點:8.64 * C 47.55 * F
DHT12 =>濕度:47.80%溫度:21.80°C 71.24°F熱指數:21.28°C 70.31°F露點:10.25°C 50.45°F
DHT12 =>濕度:48.90%溫度:22.40°C 72.32°F熱指數: 21.97 * C 71.55 * F露點:11.16 * C 52.08 * F
DHT12 =>濕度:53.90%溫度:22.90 * C 73.22 * F熱指數:22.65 * C 72.78 * F露點:13.14 * C 55.66 * F
DHT12 =>濕度:55.10%溫度:23.60 * C 74.48 * F熱指數:23.45 * C 74.22 * F露點:14.15 * C 57.46 * F
DHT12 =>濕度:54.90%溫度:23.90 * C 75.02 * F熱指數:23.78 * C 74.80 * F露點:14.37 * C 57.86 * F
DHT12 =>濕度:45.30%溫度:24.40 * C 75.92 * F熱指數:24.08 * C 75.34 * F露點:11.80 * C 53.24 * F
DHT12 =>濕度:40.60%溫度:24.60 * C 76.28 * F熱指數:24.18 * C 75.52 * F露點:10.28 * C 50.50 * F
DHT12 =>濕度:37.10%溫度:24.80 * C 76.64 * F熱指數: 24.30 * C 75.75 * F露點:9.09 * C 48.35 * F