DHT21 AM2301 Temperature & Humidity Sensor (HCSENS0026)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

DHT21 AM2301 Temperature & Humidity Sensor (HCSENS0026)

Post by admin » Thu Oct 06, 2016 9:48 am

Image



The DHT21 digital temperature sensor is one of the commonest from the range of DHT temperature sensors and boasts a relatively high temperature measurement accuracy of 0.5oC in 0.1oC steps with a relative humidity accuracy of +/- 3%. It has only 3 wires, including power and ground, meaning only one digital pin is required to interface it to a microcontroller. For Arduino development platforms the sensor is very well supported by the DHT library available from the Arduino Playground website.

Image



Specification:

Product Code: HCSENS0026
Model: AM2301
Power supply: 3.3-5V DC
Output signal: digital signal via single-bus
Sensing element: Polymer humidity capacitor
Measuring range: humidity 0-100%RH; temperature -40~80Celsius
Accuracy: humidity +-3%RH(Max +-5%RH); temperature <+-1Celsius
Resolution or sensitivity: humidity 0.1%RH; temperature 0.1Celsius
Repeatability: humidity +-1%RH; temperature +-0.2Celsius
Humidity hysteresis: +-0.3%RH
Long-term Stability: +-0.5%RH/year
Sensing period: Average: 2s
Dimensions size 59*27*13.5mm



Example Arduino Sketch:

Code: Select all

/* FILE:    DHT21_Example
   DATE:    06/10/16
   VERSION: 0.1
   AUTHOR:  Andrew Davies
   
This example sketch uses the DHT library available from the Arduino playground here:

http://playground.arduino.cc//Main/DHTLib

Simply connect your DHT21 sensor to the Arduino digital pin 5, upload this sketch
and then open a the serial monitor window with a BAUD rate of 9600.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/


#include "dht.h"

dht DHT21;

#define DATA_PIN 5 // Digital pin connected the DHT21 data pin.

void setup() 
{
  Serial.begin(9600);
}


void loop() 
{
  /* Take a reading from the sensor */
  int State = DHT21.read21(DATA_PIN);

  /*  If reading was successful then output the results to the serial port */
  if(State == DHTLIB_OK)
  {
    Serial.print("Temperature: ");
    Serial.println(DHT21.temperature, 1);
    Serial.print("Humidity: ");
    Serial.println(DHT21.humidity, 1);
    Serial.println("");
  }

  /* Wait a second before looping back */
  delay(1000);
}


Image

DHT library:
DHTLib.zip
Please note that this version of library is not compatible with ARM based devices such as the ESP8266. If you wish to use the sensor with an ESP8266 then please check out the following library:

https://github.com/RobTillaart/Arduino/ ... /DHTstable

Please note that the above url links to an external library which not maintained by Hobby Components. Use of this library is therefore at your own risk.


Datasheet:
AM2301_Datasheet.pdf

Disclaimer: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

DAJ
Posts: 6
Joined: Tue Jun 05, 2018 4:37 pm

Re: DHT21 AM2301 Temperature & Humidity Sensor (HCSENS0026)

Post by DAJ » Wed Jul 25, 2018 8:43 pm

admin wrote: DHT library:
DHTLib.zip
That library is fine for 8-bit CPUs, but won't compile for the ESP8266 and ARM-based Arduinos.

The original author, Rob Tillaart, has a new version updated for both 8-bit and 32-bit architectures on github. That compiles for the ESP8266 (with a few warnings) and seems to work well.

https://github.com/RobTillaart/Arduino/ ... /DHTstable

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: DHT21 AM2301 Temperature & Humidity Sensor (HCSENS0026)

Post by andrew » Thu Jul 26, 2018 8:42 am

The ESP devices are becoming very popular now that they are well supported by the Arduino IDE. I've added the url to the first post - thanks for your post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Sensors”