Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME280 I2C communication

    Established Member

    BME280 I2C communication

    Hi all,
    I'm using a BME280 sensor on I2C bus with a STM32F072 mcu.

    The sensor works as expected, but randomly the I2C bus gets frozen in BUSY state and the sensor is not accessible anymore.

    Is there any advice for this kind of problem?

    This is my I2C configuration:

    /* I2C1 init function */
    void MX_I2C1_Init(void)
    {
    
      hi2c1.Instance = I2C1;
      hi2c1.Init.Timing = 0x00300208;
      hi2c1.Init.OwnAddress1 = 0;
      hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
      hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
      hi2c1.Init.OwnAddress2 = 0;
      hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
      hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
      hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
      if (HAL_I2C_Init(&hi2c1) != HAL_OK)
      {
        Error_Handler();
      }
      /** Configure Analogue filter 
      */
      if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
      {
        Error_Handler();
      }
      /** Configure Digital filter 
      */
      if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
      {
        Error_Handler();
      }
    
    }

    Thank you
    Walter

     

    6 REPLIES 6
    Community Moderator

    Re: BME280 I2C communication

    Please check with  the following questions:

    1)  Is there any device besides BME280 in I2C bus?

    2) Can ChipID correctly be read out? 

    3) Can you  get I2C wave from initialization to normal & abnormal reading data?

    Established Member

    Re: BME280 I2C communication

    Hi Shellywang,

    1) There are: one EEPROM and two temperature sensors.

    2) Yes, the bus works correctly for the most of the time

    3) I can't verify that since the line are not accessible with an oscilloscope

    Thank you
    Walter

    Highlighted
    Community Moderator
    Community Moderator

    Re: BME280 I2C communication

    no matter what causes the i2c bus to get stuck, it can usually be "unstuck" by detecting the event, and toggling the SCL line 9 times (low, high, low, high, etc.).

    That will reset the state machine of all devices on the bus to a "free" state
    Established Member

    Re: BME280 I2C communication

    Yes, that's exactly what I'm doing now to recover the bus functionalities when it hangs up.

    I was trying to understand why this happens to try to avoid 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