How does it work?
DHT22 Click is based on the DHT22, a digital humidity sensor with an integrated temperature sensor and a calibrated output signal from Aosong Electronics. The DHT22 utilizes an exclusive digital-signal-collecting technique and humidity sensing technology, assuring its reliability and stability. It can read humidity over the full range of 0 to 100% RH with a typical accuracy of ±2-5%, while its maximum temperature range is from -40 to 80°C with a typical accuracy of ±0.5°C.
As mentioned before, the DHT22 uses a capacitive humidity sensor and a thermistor to measure the surrounding air, providing a digital signal for the host controller on one of the two possible mikroBUS™ pins, CS and Int pins of the mikroBUS™ socket marked as SD1 and SD2. The desirable processing line can be selected by an onboard SMD jumper labeled as SDA SEL, placing it in an appropriate position marked as SDA1 or SDA2. This Click board™ only requires careful timing to grab the data. The DHT22 can only get new data once every two seconds, which means that the sensor readings can be up to two seconds old.
This Click board™ can operate with both 3.3V and 5V logic voltage levels selected via the PWR SEL jumper. This way, it is allowed for both 3.3V and 5V capable MCUs to use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.
Specifications
Type
Temperature & humidity
Applications
Can be used for HVAC systems, testing/inspection equipment, consumer goods, automatic control, data loggers, home appliances, and more
On-board modules
DHT22 – digital humidity sensor with an integrated temperature sensor from Aosong Electronics
Key Features
Full range temperature compensated, relative humidity and temperature measurement, calibrated digital signal, outstanding long-term stability, long transmission distance, low power consumption, and more
Interface
GPIO
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V or 5V
Pinout diagram
This table shows how the pinout on DHT22 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
JP1 | PWR SEL | Left | Logic Level Voltage Selection 3V3/5V: Left position 3V3, Right position 5V |
JP2 | SDA SEL | Left | Data Processing Line Selection SDA1/SDA2: Left position SDA1, Right position SDA2 |
DHT22 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | 3.3 | – | 5 | V |
Operating Humidity Range | 0 | – | 100 | %RH |
Humidity Accuracy | ±2 | – | ±5 | %RH |
Temperature Accuracy | – | ±0.5 | – | deg |
Resolution | – | 16 | – | bit |
Operating Temperature Range | -40 | +25 | +80 | °C |
Software Support
We provide a library for the DHT22 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for DHT22 Click driver.
Key functions
-
Sends start signal to the sensor function.
-
Release the bus to wait the sensor response signal function.
-
Reading data from the sensor function.
Example Description
This is a example which demonstrates the use of DHT22 Click board by measuring temperature and relative humidity.
void application_task ( void )
{
uint8_t resp_stat = DHT22_RESP_NOT_READY;
uint32_t sens_meas = 0;
float dht22_temp = 0;
float dht22_hum = 0;
dht22_init_sda_output( &dht22 );
if ( dht22_start_signal( &dht22 ) == DHT22_OK )
{
dht22_init_sda_input( &dht22 );
if ( dht22_check_sensor_response( &dht22, &resp_stat ) == DHT22_OK )
{
if ( resp_stat == DHT22_RESP_READY )
{
if ( dht22_get_sensor_data( &dht22, &sens_meas ) == DHT22_OK )
{
dht22_temp = dht22_calculate_temperature( &dht22, sens_meas );
dht22_hum = dht22_calculate_humidity( &dht22, sens_meas );
log_printf( &logger, " Humidity : %.2f %%rn", dht22_hum );
log_printf( &logger, " Temperature : %.2f degCrn", dht22_temp );
log_printf( &logger, " ---------------------------rn", dht22_temp );
Delay_ms( 1000 );
}
}
}
}
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Dht22
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.
mikroSDK
This Click board™ is supported with mikroSDK – MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.