10-31-2023 07:28 AM
Hello,
Regarding with the interface BME280 in forced mode, I need help about how to configure settings and how to read data in a minute?
In my work, I can interface the sensor in Normal Mode properly with the Bosh Sensortech API, but I don't know what the configure settins should be and how to get data?
Here is my sample main.c in normal mode:
rslt = bme280_interface_selection(&dev, BME280_I2C_INTF);
bme280_error_codes_print_result("bme280_interface_selection", rslt);
rslt = bme280_init(&dev);
bme280_error_codes_print_result("bme280_init", rslt);
/* Always read the current settings before writing, especially when all the configuration is not modified */
rslt = bme280_get_sensor_settings(&settings, &dev);
bme280_error_codes_print_result("bme280_get_sensor_settings", rslt);
/* Configuring the over-sampling rate, filter coefficient and standby time */
/* Overwrite the desired settings */
settings.filter = BME280_FILTER_COEFF_OFF;
/* Over-sampling rate for humidity, temperature and pressure */
settings.osr_h = BME280_OVERSAMPLING_1X;
settings.osr_p = BME280_OVERSAMPLING_1X;
settings.osr_t = BME280_OVERSAMPLING_1X;
/* Setting the standby time */
settings.standby_time = BME280_STANDBY_TIME_1000_MS;
rslt = bme280_set_sensor_settings(BME280_SEL_ALL_SETTINGS, &settings, &dev);
bme280_error_codes_print_result("bme280_set_sensor_settings", rslt);
/* Always set the power mode after setting the configuration */
rslt = bme280_set_sensor_mode(BME280_POWERMODE_NORMAL, &dev);
bme280_error_codes_print_result("bme280_set_power_mode", rslt);
/* Calculate measurement time in microseconds */
rslt = bme280_cal_meas_delay(&period, &settings);
bme280_error_codes_print_result("bme280_cal_meas_delay", rslt);
/* Getting the data */
/* Humidity */
rslt = get_humidity(period, &dev);
bme280_error_codes_print_result("get_humidity", rslt);
/* Pressure */
rslt = get_pressure(period, &dev);
bme280_error_codes_print_result("get_pressure", rslt);
/* Temperature */
rslt = get_temperature(period, &dev);
bme280_error_codes_print_result("get_temperature", rslt);
NOTES:
I am using Nuvoton MCU.
Interface with I2C.
11-01-2023 07:35 AM
Hi selmanonal,
You can refer to attached BME280 example code on STM32 and sensor API https://github.com/boschsensortec/BME280_driver.