Difference between revisions of "Temperature and Humidity Sensor"

From LinkSprite Playgound
Jump to: navigation, search
(Created page with "== Introduction == This is a powerful sister version of our Linker kit - Temperature and Humidity Sensor. It has more complete and accurate performance. The detecting range o...")
 
 
(9 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
This is a powerful sister version of our Linker kit - Temperature and Humidity Sensor. It has more complete and accurate performance. The detecting range of this sensor is 5% RH - 99% RH, and -40°C - 80°C. And its accuracy satisfyingly reaches up to 2% RH and 0.5°C. A professional choice for applications that have relatively strict requirements.  
 
This is a powerful sister version of our Linker kit - Temperature and Humidity Sensor. It has more complete and accurate performance. The detecting range of this sensor is 5% RH - 99% RH, and -40°C - 80°C. And its accuracy satisfyingly reaches up to 2% RH and 0.5°C. A professional choice for applications that have relatively strict requirements.  
  
[[File:1-214.jpg]]
+
[[File:1-214.jpg|600px]]
  
[[File:1-215.jpg]]
+
[[File:1-215.jpg|600px]]
  
  
Line 28: Line 28:
  
 
(2)、Program
 
(2)、Program
  #include <DHT22.h>
+
  #include <DHT22.h>
  // Only used for sprintf
+
  // Only used for sprintf
  #include <stdio.h>
+
  #include <stdio.h>
  // Data wire is plugged into port 7 on the Arduino
+
  // Data wire is plugged into port 7 on the Arduino
  // Connect a 4.7K resistor between VCC and the data pin (strong pullup)
+
  // Connect a 4.7K resistor between VCC and the data pin (strong pullup)
  #define DHT22_PIN 7
+
  #define DHT22_PIN 7
  // Setup a DHT22 instance
+
  // Setup a DHT22 instance
  DHT22 myDHT22(DHT22_PIN);
+
  DHT22 myDHT22(DHT22_PIN);
  void setup(void)
+
  void setup(void)
{
+
  {
  // start serial port
+
  // start serial port
  Serial.begin(9600);
+
  Serial.begin(9600);
  Serial.println("DHT22 Library Demo");
+
  Serial.println("DHT22 Library Demo");
 
   }
 
   }
  void loop(void)
+
  void loop(void)
 
+
 
  DHT22_ERROR_t errorCode;
+
  DHT22_ERROR_t errorCode;
 
+
  // The sensor can only be read from every 1-2s, and requires a minimum
  // The sensor can only be read from every 1-2s, and requires a minimum
+
  // 2s warm-up after power-on.
  // 2s warm-up after power-on.
+
  delay(2000);
  delay(2000);
+
  Serial.print("Requesting data...");
 
+
  errorCode = myDHT22.readData();
  Serial.print("Requesting data...");
+
  switch(errorCode)
  errorCode = myDHT22.readData();
+
  {
  switch(errorCode)
+
  case DHT_ERROR_NONE:
  {
+
  Serial.print("Got Data ");
    case DHT_ERROR_NONE:
+
  Serial.print(myDHT22.getTemperatureC());
      Serial.print("Got Data ");
+
  Serial.print("C ");
      Serial.print(myDHT22.getTemperatureC());
+
  Serial.print(myDHT22.getHumidity());
      Serial.print("C ");
+
  Serial.println("%");
      Serial.print(myDHT22.getHumidity());
+
  // Alternately, with integer formatting which is clumsier but more compact to store and
      Serial.println("%");
+
  // can be compared reliably for equality:
      // Alternately, with integer formatting which is clumsier but more compact to store and
+
  //
      // can be compared reliably for equality:
+
  char buf[128];
      //      
+
  sprintf(buf, "Integer-only reading: Temperature %hi.%01hi C, Humidity %i.%01i %% RH",
      char buf[128];
+
  myDHT22.getTemperatureCInt()/10, abs(myDHT22.getTemperatureCInt()%10),
      sprintf(buf, "Integer-only reading: Temperature %hi.%01hi C, Humidity %i.%01i %% RH",
+
  myDHT22.getHumidityInt()/10, myDHT22.getHumidityInt()%10);
                   myDHT22.getTemperatureCInt()/10, abs(myDHT22.getTemperatureCInt()%10),
+
  Serial.println(buf);
                   myDHT22.getHumidityInt()/10, myDHT22.getHumidityInt()%10);
+
  break;
      Serial.println(buf);
+
  case DHT_ERROR_CHECKSUM:
      break;
+
  Serial.print("check sum error ");
    case DHT_ERROR_CHECKSUM:
+
  Serial.print(myDHT22.getTemperatureC());
      Serial.print("check sum error ");
+
  Serial.print("C ");
      Serial.print(myDHT22.getTemperatureC());
+
  Serial.print(myDHT22.getHumidity());
      Serial.print("C ");
+
  Serial.println("%");
      Serial.print(myDHT22.getHumidity());
+
  break;
      Serial.println("%");
+
  case DHT_BUS_HUNG:
      break;
+
  Serial.println("BUS Hung ");
    case DHT_BUS_HUNG:
+
  break;
      Serial.println("BUS Hung ");
+
  case DHT_ERROR_NOT_PRESENT:
      break;
+
  Serial.println("Not Present ");
    case DHT_ERROR_NOT_PRESENT:
+
  break;
      Serial.println("Not Present ");
+
  case DHT_ERROR_ACK_TOO_LONG:
      break;
+
  Serial.println("ACK time out ");
    case DHT_ERROR_ACK_TOO_LONG:
+
  break;
      Serial.println("ACK time out ");
+
  case DHT_ERROR_SYNC_TIMEOUT:
      break;
+
  Serial.println("Sync Timeout ");
    case DHT_ERROR_SYNC_TIMEOUT:
+
  break;
      Serial.println("Sync Timeout ");
+
  case DHT_ERROR_DATA_TIMEOUT:
      break;
+
  Serial.println("Data Timeout ");
    case DHT_ERROR_DATA_TIMEOUT:
+
  break;
      Serial.println("Data Timeout ");
+
  case DHT_ERROR_TOOQUICK:
      break;
+
  Serial.println("Polled to quick ");
    case DHT_ERROR_TOOQUICK:
+
  break;
      Serial.println("Polled to quick ");
 
      break;
 
   }
 
  
 
(3)Test Results
 
(3)Test Results

Latest revision as of 11:25, 19 April 2016

Introduction

This is a powerful sister version of our Linker kit - Temperature and Humidity Sensor. It has more complete and accurate performance. The detecting range of this sensor is 5% RH - 99% RH, and -40°C - 80°C. And its accuracy satisfyingly reaches up to 2% RH and 0.5°C. A professional choice for applications that have relatively strict requirements.

1-214.jpg

1-215.jpg


Specification

1-209.jpg

Platforms Supported

  • Arduino
  • Raspberry Pi

Test

Test tools and test

(1)Test tools

  • Arduino UNO x 1 
  • Linker Base Shield x 1
  • Linker temperature & humidity sensor x1

1-210.png

(2)、Program

  #include <DHT22.h>
  // Only used for sprintf
  #include <stdio.h>
  // Data wire is plugged into port 7 on the Arduino
  // Connect a 4.7K resistor between VCC and the data pin (strong pullup)
  #define DHT22_PIN 7
  // Setup a DHT22 instance
  DHT22 myDHT22(DHT22_PIN);
  void setup(void)
 {
 // start serial port
 Serial.begin(9600);
 Serial.println("DHT22 Library Demo");
 }
  void loop(void)
  { 
  DHT22_ERROR_t errorCode;
 // The sensor can only be read from every 1-2s, and requires a minimum
 // 2s warm-up after power-on.
 delay(2000);
 Serial.print("Requesting data...");
 errorCode = myDHT22.readData();
 switch(errorCode)
 {
 case DHT_ERROR_NONE:
 Serial.print("Got Data ");
 Serial.print(myDHT22.getTemperatureC());
 Serial.print("C ");
 Serial.print(myDHT22.getHumidity());
 Serial.println("%");
 // Alternately, with integer formatting which is clumsier but more compact to store and
 // can be compared reliably for equality:
 //
 char buf[128];
 sprintf(buf, "Integer-only reading: Temperature %hi.%01hi C, Humidity %i.%01i %% RH",
 myDHT22.getTemperatureCInt()/10, abs(myDHT22.getTemperatureCInt()%10),
 myDHT22.getHumidityInt()/10, myDHT22.getHumidityInt()%10);
 Serial.println(buf);
 break;
 case DHT_ERROR_CHECKSUM:
 Serial.print("check sum error ");
 Serial.print(myDHT22.getTemperatureC());
 Serial.print("C ");
 Serial.print(myDHT22.getHumidity());
 Serial.println("%");
 break;
 case DHT_BUS_HUNG:
 Serial.println("BUS Hung ");
 break;
 case DHT_ERROR_NOT_PRESENT:
 Serial.println("Not Present ");
 break;
 case DHT_ERROR_ACK_TOO_LONG:
 Serial.println("ACK time out ");
 break;
 case DHT_ERROR_SYNC_TIMEOUT:
 Serial.println("Sync Timeout ");
 break;
 case DHT_ERROR_DATA_TIMEOUT:
 Serial.println("Data Timeout ");
 break;
 case DHT_ERROR_TOOQUICK:
 Serial.println("Polled to quick ");
 break;

(3)Test Results

1-211.png

Documents

Test code download