I made a simpler test case which highlighted a stupid error on my part when writing to registers. That is fixed, but now I need to see why the self-test fails here:
if ((data[0].humidity < MIN_HUMIDITY) || (data[0].humidity > MAX_HUMIDITY))
self_test_failed++;
and for each entry here:
for (i = 0; i < n_meas; i++) /* Every gas measurement should be valid */
if (!(data[i].status & BME680_GASM_VALID_MSK))
self_test_failed++;
as well as:
if ((cent_res * 5) < 6)
self_test_failed++;
in
analyze_sensor_data()
Any pointers appreciated...
In the register map you showed here, the humidity config in register 0x72 is 0 means humidity measurement is skipped.
Please double check at your side after you fix I2C write issue.
In the code, it is not set as 0.
also the heat profile setting for gas measurement in provided register map is also wrong.
So, can you give me an update register map here for double confirm if all settings write to sensor is correct?
Hi Vincent,
so after this bit of code:
/* Set the temperature, pressure and humidity settings */
sensor.tph_sett.os_hum = BME680_OS_2X;
sensor.tph_sett.os_pres = BME680_OS_4X;
sensor.tph_sett.os_temp = BME680_OS_8X;
sensor.tph_sett.filter = BME680_FILTER_SIZE_3;
/* Set the remaining gas sensor settings and link the heating profile */
sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS;
/* Create a ramp heat waveform in 3 steps */
sensor.gas_sett.heatr_temp = 300; /* degree Celsius */
sensor.gas_sett.heatr_dur = 150; /* milliseconds */
/* Select the power mode */
/* Must be set before writing the sensor configuration */
sensor.power_mode = BME680_FORCED_MODE;
/* Set the required sensor settings needed */
set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL
| BME680_GAS_SENSOR_SEL;
/* Set the desired sensor configuration */
bme680_set_sensor_settings(set_required_settings,&sensor);
Reading the registers should return corresponding values, right? I'll troubleshoot that once you confirm this is correct.
Yes, after bme680_set_sensor_settings, all coresponding settings should be write into registery correctly.
You can check there.
But in the Github code, there is also some other functions before set setting like bme680_get_profile_dur, why i didn't see it in your code screen shot? Did you delete them?
No, I omitted them for brevity, but it goes like:
sensor.intf = BME680_I2C_INTF;
sensor.read = (bme680_com_fptr_t)read;
sensor.write = (bme680_com_fptr_t)write;
sensor.delay_ms = (bme680_delay_fptr_t)user_delay_ms;
sensor.amb_temp = 22;
bme680_init(&sensor);