Skip to content

Commit

Permalink
rarely dht11 timeout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hary777 committed Apr 25, 2018
1 parent e74a4f5 commit 2bb02f4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion projekt_multisensor/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,15 @@ static void multisensor_app_sendtemp(void)
dht11_data_t sensor_data;
char tmp[10];
int len;
dht11_errorHandle( dht11_getData(&sensor_data) );
int status;
status = dht11_getData(&sensor_data);

if(status == DHT11_TIMEOUT_ERROR){
//wait 100ms
vTaskDelay(5000 / portTICK_PERIOD_MS);
//next try
dht11_errorHandle(dht11_getData(&sensor_data) );
}

len = sprintf(tmp, "%d", sensor_data.temperature);
esp_mqtt_client_publish(mqtt_client_handle, "home/room/temp", tmp, len, 0, 0);
Expand Down

0 comments on commit 2bb02f4

Please sign in to comment.