Added a random error checking function
Not actually sure I'll use it?
This commit is contained in:
@@ -12,6 +12,15 @@ static const char* TAG = "DHT22";
|
||||
deci_percent _dht22_relative_humidity = UINT16_MAX;
|
||||
deci_degrees_c _dht22_temperature = INT16_MIN;
|
||||
|
||||
void dht22_handle_error(dht22_error e) {
|
||||
if (e == DHT22_OK) {
|
||||
ESP_LOGI(TAG, "No errors reading DHT22 value");
|
||||
} else if (e == DHT22_CHECKSUM_ERROR) {
|
||||
ESP_LOGE(TAG, "Error calculating checksum");
|
||||
} else if (e == DHT22_TIMING_ERROR) {
|
||||
ESP_LOGE(TAG, "Timing error while obtaining data");
|
||||
}
|
||||
}
|
||||
|
||||
dht22_error dht22_read() {
|
||||
uint8_t data[5] = {0};
|
||||
@@ -28,7 +37,6 @@ dht22_error dht22_read() {
|
||||
if (checksum_val != data[4]) {
|
||||
_dht22_relative_humidity = UINT16_MAX;
|
||||
_dht22_temperature = INT16_MIN;
|
||||
ESP_LOGE(TAG, "Error in final checksum check");
|
||||
return DHT22_CHECKSUM_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user