.i2c_port = 0,
.scl_io_num = CONFIG_RHT_SCL_PIN,
.sda_io_num = CONFIG_RHT_SDA_PIN,
- .glitch_ignore_cnt = 0,
+ .glitch_ignore_cnt = 7,
.flags.enable_internal_pullup = false, //true,
};
i2c_device_config_t dev_cfg = {
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.device_address = CONFIG_RHT_ADDRESS,
- .scl_speed_hz = 400000,
+ .scl_speed_hz = 100000,
};
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &rht_handle));
+ /*ESP_LOGE(TAG, "reset bus");
+ uint8_t send_cmd[1] = CMD_SOFT_RESET;
+ esp_err_t check_done = i2c_master_transmit(rht_handle, send_cmd, sizeof(send_cmd), 100);
+ ESP_LOGE(TAG, "done: %s", esp_err_to_name(check_done));*/
+
return true;
}
ESP_LOGI(TAG, "fetching rht data");
//ESP_ERROR_CHECK(i2c_master_transmit_receive(rht_handle, send_cmd, 2, buf, 6, -1));
- esp_err_t tx_check = i2c_master_transmit(rht_handle, send_cmd, sizeof(send_cmd), -1);
+ esp_err_t tx_check = i2c_master_transmit(rht_handle, send_cmd, sizeof(send_cmd), 100);
ESP_LOGE(TAG, "i2c transmit status is %s", esp_err_to_name(tx_check));
if (tx_check != ESP_OK){
+ ESP_LOGE(TAG, "reset bus");
+ uint8_t send_cmd[1] = CMD_SOFT_RESET;
+ esp_err_t check_done = i2c_master_transmit(rht_handle, send_cmd, sizeof(send_cmd), 100);
+ ESP_LOGE(TAG, "done: %s", esp_err_to_name(check_done));
return -1;
}
// delay to allow measurement time to finish
vTaskDelay( pdMS_TO_TICKS(10) );
- esp_err_t rx_check = i2c_master_receive(rht_handle, buf, 6, -1);
+ esp_err_t rx_check = i2c_master_receive(rht_handle, buf, 6, 100);
ESP_LOGE(TAG, "i2c receive status is %s", esp_err_to_name(rx_check));
if (rx_check != ESP_OK){
+ ESP_LOGE(TAG, "reset bus");
+ uint8_t send_cmd[1] = CMD_SOFT_RESET;
+ esp_err_t check_done = i2c_master_transmit(rht_handle, send_cmd, sizeof(send_cmd), 100);
+ ESP_LOGE(TAG, "done: %s", esp_err_to_name(check_done));
return -1;
}
// doesn't really matter when we start the counting loop, so just block until we have the semaphore
// (should only be unavailable if another task is updating, or more likely we're generating the report)
- xSemaphoreTake(report_data.mutex, portMAX_DELAY);
+ //xSemaphoreTake(report_data.mutex, portMAX_DELAY);
report_data.humidity = sensor_rh;
- xSemaphoreGive(report_data.mutex);
+ //xSemaphoreGive(report_data.mutex);
return -1;