Hi everyone, I am trying to read temperature and humidity from DHT11 sensor. but it got an error :" Error reading values". I am debugging the “dht.c” code and find in " _wait_for_level" function there is problem. When the code try to (gpio_read(pin)), it can not do this. So, because of the finishing timer it return an error. I increased the timer but still it does not work. I attach my setup (arduino-uno+dht11)
as well as my code. I will be very appreciate if any one can help meBlockquote
#define DELAY (10 * US_PER_SEC)
int main(void)
{
/* Fix port parameter for digital sensor */
dht_params_t my_params;
my_params.pin = GPIO_PIN(PORT_D, 2);
my_params.in_mode = DHT_PARAM_PULL;
/* Initialize digital sensor */
dht_t dev;
int16_t temp, hum;
if (dht_init(&dev, &my_params) == DHT_OK) {
printf("DHT sensor connected\n");
}
else {
printf("Failed to connect to DHT sensor\n");
return 1;
}
while (1) {
if (dht_read(&dev, &temp, &hum) != DHT_OK) {
puts("Error reading values");
continue;
}
printf("DHT values - temp: %d.%d°C - relative humidity: %d.%d%%\n",
temp/10, temp%10, hum/10, hum%10);
xtimer_usleep(DELAY);
}
return 0;
}