Contiki-NG
|
Files | |
file | dht11-sensor.c |
DHT 11 sensor implementation. | |
file | dht11-sensor.h |
DHT 11 sensor header file. | |
Macros | |
#define | DHT11_SIGNAL_HIGH (1) |
GPIO High. | |
#define | DHT11_SIGNAL_LOW (0) |
GPIO Low. | |
#define | DHT11_SIGNAL_START_PHASE1_DURATION (40) |
Duration of signal start phase 1 according to data sheet. | |
#define | DHT11_SIGNAL_START_PHASE2_DURATION (80) |
Duration of signal start phase 2 according to data sheet. | |
#define | DHT11_SIGNAL_START_PHASE3_DURATION (80) |
Duration of signal start phase 3 according to data sheet. | |
#define | DHT11_SIGNAL_RESPONSE_PHASE1_DURATION (50) |
Duration of signal response phase 1 according to data sheet. | |
#define | DHT11_SIGNAL_RESPONSE_BIT_0_DURATION (28) |
Duration of signal response if bit is set to 0, according to data sheet. | |
#define | DHT11_SIGNAL_RESPONSE_BIT_1_DURATION (70) |
Duration of signal response if bit is set to 1, according to data sheet. | |
#define | DHT11_TICKS_GUARD (1) |
Sensor timer drift in ticks. | |
#define | DHT11_US_GUARD RTIMERTICKS_TO_US(1) |
Sensor timer drift in us from rtimer. | |
#define | DHT11_DATA_SAMPLES (40) |
Number of data requests. | |
#define | DHT11_DATA_SIZE (5) |
Number of bytes in data. | |
#define | DHT11_SAMPLING_RATE_SECONDS (1) |
DHT11 maximum sample rate is 1 Hz (1 second) | |
#define | DHT11_CONFIGURE_GPIO_PORT (0) |
DHT11 Configuration type for GPIO Port. | |
#define | DHT11_CONFIGURE_GPIO_PIN (1) |
DHT11 Configuration type for GPIO Pin. | |
#define | DHT11_VALUE_HUMIDITY_INTEGER (0) |
DHT11 value type for humidity integer part. | |
#define | DHT11_VALUE_HUMIDITY_DECIMAL (1) |
DHT11 value type for humidity decimal part. | |
#define | DHT11_VALUE_TEMPERATURE_INTEGER (2) |
DHT11 value type for temperature integer part. | |
#define | DHT11_VALUE_TEMPERATURE_DECIMAL (3) |
DHT11 value type for temperature decimal part. | |
#define | DHT11_STATUS_OKAY (0) |
DHT11 status okay. | |
#define | DHT11_STATUS_TIMEOUT (1) |
DHT11 status timeout. | |
#define | DHT11_STATUS_CHECKSUM_FAILED (2) |
DHT11 status checksum failed. | |
Functions | |
static uint8_t | dht_read (void) |
Variables | |
static dht_t | dht |
DHT struct. | |
#define DHT11_TICKS_GUARD (1) |
Sensor timer drift in ticks.
DHT uses 1us granularity and rtimer granularity is higher. So, allow the reading to drift by 1 tick
Definition at line 106 of file dht11-sensor.c.
#define DHT11_US_GUARD RTIMERTICKS_TO_US(1) |
Sensor timer drift in us from rtimer.
DHT uses 1us granularity and rtimer granularity is higher. So, allow the reading to drift by 1 tick in us
Definition at line 115 of file dht11-sensor.c.
Referenced by dht_read().
|
static |
Data Single-bus free status is at high voltage level. When the communication between MCU and DHT11 begins, the programme of MCU will set Data Single-bus voltage level from high to low and this process must take at least 18ms to ensure DHT’s detection of MCU's signal, then MCU will pull up voltage and wait 20-40us for DHT’s response.
Once DHT detects the start signal,it will send out a low-voltage-level response signal, which lasts 80us. Then the programme of DHT sets Data Single-bus voltage level from low to high and keeps it for 80us for DHT’s preparation for sending data.
When DHT is sending data to MCU, every bit of data begins with the 50us low-voltage-level and the length of the following high-voltage-level signal determines whether data bit is "0" or "1"
26-28us voltage-length means data "0" 70us voltage-length means 1 bit data "1"
Definition at line 229 of file dht11-sensor.c.
References dht, DHT11_DATA_SAMPLES, DHT11_DATA_SIZE, DHT11_SIGNAL_HIGH, DHT11_SIGNAL_LOW, DHT11_SIGNAL_RESPONSE_BIT_0_DURATION, DHT11_SIGNAL_RESPONSE_BIT_1_DURATION, DHT11_SIGNAL_RESPONSE_PHASE1_DURATION, DHT11_SIGNAL_START_PHASE1_DURATION, DHT11_SIGNAL_START_PHASE2_DURATION, DHT11_SIGNAL_START_PHASE3_DURATION, DHT11_STATUS_CHECKSUM_FAILED, DHT11_STATUS_OKAY, DHT11_STATUS_TIMEOUT, DHT11_US_GUARD, and RTIMER_BUSYWAIT.