Hi, I'm currently using a BME280 to read temperature using I2C with STM32 F401RTE. The problem is that I succesfully initialized the sensor but when I read the temperature I got 22.4879 every time. Below I copy the init function for the sensor and the code I use to read the data. I'm using the latest version of bme280 library (v.3.5.1). struct bme280_dev sensore; struct bme280_settings *settings; void init_sensore (){ int8_t rslt = BME280_OK; uint8_t dev_addr = 0x76; int8_t (*read_ptr)(uint8_t, uint8_t *, uint32_t, void *) = &user_i2c_read; int8_t (*write_ptr)(uint8_t, const uint8_t * ,uint32_t, void *) = &user_i2c_write; void (*delay_ptr)(uint32_t, void *) = &user_delay_us; sensore.intf_ptr = &dev_addr; sensore.intf = BME280_I2C_INTF; sensore.read = user_i2c_read; sensore.write = user_i2c_write; sensore.delay_us = user_delay_us; rslt = bme280_init(&sensore); settings->filter = BME280_FILTER_COEFF_16; settings->osr_h = BME280_NO_OVERSAMPLING; settings->osr_p = BME280_NO_OVERSAMPLING;; settings->osr_t = BME280_OVERSAMPLING_1X; settings->standby_time = BME280_STANDBY_TIME_0_5_MS; rslt = bme280_set_sensor_settings(BME280_SEL_ALL_SETTINGS, settings, &sensore); rslt = bme280_set_sensor_mode(BME280_POWERMODE_NORMAL, &sensore); } float read_temperature(){ float temperature; uint32_t period = 40; struct bme280_data comp_data; int8_t rslt; user_delay_us(period, sensore.intf_ptr); rslt = bme280_get_sensor_data(BME280_TEMP, &comp_data, &sensore); temperature = comp_data.temperature; return temperature; }
... View more