Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME280 CHIP_ID wrong

    BME280 CHIP_ID wrong

    Hpmax
    New Poster
    A friend of mine bought a board which I believe is this:

    https://lastminuteengineers.com/bme280-arduino-tutorial/

    I am writing software to poll the sensor for temperature and humidity information. I am using this software:

    https://github.com/BoschSensortec/BME280_driver

    When I run a bme280_init() it fails to detect a device. I threw some printf's in to debug it and it appears that the get_regs() on 0xd0 returns 0x45 for a chip_id rather than 0x60.

    Can anyone explain to me what's going on?
    7 REPLIES 7

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Hpmax,

    Please ensure you set correct BME280 I2C device address when you read chip ID, refer it from BME280 data sheet.

    BME280 I2C interface.png

    If other device had same I2C device address, you could disconnect it first and read BME280 with I2C interface directly.

     

    The "other devices" are soldered to the same PCB that the I2C bus comes off of.  It would not be trivial to "remove" them.  My code includes this:

    struct bme280_dev dev;
    int8_t rslt = BME280_OK;
    uint8_t dev_addr = BME280_I2C_ADDR_PRIM;
    
    dev.intf_ptr = &dev_addr;
    dev.intf = BME280_I2C_INTF;
    dev.read = user_i2c_read;
    dev.write = user_i2c_write;
    dev.delay_ms = user_delay_ms;
    
    rslt = bme280_init(&dev);


    Albeit I think I actually changed the name from dev to bme280_dev.  I believe this should be accessing 0x76.  Based on looking at the website I referenced earlier, it is likely that the BME280 is configured for 0x76, although it's always possible it's 0x77.  Honestly, looking through the bme280_init code, a lot of it really doesn't make sense.  It's nothing like the other I2C device accesses I've used.  I'm used to opening a file descriptor first, and I don't see that anywhere.  Within the bme280_get_regs we have:

    dev->intf_rslt = dev->read(reg_addr, reg_data, len, dev->intf_ptr);

    That's pretty weird, since it looks like read is a function, but the reference seems to be using it as a variable within a structure pointed to by dev.  But this is C, not C++, so...  why would a function be inside a structure?  Where is this defined?  Why no file decriptor, etc?  Why assign a pointer (dev.intf_ptr) to a variable that stores the address, why not just store the address since presumably you are just using it to open the file descriptor?  Or maybe not.  Like I said, I'm really confused about this code.

    Regardles...  was my expectation that I2C writes should work, and that I2C reads should be the logical AND of the two device outputs if multiple devices share an I2C  bus address?  Again, I want to emphasize that my ability to debug this is limited.  I am located in the US, and my friend is in Germany.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Hpmax,

    Do you mean you couldn't confirm your I2C devices address according our data sheet description?

    I think who had hardware board who had ability to debug it.

    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