dht22  2.0.0.0
Functions
Public function

Functions

void dht22_cfg_setup (dht22_cfg_t *cfg)
 Config Object Initialization function. More...
 
err_t dht22_init (dht22_t *ctx, dht22_cfg_t *cfg)
 Initialization function. More...
 
err_t dht22_start_signal (dht22_t *ctx)
 Sends start signal to the sensor function. More...
 
err_t dht22_check_sensor_response (dht22_t *ctx, uint8_t *check_out)
 Release the bus to wait the sensor response signal function. More...
 
err_t dht22_get_sensor_data (dht22_t *ctx, uint32_t *data_out)
 Reading data from the sensor function. More...
 
uint16_t dht22_get_temperature (dht22_t *ctx, uint32_t sensor_data)
 Get the temperature data function. More...
 
float dht22_calculate_temperature (dht22_t *ctx, uint32_t sensor_data)
 Calculate the temperature in degrees Celsius function. More...
 
uint16_t dht22_get_humidity (dht22_t *ctx, uint32_t sensor_data)
 Get the humidity data function. More...
 
float dht22_calculate_humidity (dht22_t *ctx, uint32_t sensor_data)
 Calculate the humidity in percentage function. More...
 
err_t dht22_init_sda_input (dht22_t *ctx)
 Init SDA data pin as input. More...
 
err_t dht22_init_sda_output (dht22_t *ctx)
 Init SDA data pin as output. More...
 

Detailed Description

Function Documentation

◆ dht22_calculate_humidity()

float dht22_calculate_humidity ( dht22_t ctx,
uint32_t  sensor_data 
)

Calculate the humidity in percentage function.

Parameters
ctxClick object.
sensor_data32-bit read value from the sensor ( temperature and humidity data ).
Returns
Float percentage of relative humidity [ % RH ].

@description The function calculate the percentage of humidity [ % RH ] from sensor data reading from the sensor AM2302 on the DHT22 Click.

◆ dht22_calculate_temperature()

float dht22_calculate_temperature ( dht22_t ctx,
uint32_t  sensor_data 
)

Calculate the temperature in degrees Celsius function.

Parameters
ctxClick object.
sensor_data32-bit read value from the sensor ( temperature and humidity data ).
Returns
Float temperature value in degrees Celsius [ C ].

@description The function calculate the temperature in degrees Celsius [ C ] from sensor data reading from the sensor AM2302 on the DHT22 Click.

◆ dht22_cfg_setup()

void dht22_cfg_setup ( dht22_cfg_t cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ dht22_check_sensor_response()

err_t dht22_check_sensor_response ( dht22_t ctx,
uint8_t *  check_out 
)

Release the bus to wait the sensor response signal function.

Parameters
ctxClick object.
check_out0 : ERROR, Sensor not responding. 1 : The sensor responded and is ready to read data.
Returns
0 - Ok, (-1) - Error.

@description The function release the bus to wait the sensor response signal from the sensor AM2302 on the DHT22 Click.

Note
Before calling this function it is necessary to :
  • 1. : sends start signal to the sensor by calling dht22_start_signal function.
  • 2. : set the SDA pin as input.

◆ dht22_get_humidity()

uint16_t dht22_get_humidity ( dht22_t ctx,
uint32_t  sensor_data 
)

Get the humidity data function.

Parameters
ctxClick object.
sensor_data32-bit read value from the sensor ( temperature and humidity data ).
Returns
16-bit humidity data.

@description The function calculate the humidity data from sensor data reading from the sensor AM2302 on the DHT22 Click.

Note
The 16-bit humidity data should be divided by 10 to obtain the exact percentage of humidity [ % RH ].

◆ dht22_get_sensor_data()

err_t dht22_get_sensor_data ( dht22_t ctx,
uint32_t *  data_out 
)

Reading data from the sensor function.

Parameters
ctxClick object.
data_out32-bit read value from the sensor ( temperature and humidity data ).
Returns
0 - Ok, (-1) - Error.

@description The function reading data from the sensor AM2302 on the DHT22 Click.

Note
Before calling this function it is necessary to :
  • 1. : set the SDA pin as output.
  • 2. : sends start signal to the sensor by calling #dht22_start_ignal function.
  • 3. : set the SDA pin as input.
  • 4. : release the bus to wait the sensor response signal by calling dht22_check_sensor_response function.

◆ dht22_get_temperature()

uint16_t dht22_get_temperature ( dht22_t ctx,
uint32_t  sensor_data 
)

Get the temperature data function.

Parameters
ctxClick object.
sensor_data32-bit read value from the sensor ( temperature and humidity data ).
Returns
16-bit temperature data.

@description The function calculate the temperature data from sensor data reading from the sensor AM2302 on the DHT22 Click.

Note
The 16-bit temperature data should be divided by 10 to obtain the exact temperature value in degrees Celsius [ C ].

◆ dht22_init()

err_t dht22_init ( dht22_t ctx,
dht22_cfg_t cfg 
)

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.
Returns
0 - Ok, (-1) - Error.

@description This function initializes all necessary pins and peripherals used for this click.

◆ dht22_init_sda_input()

err_t dht22_init_sda_input ( dht22_t ctx)

Init SDA data pin as input.

Parameters
ctxClick object.
Returns
0 - Ok, (-1) - Error.

@description This function initializes SDA data pin as input.

◆ dht22_init_sda_output()

err_t dht22_init_sda_output ( dht22_t ctx)

Init SDA data pin as output.

Parameters
ctxClick object.
Returns
0 - Ok, (-1) - Error.

@description This function initializes SDA data pin as output.

◆ dht22_start_signal()

err_t dht22_start_signal ( dht22_t ctx)

Sends start signal to the sensor function.

Parameters
ctxClick object.
Returns
0 - Ok, (-1) - Error.

@description The function sends the start signal to the tempemperature and humidity sensor AM2302 on the DHT22 Click.

Note
Before calling this function it is necessary to set the SDA pin as output.