DHT22 Temp & Humidity Sensor Library  v0.6
Library for the DHT22/CM2302/AM2302 Temperature and Humidity Module
Macros | Functions
dht22.h File Reference

This Propeller C library was created for the DHT22/AM2302/CM2302 temperature and humidity sensor module. More...

Go to the source code of this file.

Macros

#define CELSIUS   0
 
#define FAHRENHEIT   1
 
#define KELVIN   2
 

Functions

char dht22_read (int dht_pin)
 Triggers a reading of the temperature and relative humidity from the sensor module. More...
 
void dht22_set_timeout_ignore (int dht_pin, char ignore_timeout)
 The function is used to set or clear an ignore timeout instruction for modules connected to the specified pin. More...
 
int dht22_getTemp (char temp_units)
 Retrieves the last temperature reading made by the dht22_read() function. More...
 
int dht22_getHumidity ()
 Retrieves the last humidity reading made by the dht22_read() function. More...
 

Detailed Description

This Propeller C library was created for the DHT22 temperature and humidity sensor module.

This Propeller C library was created for the DHT22/CM2302/AM2302 temperature and humidity sensor module.

Author
Matthew Matz
Version
0.6

Function Documentation

◆ dht22_getHumidity()

int dht22_getHumidity ( )

Retrieves the last humidity reading made by the dht22_read() function.

Returns
the last relative humidity read in tenths of a percent.

◆ dht22_getTemp()

int dht22_getTemp ( char  temp_units)

Retrieves the last temperature reading made by the dht22_read() function.

Parameters
temp_unitsallows the temperature unit to be specified in (0) Celsius, (1) Fahrenheit, or (2) Kelvin.
Returns
the temperature read in degree-tenths of the unit specified.

◆ dht22_read()

char dht22_read ( int  dht_pin)

Triggers a reading of the temperature and relative humidity from the sensor module.

This function instructs the temperature and relative humidity sensor module to take a reading.

Note
The sensor can be read every 500ms. If this function is called before 500ms from the previous call has elapsed, the function waits unless the dht22_set_timeout_ignore() function was used to instruct modules on that pin to ignore the 0.5 second minimum timeout.
Parameters
dht_pindefines which Propeller MCU I/O pin the sensor is attached to. Requires a 10 kOhm pullup resistor to 3.3V when connecting to the Propeller MCU.
Returns
1 if a valid checksum was recieved, 0 if the checksum is invalid.

◆ dht22_set_timeout_ignore()

void dht22_set_timeout_ignore ( int  dht_pin,
char  ignore_timeout 
)

The function is used to set or clear an ignore timeout instruction for modules connected to the specified pin.

Parameters
dht_pindefines which pin the sensor is attached to.
ignore_timeoutwhen true (1), the function instructs the Propeller MCU to ignore the protective timeout that prevents the sensor from being read before it is ready. This parameter is set to false (0) by default.