AOSong DHT topic
- Quick Notes
- Sensor Datasheet
- Sensor Constructor
- Example Code
- Reference
-
Detailed Descriptions
Classes for the AOSong DHT digital-output relative humidity and temperature sensor.
Quick Notes
- Applies to AOSong modules:
- DHT11/
CHT11, - DHT21/AM2301, and
- DHT22/
AM2302/ CM2302
- DHT11/
- Depends on the Adafruit DHT library
- Communicate with a single-bus single wire digital signaling protocol
- Can be connected to any digital pin on a Arduino
- The communication with these sensors is slow and interrupts are turned off during communication.
- See the Adafruit DHT library's DHT.cpp for details.
- Could possibly cause issues if used in combination with other interrupt-driven sensors.
- Only 1 can be connected to a system at a time
- Requires a 3.3 - 6V power source
- Sensors should not be polled more frequently than once every 2 seconds
- Uses a Maxim DS18 sensor internally
Sensor Datasheet
Sensor Constructor
Construct a new AOSongDHT object - need the power pin, the data pin, and the sensor type. The pin on the mcu controlling power to the AOSong DHT. Use -1 if it is continuously powered. The type of DHT. Possible values are DHT11, DHT21, AM2301, DHT22, or AM2302.
AOSongDHT::
Parameters
powerPin
dataPin
The pin on the mcu receiving data from the AOSong DHT
type
measurementsToAverage
The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
Example Code
The DHT is used in the menu a la carte example.
Classes
- class AOSongDHT
- The Sensor sub-class for the AOSong digital-output relative humidity and temperature sensor modules.
- class AOSongDHT_Humidity
- The Variable sub-class used for the humidity output from an AOSong DHT.
- class AOSongDHT_Temp
- The Variable sub-class used for the temperature output from an AOSong DHT.
- class AOSongDHT_HI
- The Variable sub-class used for the heat index output calculated from measurements made by an AOSong DHT.
Sensor Variable Counts
The number of variables that can be returned by an AOSong DHT
- #define DHT_NUM_VARIABLES = 3
- Sensor::
_numReturnedValues; the DHT can report 3 values. - #define DHT_INC_CALC_VARIABLES = 0
- Sensor::
_incCalcValues; we don't calculate any additional values.
Sensor Timing
The sensor timing for an AOSong DHT
- #define DHT_WARM_UP_TIME_MS = 1700
- Sensor::
_warmUpTime_ms; DHT warms up in 1700ms (1.7sec). - #define DHT_STABILIZATION_TIME_MS = 0
- Sensor::
_stabilizationTime_ms; We assume the sensor is stable immediately after warm-up. - #define DHT_MEASUREMENT_TIME_MS = 2000
- Sensor::
_measurementTime_ms; DHT takes 2000ms (2s) to complete a measurement.
Humidity
The humidity variable from an AOSong DHT
- Accuracy is ± 2 % RH for DHT22 and ± 5 % RH for DHT11
- Range is 0 to 100 % RH
Construct a new AOSongDHT_
AOSongDHT_
Parameters
parentSense
The parent AOSongDHT providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "DHTHumidity".
- #define DHT_HUMIDITY_RESOLUTION = 1
- Decimals places in string representation; humidity should have 1 (0.1 % RH for DHT22 and 1 % RH for DHT11)
- #define DHT_HUMIDITY_VAR_NUM = 0
- Sensor variable number; humidity is stored in sensorValues[0].
- #define DHT_HUMIDITY_VAR_NAME = "relativeHumidity"
- Variable name in ODM2 controlled vocabulary; "relativeHumidity".
- #define DHT_HUMIDITY_UNIT_NAME = "percent"
- Variable unit name in ODM2 controlled vocabulary; "percent" (percent relative humidity or % RH)
- #define DHT_HUMIDITY_DEFAULT_CODE = "DHTHumidity"
- Default variable short code; "DHTHumidity".
Temperature
The temperature variable from an AOSong DHT
- Accuracy is ±0.5°C for DHT22 and ± ±2°C for DHT11
- Range is -40°C to +80°C
Construct a new AOSongDHT_
AOSongDHT_
Parameters
parentSense
The parent AOSongDHT providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "DHTTemp".
- #define DHT_TEMP_RESOLUTION = 1
- Decimals places in string representation; temperature should have 1 - resolution is 0.1°C.
- #define DHT_TEMP_VAR_NUM = 1
- Sensor variable number; temperature is stored in sensorValues[1].
- #define DHT_TEMP_VAR_NAME = "temperature"
- Variable name in ODM2 controlled vocabulary; "temperature".
- #define DHT_TEMP_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (degrees Celsius, °C)
- #define DHT_TEMP_DEFAULT_CODE = "DHTTemp"
- Default variable short code; "DHTTemp".
Heat Index
The heat index variable from an AOSong DHT
- Heat index is calculated within the Adafruit library from the measured temperature and humidity.
Construct a new AOSongDHT_
AOSongDHT_
Parameters
parentSense
The parent AOSongDHT providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "DHTHI".
- #define DHT_HI_RESOLUTION = 1
- Decimals places in string representation; heat index should have 1 - resolution is 0.1°C.
- #define DHT_HI_VAR_NUM = 2
- Sensor variable number; HI is stored in sensorValues[2].
- #define DHT_HI_VAR_NAME = "heatIndex"
- Variable name in ODM2 controlled vocabulary; "heatIndex".
- #define DHT_HI_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
- #define DHT_HI_DEFAULT_CODE = "DHTHI"
- Default variable short code; "DHTHI".