pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

BME 280 SPI example needs temperature and pressure switched?

Open rvt opened this issue 2 years ago • 0 comments

If we look at the code here : https://github.com/raspberrypi/pico-examples/blob/master/spi/bme280_spi/bme280_spi.c#L229

We can see that both compensate_pressure and compensate_temperature is called. However since compensate_temperature set'st_fine and compensate_pressure uses t_fine in it's calculations they call order should be:

        // These are the raw numbers from the chip, so we need to run through the
        // compensations to get human understandable numbers
        temperature = compensate_temp(temperature);
        pressure = compensate_pressure(pressure);

when done in this order, then the first calculation for pressure is correct. In the current situation the first pressure calculation will show an incorrect readout after compensate_pressure

rvt avatar Dec 01 '23 21:12 rvt