finally a working I2C connection

This commit is contained in:
2020-09-13 19:07:44 -05:00
parent 0d818b033e
commit 618b28bf4e

View File

@@ -64,6 +64,28 @@ void app_main(void)
my_i2c_setup();
my_bme280_init();
int8_t rslt;
uint32_t count = 0;
char msgbuf[128];
struct bme280_data comp_data;
while(1) {
// take BME280 readings.
rslt = bme280_set_sensor_mode(BME280_NORMAL_MODE, &bme280);
bme280.delay_ms(40);
rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, &bme280);
if (rslt != BME280_OK)
ESP_LOGI(TAG, "bme280_get_sensor_data() returned %d", rslt);
snprintf(msgbuf, sizeof(msgbuf), "%.1f C, %0.2f hPa, %0.1f%% (#%04u)",
comp_data.temperature, comp_data.pressure / 100.,
comp_data.humidity, count++);
if (count >= 9999)
count = 0;
ESP_LOGI(TAG, "%s", msgbuf);
vTaskDelay(1600/portTICK_PERIOD_MS);
}
}
static esp_err_t root_get_handler(httpd_req_t *req)