01-26-2021 04:43 PM
My code is exactly the same as the code here,https://github.com/BoschSensortec/BME680_driver#example-for-reading-all-sensor-data
But there is a issue, printf (", G: %d ohms", data.gas_resistance); there is no output
Other data output is normal。
while(1) { user_delay_ms(meas_period); /* Delay till the measurement is ready */ rslt = bme680_get_sensor_data(&data, &gas_sensor); printf("T: %.2f degC, P: %.2f hPa, H %.2f %%rH ", data.temperature / 100.0f, data.pressure / 100.0f, data.humidity / 1000.0f );//normal /* Avoid using measurements from an unstable heating setup */ if(data.status & BME680_GASM_VALID_MSK) printf(", G: %d ohms", data.gas_resistance);//no output printf("\r\n"); /* Trigger the next measurement if you would like to read data out continuously */ if (gas_sensor.power_mode == BME680_FORCED_MODE) { rslt = bme680_set_sensor_mode(&gas_sensor); } }
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
This is the data I read and write, I use i2c
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x51 0xF7 0x30 0x7B 0x0A 0x50 0x52 0xC5 0x80 0x00 0x00 0x3C 0xB6
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x51 0xF7 0x30 0x7B 0x0A 0x40 0x52 0xC3 0x80 0x00 0x00 0x3B 0x36
Solved! Go to Solution.
01-26-2021 04:55 PM
Can you give me some suggestions, thanks!
01-27-2021 12:22 AM
Hello rex,
In github, there is configuration part as well.
https://github.com/BoschSensortec/BME680_driver#example-for-reading-all-sensor-data
I would like to check your configuratoin part also.
Could you upload your whole bme680 code?
Thank you.
01-27-2021 12:35 AM
void bme680_task_process(void){
twi_init_bme680(&twi_cfg_bme);
struct bme680_dev gas_sensor;
gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY;
gas_sensor.intf = BME680_I2C_INTF;
gas_sensor.read = bme680_com_read;
gas_sensor.write = bme680_com_write;
gas_sensor.delay_ms = user_delay_ms;
/* amb_temp can be set to 25 prior to configuring the gas sensor
* or by performing a few temperature readings without operating the gas sensor.
*/
gas_sensor.amb_temp = 25;
int8_t rslt = BME680_OK;
rslt = bme680_init(&gas_sensor);
//Regarding compensation functions for temperature, pressure, humidity and gas we have two implementations.
//- Integer version
//- floating point version
//By default, Integer version is used in the API
NRF_LOG_INFO("%s,id:%x\r\n",__FUNCTION__,gas_sensor.chip_id);
//Example for configuring the sensor in forced mode
uint8_t set_required_settings;
/* Set the temperature, pressure and humidity settings */
gas_sensor.tph_sett.os_hum = BME680_OS_2X;
gas_sensor.tph_sett.os_pres = BME680_OS_4X;
gas_sensor.tph_sett.os_temp = BME680_OS_8X;
gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3;
/* Set the remaining gas sensor settings and link the heating profile */
gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS;
/* Create a ramp heat waveform in 3 steps */
gas_sensor.gas_sett.heatr_temp = 320; /* degree Celsius */
gas_sensor.gas_sett.heatr_dur = 150; /* milliseconds */
/* Select the power mode */
/* Must be set before writing the sensor configuration */
gas_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 */
rslt = bme680_set_sensor_settings(set_required_settings,&gas_sensor);
/* Set the power mode */
rslt = bme680_set_sensor_mode(&gas_sensor);
//reading all sensor data
/* Get the total measurement duration so as to sleep or wait till the
* measurement is complete */
uint16_t meas_period;
bme680_get_profile_dur(&meas_period, &gas_sensor);
struct bme680_field_data data;
char temperature[20];
char pressure[20];
char humidity[20];
while(1)
{
user_delay_ms(meas_period); /* Delay till the measurement is ready */
rslt = bme680_get_sensor_data(&data, &gas_sensor);
sprintf(temperature,"%f",data.temperature / 100.0f);
NRF_LOG_INFO("%s,temperature:%s degC\r\n",__FUNCTION__,temperature); //normal
sprintf(pressure,"%f",data.pressure / 100.0f);
NRF_LOG_INFO("%s,pressure:%s hPa\r\n",__FUNCTION__,pressure); //normal
sprintf(humidity,"%f",data.humidity / 1000.0f);
NRF_LOG_INFO("%s,humidity:%s rH\r\n",__FUNCTION__,humidity); //normal
//printf("T: %.2f degC, P: %.2f hPa, H %.2f %%rH ", data.temperature / 100.0f,
//data.pressure / 100.0f, data.humidity / 1000.0f );
/* Avoid using measurements from an unstable heating setup */
if(data.status & BME680_GASM_VALID_MSK){
NRF_LOG_INFO("%s,gas_resistance:%d ohms\r\n",__FUNCTION__,data.gas_resistance); ////no output
}
//printf(", G: %d ohms", data.gas_resistance);//气体电阻(欧姆)
//printf("\r\n");
gas_sensor.power_mode=BME680_FORCED_MODE;
/* Trigger the next measurement if you would like to read data out continuously */
if (gas_sensor.power_mode == BME680_FORCED_MODE) {
rslt = bme680_set_sensor_mode(&gas_sensor);
}
}
}
01-27-2021 12:43 AM
Hi, minhwan
this is after the last task is run, the logic analyzer gets the data, thank you
write to 0x76 ack data: 0xE0 0xB6
write to 0x76 ack data: 0xD0
read to 0x76 ack data: 0x61
write to 0x76 ack data: 0x89
read to 0x76 ack data: 0x80 0x4D 0x67 0x03 0x30 0x24 0x8D 0x90 0xD7 0x58 0x00 0xE4 0x1E 0x6E 0xFF 0x1F 0x1E 0x00 0x00 0x09 0xFB 0xA8 0xF3 0x1E 0x7F
write to 0x76 ack data: 0xE1
read to 0x76 ack data: 0x3F 0xE7 0x2C 0x00 0x2D 0x14 0x78 0x9C 0xC2 0x66 0xBD 0xE6 0xDF 0x12 0x9D 0x00
write to 0x76 ack data: 0x02
read to 0x76 ack data: 0x16
write to 0x76 ack data: 0x00
read to 0x76 ack data: 0x2F
write to 0x76 ack data: 0x04
read to 0x76 ack data: 0x03
write to 0x76 ack data: 0x5A 0x41 0x64 0x65
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x00
write to 0x76 ack data: 0x75
read to 0x76 ack data: 0x00
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x00
write to 0x76 ack data: 0x72
read to 0x76 ack data: 0x00
write to 0x76 ack data: 0x71
read to 0x76 ack data: 0x00
write to 0x76 ack data: 0x75 0x08 0x74 0x8C 0x72 0x02 0x71 0x10
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xD6 0x80 0x78 0x8A 0x80 0x56 0xEE 0x80 0x00 0x00 0x2D 0xF5
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x70 0x78 0x9F 0x00 0x57 0x01 0x80 0x00 0x00 0x66 0x35
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x50 0x78 0x9E 0x40 0x57 0x17 0x80 0x00 0x00 0x66 0xB5
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x00 0x78 0x9D 0xA0 0x57 0x18 0x80 0x00 0x00 0x66 0x35
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x20 0x78 0x9D 0x30 0x57 0x0A 0x80 0x00 0x00 0x66 0xB5
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x20 0x78 0x9D 0x00 0x56 0xF1 0x80 0x00 0x00 0x66 0x35
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x20 0x78 0x9C 0xC0 0x56 0xD4 0x80 0x00 0x00 0x64 0xF5
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D
write to 0x76 ack data: 0x1D
read to 0x76 ack data: 0x80 0x00 0x50 0xDC 0x50 0x78 0x9C 0xC0 0x56 0xB8 0x80 0x00 0x00 0x65 0x75
write to 0x76 ack data: 0x74
read to 0x76 ack data: 0x8C
write to 0x76 ack data: 0x74 0x8D