개발자/Arduino

Nano 33 IoT 보드 온도 습도 센서 dht11 테스트

지구빵집 2020. 10. 6. 18:20
반응형

 

 

DHT11은 NTC 방식으로 온도센서와 프로세서를 포함하고 있고 트리거 신호에 의해 온도와 습도 값을 40bit로 보내어 줍니다.

 

40bit에는 습도(상위 8Bit, 하위 8bit) + 온도(상위 8Bit, 하위 8bit) + Parity Bit(8bit)로 되어 있습니다. 0001 0101 0000 0000 + 0001 0110 0000 1000 + 0011 0011

 

그럼 NTC 가 무엇인지 알아보겠습니다. 저항의 온도 계수에 따라 서미스터는 크게 두 종류로 구분할 수 있습니다. k(1차 저항 온도 계수) > 0인 경우, 서미스터의 저항은 온도에 따라 증가하며, 이러한 서미스터를 정특성 서미스터(PTC thermistor:Positive Temperature Coefficient thermistor)라 합니다.

 

반대로 k <0인 경우 서미스터의 저항은 온도가 증가하면 감소하게 되며, 이를 부특성 서미스터(NTC thermistor:Negative Temperature Coefficient thermistor)라 합니다.

 

서미스터는 주로 폴리머나 세라믹 소재로 제작되며, 섭씨 영하 90도에서 130도 사이에서 높은 정확도로 온도를 측정할 수 있습니다. 이러한 점에서 순수한 금속을 사용하여 고온의 온도를 측정하는 저항 온도계와는 차이를 보입니다.

 

설명이 어려운데 간단하게 설명하자면 온도(T)가 올라가면 저항값이 내려가는 온도센서라고 보시면 됩니다. 그래서 이런 특성에 맞게 NTC 회사들은 저항-온도 테이블도 제공한다고 합니다.

 

dht11 데이터 쉬트를 참고하세요.

 

DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf
1.42MB

 

DHT11 스펙 

 

- Ultra low cost

- 3 to 5V power and I/O

- 2.5mA max current use during conversion (while requesting data)

- 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

- 4 pins with 0.1" spacing 

 

DHT11과 DHT22 차이점이라고 하면 DHT22가 습도(2~5%)와 온도(±0.5°C)로 정확도 높은 것과 sampling rating(0.5Hz) 더 빠르다는 것입니다. 그래서 좀 더 정확한 값을 원한다면 DHT11 이 아니라 DHT22를 구매해야 합니다. 

 

소스코드

 


#include <SimpleDHT.h>

// for DHT11, 
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 9; /* 수정 */
SimpleDHT11 dht11;

void setup() {
  Serial.begin(9600); /* 수정 */
}

void loop() {
  // start working...
  Serial.println("=================================");
  Serial.println("Sample DHT11...");
  
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
    Serial.print("Read DHT11 failed.");
    return;
  }
  
  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, "); 
  Serial.print((int)humidity); Serial.println(" %");
  
  // DHT11 sampling rate is 1HZ.
  delay(1000);
}

 

 

https://learn.adafruit.com/assets/578

 

 

 

 

 

반응형