Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMP 280 Weird temperatur data with I2C

    Ferrum
    New Poster

    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

    3 REPLIES 3
    FAE_CA1
    Community Moderator

    Re: BMP 280 Weird temperatur data with I2C

    Hi,

    Thanks for your inquiry.

    You can directly use BMP280 API source code at https://github.com/BoschSensortec/BMP280_driver in your project to get final pressure value in the unit of Pa and final temperature value in the unit of degree C. 

    Or you can refer to the attached "sample_calculation_BMP280.xls" to manually input dig_T1, etc other NVM calibration parameters and then manually input BMP280 raw data UT and UP. The Excel file will calculate the FT and FP for you so that you can check if your conversion is correct or not.

    Thanks.

    Ferrum
    New Poster

    Re: BMP 280 Weird temperatur data with I2C

    I already know this library and I also have the calculations from it.The part that confuses me is that I get two wrong values for dig_T3 and Adc_T, the others are "fine". dig_T3 confuses me the most because dig_T2 and dig_T1 are OK. Attached is a screenshot of the debugger. By the way the measured temperature is ~23°C. 

    And even if I could use the library I prefer to write the code I use "myself" because.
    1. I am in an apprenticeship and have the time to write code myself and it also brings me more.
    2. according to everyone who knows programming in my environment, I should not use anyone else's library without understanding it, which I don't do with the one you provide.
    3. i also want to find my mistake so that something similar doesn't happen to me again in the future.
    I hope you understand and don't take this badly.

    FAE_CA1
    Community Moderator

    Re: BMP 280 Weird temperatur data with I2C

    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-e1c8... 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.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist