Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Issue with BME280

    Issue with BME280

    mariswamy
    New Poster

    hello,

     
     
    we are using bosch BME280 sensor for to capture temperature, Humidity and Pressure. but we are running in to issue while reading the values from sensor, we are getting constant garbage values as seen in the attachment.
     
    These are the configurations which i have done:-
     
    i.  we verified that there is no hardware and voltage issues (we are able to read chip id and raw data from registers) 
    ii.  we have taken the code from https://github.com/BoschSensortec/BME280_driver website which is referred by bosh and we integrated with our I2C drivers.
    iii. we have done BME280 initialization as per from the given link https://github.com/BoschSensortec/BME280_driver/blob/master/README.md
     
    iv. and we tried to read data in normal mode as well as forced mode, but we didn't get the proper values.
     
    v. I2C clock:-  250kbps, Address:- BME280_I2C_ADDR_PRIM         UINT8_C(0x76)
     
     
    please help me on this.
     
     
    thanks & regards,
    Swamy M
    3 REPLIES 3

    kgoveas
    Community Moderator
    Community Moderator

    Hi mariswamy,

    Given that the values are not changing, there is a possibility that the oversampling settings are not written into the sensor. This could happen if the I2C write function is not implemented properly. Can you share your implementation of the write function?

    Hi,

    Please find the I2C write function below, nrf_drv_twi_tx  API generated by nordic semiconductor, but these drivers already used for Accelerometer and gyroscope there it is working fine.

     

     

    int8_t BEM280_I2C_Write(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len)
    {

    if( nrf_drv_twi_tx(&m_twi, BME280_I2C_ADDR_PRIM, &reg_addr, 1, 1) == NRF_SUCCESS )
    {
           if(nrf_drv_twi_tx(&m_twi, BME280_I2C_ADDR_PRIM, data, len, 1) == NRF_SUCCESS )
           {
               return 0;
           }
           return 1;
    }
    else
    {
    return 1;
    }
    }

     

    here,

    m_twi :- I2C Instance

    reg_addr:- Location Address where we are writing

    data:- actual data (like sensor settings etc)

    len:- number of bytes (data length)

    1:- no stop

     

     

     

    thanks & regards,

    Swamy M.

    kgoveas
    Community Moderator
    Community Moderator

    Hi mariswamy,

    It is recommended to complete it register address and data write in a single transaction. Assuming that setting the last parameter of the function nrf_drv_twi_tx to 1 allows for a single write sequence, the second call of the function nrf_drv_twi_tx to write the data should have the last parameter set to 0 to complete the transaction. If this doesn't work, then you may have to create a single array of len+1 and copy the register address and data accordingly. 

    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