01-24-2022 01:26 PM
Hi,
I am trying to get compile bme680_init() function only and it interfaced with the BlueNRG-2 (BLE+MCU)module. I am using Keil compiller. Please look below for reference
struct bme680_dev gas_sensor;
/* You may assign a chip select identifier to be handled later */
gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY;
gas_sensor.intf = BME680_I2C_INTF;
gas_sensor.read = i2c_read;
gas_sensor.write = i2c_write;
gas_sensor.delay_ms = 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);
printf("BME680 InIt Result: ");
if(rslt==0)
{
printf("Success");
}
else
{
printf("Error");
}
printf("\n");
But I am getting issue at rslt = bme680_get_regs(BME680_COEFF_ADDR1, coeff_array, BME680_COEFF_ADDR1_LEN, dev);
in get_calib_data () function. Here Program is stuck and getting error in I2C reading. But I am getting proper Chip ID 0x61 while reading chip ID . So I am assuming my I2C lines are working. Also tested with other sensor and confirm I2C line is working. I have also checked about BME680_COEFF_ADDR1 and that is 0x89 given in bme680_def.h file. But It is not mentioned anywhere in datasheet.
Can you please Guide me where I am doing wrong. Please Guide.
Solved! Go to Solution.
02-09-2022 05:35 AM
Hello Minhwan,
I have tried I2C byte by byte reading induvisually instead of multiple byte reading in shot. I got proper result of Temperature, Humidity, Pressure and Altitude but Gas resistance is getting zero Now. Can you refer my code and can you guide me if anything I am doing wrong. I have attached here my main.c code here, Please find the attachment. I have made my own functions . You can see also below Output that I am getting.
CHIP ID: 97
Temperature: 27.510000
Humidity: 50.083008
Pressure: 951.679993
Altitude: 525.671021
Gas: 0.000000
BR
Sudeep
02-09-2022 01:48 PM
Hello Minhwan,
I have sent code today is modified just for your understand below values
tempOversampling = 0x05;
humidOversampling = 0x05; //Setting Humidity Oversampling to factor 16 (default)
pressOversampling = 0x05; //Setting Pressure Oversampling to factor 16 (default)
sensorMode = 0x01;
target_temp =320; // Target Temp 320 degree C
tempOutsideCelsius=15;
pressureSeaLevel = 1013.25; //default value of 1013.25 hPa
IIRfilter=0x04;
Please refer the new attachment. Output is same as shared you in previous message. Temperature, humidity, pressure and altitude values getting are correct. Chip Id is also getting correct.
CHIP ID: 97
Temperature: 27.299999
Humidity: 36.500977
Pressure: 947.539978
Altitude: 561.994995
Gas: 0.000000
Only issue I found that I didnt got new data bit 1 while checking status of new data in gas measurement.
I need to share one thing here, I have just referd one Arduino board code which is working that I have checked with this BME680 sensor that I am using.
Same thing I have implemented in this shared code. Now I got same readings of Temperature, Humidity, Pressure, Altitude. But Didnt got Gas resistance value. For Comparision I have collected logic analyser data for both setup. For Arduino and my board. Values I am getting are same no change just in last when I am trying to check status of new data bit while trying to get gas resistance value there I am not getting that new data bit 1. So thats why I am getting return 0 and therefore gas value showing 0.
Waiting for your reply.
02-09-2022 07:28 PM
Hello Sudeep,
Your source code is register based and you made it yourself. I think you need to check it from your side.
If you want to use just API, please refer to your latest BME68x API.
https://github.com/BoschSensortec/BME68x-Sensor-API
And, I can provide forced mode logic analyzer log, and you can compare it with yours.
Thanks,
02-09-2022 07:54 PM
02-10-2022 05:14 AM
Hello Minhwan,
As you know I have already tried latest API with forced example. But issue is getting in calibration function where I have stucked just because my I2C max read count is 16. Can you please tell me if my I2C read count is max 16 then can I use API with some modifications? as you know in calibration function I2C reads coefficient registers and it reads 25 addresses at a time. Can I modify there to read one by one instead multiple read at a time? Please guide.
I will also refer your logic analyser log to compare with my logic analyser log of forced code.
Thank you again for your valuable guidance.
BR
Sudeep