Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME688 sensor API

    BME688 sensor API

    Rosso9
    Established Member

    Hi, I'm using  the BME688 sensor for a new project with Nordik nRF52832. I find on github the API for using the sensor. The problem is that API's files include the library coines that I'm not able to find anywhere. I would like to ask you if you have it or if you have a structure of the library to implement (because I do not understand what the various functions do). Thanks for your helps

    18 REPLIES 18

    Hello, thank you for sharing and helping me!

    Rosso9
    Established Member

    Hi,

    after lots of trouble I'm making progress.

    Now, the problem is about the getting new data. Indeed, the output is this:

    I2C InterfaceAPI name [bme68x_interface_init]: Tutto ok
    API name [bme68x_init]: Tutto ok
    API name [bme68x_set_conf]: Tutto ok
    API name [bme68x_set_heatr_conf]: Tutto ok
    Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohm), Status
    API name [bme68x_set_op_mode]: Tutto ok
    API name [bme68x_get_data] Warning [2] : No new data found
    API name [bme68x_set_op_mode]: Tutto ok
    API name [bme68x_get_data] Warning [2] : No new data found

    From another issue of Bosch community, I understood that the problem is probably related to the I2C write and read functions I have implemented in the common.c file. 

    I have implemented the functions in this way, is it correct?

    BME68X_INTF_RET_TYPE bme68x_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
    {
        uint8_t dev_addr = *(uint8_t*)intf_ptr; 
        ret_code_t ret_code;
        ret_code = nrf_drv_twi_tx(&i2c_instance, dev_addr, &reg_addr,1,false);
        if(ret_code != NRF_SUCCESS)
        {
            return ret_code;
        }
    
        ret_code = nrf_drv_twi_rx(&i2c_instance,dev_addr, reg_data, len);
        if (ret_code == NRF_SUCCESS) 
            return BME68X_OK;
        else 
            return 1;
    }
    
    
    
    BME68X_INTF_RET_TYPE bme68x_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
    {
        uint8_t dev_addr = *(uint8_t*)intf_ptr;
        ret_code_t ret_code;
        uint8_t send_tmp[10] = {0};
        send_tmp[0] = reg_addr;
        memcpy(send_tmp+1, reg_data, len);
        ret_code = nrf_drv_twi_tx(&i2c_instance, dev_addr, send_tmp, len , false);  
        if (ret_code == NRF_SUCCESS) 
            return BME68X_OK;
        else 
            return 1;
    }

    If the logic of the function is not correct, please could you tell me how I have to make it (the logic of the functions I mean)?

    Thanks

    Minhwan
    Community Moderator
    Community Moderator

    It looks okay. 

    Our i2c functions are simple. 

    Reg_addr is target register, and reg_data is the data you are going to read and write, and len is data length. 

    As long as you implement correctly, it will work. 

    Thank you. 

    Rosso9
    Established Member

    Thanks for  looking at my functions. 

    The code still has the same problem

    API name [bme68x_get_data] Warning [2] : No new data found

    What can I do or try to do to solve the problem? I have no more idea. I attach my common.c file to let you see if it is all correct, if you would like to give it a look.

    Thanks again

    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