Bosch Sensortec Community

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

    STM32 BM680, bsec_set_configuration

    STM32 BM680, bsec_set_configuration

    JohFlo
    Member

    Hi,

     

    How can I load the "generic_33v_3s_4d" configuation on a STM32 to bsec_set_configuration();

     

    Johannes

     

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hi JohFlo,

    Could you give detailed description? For example the link of example code you used, your modification, etc.

    I use the standard bsec_iot_Init() from bsec 1.4.8.

    return_values_init bsec_iot_init(float sample_rate, float temperature_offset, bme680_com_fptr_t bus_write, 
                        bme680_com_fptr_t bus_read, sleep_fct sleep, state_load_fct state_load, config_load_fct config_load)
    {
        return_values_init ret = {BME680_OK, BSEC_OK};
        bsec_library_return_t bsec_status = BSEC_OK;
        
        uint8_t bsec_state[BSEC_MAX_STATE_BLOB_SIZE] = {0};
        uint8_t bsec_config[BSEC_MAX_PROPERTY_BLOB_SIZE] = {0};
        uint8_t work_buffer[BSEC_MAX_WORKBUFFER_SIZE] = {0};
        int bsec_state_len, bsec_config_len;
        
        /* Fixed I2C configuration */
        bme680_g.dev_id = BME680_I2C_ADDR_PRIMARY;
        bme680_g.intf = BME680_I2C_INTF;
        /* User configurable I2C configuration */
        bme680_g.write = bus_write;
        bme680_g.read = bus_read;
        bme680_g.delay_ms = sleep;
        
        /* Initialize BME680 API */
        ret.bme680_status = bme680_init(&bme680_g);
        if (ret.bme680_status != BME680_OK)
        {
            return ret;
        }
        
        /* Initialize BSEC library */
        ret.bsec_status = bsec_init();
        if (ret.bsec_status != BSEC_OK)
        {
            return ret;
        }
        
        /* Load library config, if available */
        bsec_config_len = config_load(bsec_config, sizeof(bsec_config));
        if (bsec_config_len != 0)
        {       
            ret.bsec_status = bsec_set_configuration(bsec_config, bsec_config_len, work_buffer, sizeof(work_buffer));     
            if (ret.bsec_status != BSEC_OK)
            {
                return ret;
            }
        }
        
        /* Load previous library state, if available */
        bsec_state_len = state_load(bsec_state, sizeof(bsec_state));
        if (bsec_state_len != 0)
        {       
            ret.bsec_status = bsec_set_state(bsec_state, bsec_state_len, work_buffer, sizeof(work_buffer));     
            if (ret.bsec_status != BSEC_OK)
            {
                return ret;
            }
        }
        
        /* Set temperature offset */
        bme680_temperature_offset_g = temperature_offset;
        
        /* Call to the function which sets the library with subscription information */
        ret.bsec_status = bme680_bsec_update_subscription(sample_rate);
        if (ret.bsec_status != BSEC_OK)
        {
            return ret;
        }
        
        return ret;
    }

     

    How can I use the generic config files . The use like on ESP does not work.

     

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hi JohFlo,

    Did you copy config file bsec_config_iaq from "BSEC_1.4.8.0_Generic_Release\config\generic_33v_3s_4d\bsec_serialized_configurations_iaq.c"?

    uint32_t config_load(uint8_t *config_buffer, uint32_t n_buffer)
    {
    // ...
    // Load a library config from non-volatile memory, if available.
    //
    // Return zero if loading was unsuccessful or no config was available,
    // otherwise return length of loaded config string.
    // ...
    memcpy(config_buffer, bsec_config_iaq, sizeof(bsec_config_iaq));
    return 0;
    }

    Thanks, that was the solution.

    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