Here is the part of the code which reproduce the issue. It does not include the ESP32 specific part, but if you think is relevant i can share it also. static int get_bmp_data(bmp_data_t *bmpdata)
{
int res = BMP2_E_COM_FAIL;
uint8_t reg_addr = 0xf4, reg_data;
struct bmp2_status bmps;
if(bmpdev.power_mode == BMP2_POWERMODE_FORCED)
{
reg_data = 0;
reg_data = osrs_t << 5 | osrs_p << 2 | 1;
res = bmp2_set_regs(®_addr, ®_data, 1, &bmpdev);
}
else
res = BMP2_OK;
if(res == BMP2_OK)
{
if(bmpdev.power_mode == BMP2_POWERMODE_FORCED)
{
while((res = bmp2_get_status(&bmps, &bmpdev) == BMP2_OK) && bmps.measuring == 1)
{
vTaskDelay(pdMS_TO_TICKS(10));
//ESP_LOGI(TAG, "bmp280 busy");
}
}
res = bmp2_get_sensor_data(bmpdata, &bmpdev);
if(res == BMP2_OK)
{
char buf[50];
ESP_LOGI(TAG, "Temperature = %8.3f", bmpdata->temperature);
ESP_LOGI(TAG, "Pressure = %8.3f", bmpdata->pressure);
//sprintf(buf, "%.3f\1%.3f", bmpdata->temperature, bmpdata->pressure);
//publish_state(buf, 0, 0);
}
}
return res;
}
main()
{
uint8_t pmode = 0xff;
struct bmp2_config conf;
bmpdev.intf = BMP2_I2C_INTF;
bmpdev.delay_us = my_usleep;
bmpdev.read = bmp280_read;
bmpdev.write = bmp280_write;
bmpdev.intf_ptr = NULL;
int res = i2c_master_init();
res = bmp2_init(&bmpdev);
if(res == BMP2_OK)
{
res = bmp2_get_config(&conf, &bmpdev);
if(res == BMP2_OK)
{
ESP_LOGI(TAG, "bmp280 chip ID: %0x %0x %0x %0x %0x %0x %0x", bmpdev.chip_id, conf.filter, conf.odr, conf.os_mode, conf.os_pres, conf.os_temp, conf.spi3w_en);
ESP_LOGI(TAG, "bmp280 cal param: %6d %6d \n%6d %6d %6d %6d %6d\n%6d %6d %6d %6d %6d", bmpdev.calib_param.dig_t1, bmpdev.calib_param.dig_t2
, bmpdev.calib_param.dig_p1, bmpdev.calib_param.dig_p2, bmpdev.calib_param.dig_p3, bmpdev.calib_param.dig_p4, bmpdev.calib_param.dig_p5
, bmpdev.calib_param.dig_p6, bmpdev.calib_param.dig_p7, bmpdev.calib_param.dig_p8, bmpdev.calib_param.dig_p9, bmpdev.calib_param.dig_p10);
conf.os_mode = BMP2_OS_MODE_ULTRA_HIGH_RESOLUTION;
conf.filter = BMP2_FILTER_COEFF_16;
conf.os_pres = 0; // BMP2_OS_MODE_ULTRA_HIGH_RESOLUTION;
conf.os_temp = 0; //BMP2_OS_MODE_ULTRA_HIGH_RESOLUTION;
conf.odr = BMP2_ODR_500_MS;
res = bmp2_set_power_mode(BMP2_POWERMODE_NORMAL, &conf, &bmpdev);
if(res == BMP2_OK)
{
res = bmp2_get_config(&conf, &bmpdev);
ESP_LOGI(TAG, "bmp280 config: %0x %0x %0x %0x %0x\n", conf.filter, conf.odr, conf.os_pres, conf.os_temp, conf.spi3w_en);
osrs_t = conf.os_temp;
osrs_p = conf.os_pres;
res = bmp2_get_power_mode(&pmode, &bmpdev);
ESP_LOGI(TAG, "bmp280 power mode: %0x", pmode);
}
else
ESP_LOGI(TAG, "error during configuration %d", res);
}
}
if(res != BMP2_OK)
ESP_LOGI(TAG, "Cannot initialize i2c driver. Error = %d", res);
// test for normal mode
bmp_data_t bmpdata;
while(1 && res == BMP2_OK)
{
get_bmp_data(&bmpdata);
vTaskDelay(2000 / portTICK_PERIOD_MS); //wait 2 seconds
}
} and here is some sample log I (02:00:02.675) WESTA OP: bmp280 chip ID: 58 4 4 0 5 2 0
I (02:00:02.676) WESTA OP: bmp280 cal param: 27117 26189
34962 -10618 3024 3525 234
-7 15500 -14600 6000 0
I (02:00:02.680) WESTA OP: bmp280 config: 4 4 5 2 0
I (02:00:02.682) WESTA OP: bmp280 power mode: 3
I (02:00:02.684) WESTA OP: Temperature = 28.135
I (02:00:02.685) WESTA OP: Pressure = 83878.021
I (02:00:05.832) WESTA OP: Temperature = 28.135
I (02:00:05.834) WESTA OP: Pressure = 83878.021
I (11:55:39.467) NTP sync: Notification of a time synchronization event
I (11:55:39.757) NTP sync: local time updated 2023-04-06/11:55:39
I (11:52:27.952) WESTA OP: Temperature = 28.135
I (11:52:27.953) WESTA OP: Pressure = 83878.021
I (11:52:29.952) WESTA OP: Temperature = 28.135
I (11:52:29.953) WESTA OP: Pressure = 83878.021
I (11:52:31.952) WESTA OP: Temperature = 28.135
I (11:52:31.953) WESTA OP: Pressure = 83878.021
I (11:52:33.952) WESTA OP: Temperature = 28.135
I (11:52:33.953) WESTA OP: Pressure = 83878.021
I (11:52:35.952) WESTA OP: Temperature = 28.135
I (11:52:35.953) WESTA OP: Pressure = 83878.021
I (11:52:37.952) WESTA OP: Temperature = 28.135
... View more