I have connected a BME280 sensor, but I get a constant value for temperature when requested. It reports a value of 22.1,
I'm developing my code using ESP-IDF (using PlatformIO)
I'm using teh Bosch BME280 drive (version 3.3.6).
It appears to connects without error and fetches the value of 22.1. I'm running the read inside a while loop, pausing one second between the setting of forced mode and the reading of the sensor registers. The read call back is executed three times; 1 byte, 1 byte then 8 bytes.
Would posting the raw, uncomensated register values help?
Does the value of 22.1 have any significance?
Solved! Go to Solution.
Can you confirm that the init funtion (bme280_init()) is called and returns without any error/warning? If so, could you please share a snippet of your code including initialization, configuration of the sensor and data read-out?
To verify your raw data and compensation formulas, you could use the spreadsheet shared here, although that should typically not be the case if using the official sensor API.
I grabbed the calibration data and uncompensated values from my code, whilst it was running and fed them into the spreadsheet. The temp of 22.1 matches, so the values it's reading do tally up.
All calls to the bme280 library return a success result.
I get a value of 524288 from the uncompensated temperature registers
I get calibration values of 28462 26902 50 for T1, T2, T3
The library then reports 2210 as the temperature, which corresponds to the spreadsheet you recommended.
The BME280_I2C_bus_write and BME280_I2C_bus_read function pointers are invoked as expected (from my understanding of the I2C protocol.
What am I missing?
My code is like this:
A quick overview at the code provided doesn't show anything outstanding in the process. On the other hand something that could generate unexpected behavior could be that you configure the ".intf" element as "BME280_SPI_INTF", while your code indicates you are rather using an I2C interface. If so, you could try configuring it as "BME280_I2C_INTF". If needed and if you have an oscillosope/logic analyser available, you could also confirm that your I2C frames look as expected (in particular the reg_addr element).