fixed dht22 driver and example

This commit is contained in:
Antonio Iannopollo 2018-05-09 19:25:08 -07:00
parent 46e1633c19
commit 51a4960fa8
3 changed files with 3 additions and 4 deletions

View File

@ -72,7 +72,7 @@ dht22_read(void)
{
uint8_t i;
uint8_t j = 0;
uint8_t last_state;
uint8_t last_state = 0xFF;
uint8_t counter = 0;
uint8_t checksum = 0;
@ -95,7 +95,6 @@ dht22_read(void)
* if the line is high between 70-74us the bit sent will be "1" (one).
*/
GPIO_SET_INPUT(DHT22_PORT_BASE, DHT22_PIN_MASK);
last_state = GPIO_READ_PIN(DHT22_PORT_BASE, DHT22_PIN_MASK);
for(i = 0; i < DHT22_MAX_TIMMING; i++) {
counter = 0;

View File

@ -90,7 +90,7 @@
#define DHT22_COUNT 8 /**< Minimum ticks to detect a "1" bit */
#define DHT22_MAX_TIMMING 85 /**< Maximum ticks in a single operation */
#define DHT22_READING_DELAY 1 /**< 1 us */
#define DHT22_READY_TIME 20 /**< 40 us */
#define DHT22_READY_TIME 40 /**< 40 us */
#define DHT22_START_TIME (RTIMER_SECOND / 50) /**< 20 ms */
#define DHT22_AWAKE_TIME (RTIMER_SECOND / 4) /**< 250 ms */
/** @} */

View File

@ -55,7 +55,7 @@ static struct etimer et;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(remote_dht22_process, ev, data)
{
int16_t temperature, humidity;
int temperature, humidity;
PROCESS_BEGIN();
SENSORS_ACTIVATE(dht22);