BMP 280 Weird temperatur data with I2C

Chip: Atmega 2561
Code: C
Sensor: BMP280
Communication: I2C
Problem: I get wrong data from my Bmp280 sensor when I want to know the temperature. To be exact, i even have an inverted value when i make the sensor warmer the displayed temperature becomes colder. the calculation works I tested it with sample numbers. The I2C interface also works, after the id check. The only 2 things that could cause errors are the conversion to the variables or the config.

I hope someone can help me with this

Code_Example.docx
12.8KB
Best reply by FAE_CA1

Hi,

It is ok that you write your own code to operate BMP280 sensor without using library or API. You may refer to Arduino sample code at https://create.arduino.cc/projecthub/SurtrTech/bmp280-measure-temperature-pressure-and-altitude-e1c857 for more information.

From your screenshot, ADC_T should be unsigned integer and dig_T3 should be a negative integer.

Here is what you could do:

1. Check your I2C read function to see if you can always get BMP280 chip_ID value of 0x58 from register 0xD0. If yes, then your I2C read function is working fine.

2. Check your I2C write function. For example you can write value of 0x33 to register 0xF4 to configure BMP280 to be in normal mode with ost_t = x1 and osr_p = x8. Then you can read register 0xF4 to see if the value of 0x33 has been written to this register successfully or not. If yes, then your I2C write function is working fine.

3. Check your I2C burst read function. You can read BMP280 3 bytes pressure data registers from 0xF7 to 0xF9 in one I2C transaction. Or you can read 6 bytes pressure data and temperature data from data registers 0xF7 to 0xFC in one single I2C transaction. And then you can get UT and UP from these 6 bytes data.

4. Check NVM parameters read function.

5. Check if you can convert BMP280 UT and UP raw data together with NVM parameters to correct FT and FP.

Thanks.

View original
3 replies
Resolved