Bosch Sensortec Community

    Supporting BME680 with BSEC on ESP32 using deep-sleep

    Highlighted
    Community Moderator

    Re: Supporting BME680 with BSEC on ESP32 using deep-sleep

    Hi Dmitry,

    I was able to get it work with an experimental branch of the BSEC Arduino library.


    ets Jun 8 2016 00:22:57

    rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1044
    load:0x40078000,len:8896
    load:0x40080400,len:5816
    entry 0x400806ac
    000959611: BSEC version 1.4.7.4
    000959612: setState:
    04 07 04 01 3d 00 00 00 00 00 00 00 73 00 00 00
    2d 00 01 01 a9 b4 ad 40 de b8 ad 40 98 28 aa 40
    67 26 aa 40 00 00 00 00 2c 01 25 25 00 00 40 40
    00 00 40 40 00 00 03 00 17 a8 5f 3f 14 0c 00 02
    01 69 1d 00 43 f9 f1 a7 42 10 00 03 01 da 20 97
    40 48 81 d3 41 a1 e6 ef 41 16 00 05 01 40 ac 9c
    d3 de 00 00 00 00 00 00 00 7c fc 8c 52 01 01 0c
    00 09 01 40 ac 9c d3 de 00 00 00 08 00 0a 01 17
    9a d3 41 00 00 00 00 d9 4c 00 00
    000959642: Successfully set state from 957044
    000959646: Sensor init done
    000959890: Temperature raw 26.46 compensated 26.39
    000959891: Humidity raw 29.84 compensated 29.96
    000959891: Pressure 97.78 kPa
    000959891: IAQ 127 accuracy 3
    000959893: Static IAQ 83 accuracy 3
    000959896: Gas resistance 53.03 kOhm
    000959900: getState:
    04 07 04 01 3d 00 00 00 00 00 00 00 73 00 00 00
    2d 00 01 01 a5 b4 ad 40 de b8 ad 40 9c 28 aa 40
    67 26 aa 40 00 00 00 00 2c 01 26 26 00 00 40 40
    00 00 40 40 00 00 03 00 17 a8 5f 3f 14 0c 00 02
    01 b9 3a fe 42 12 cc a6 42 10 00 03 01 5a 25 97
    40 03 83 d3 41 03 d9 ef 41 16 00 05 01 00 84 c8
    7d df 00 00 00 00 00 00 00 7c fc 8c 52 01 01 0c
    00 09 01 00 84 c8 7d df 00 00 00 08 00 0a 01 cf
    9c d3 41 00 00 00 00 f7 ca 00 00
    000959938: Saved state to RTC memory at 959899
    000959942: Deep sleep for 2340 ms. BSEC next call at 962648 ms.

     You can find the sketch in the experimental branch here. The BSEC outputs are configured for LP so as to see the calibration and data changes sooner. 

    Highlighted
    New Poster

    Re: Supporting BME680 with BSEC on ESP32 using deep-sleep

    I just wanted to say thank you!
    The latest update of the experimental library and code example helped me solve my issue with the timestamp in ESP32 after deep sleep.
    I am working on a ESP32 Sensor with epaper and Lora running on battery, so trying to save as much energy as possible.

    Highlighted
    New Poster

    Re: Supporting BME680 with BSEC on ESP32 using deep-sleep

    Maybe one additional note:

    I might be mistaken depending on the implementation of delay on the ESP32, but the usage of the plain delay(period) in the function Bsec::delay_ms(uint32_t period) in bsec.cpp might be wasting valuable power, as the delay is 2 seconds in the example.
    If no background tasks are running like Wifi, it might better be replaced by:
    esp_sleep_enable_timer_wakeup(period * 1000);
    esp_light_sleep_start();
     
    Highlighted
    Community Moderator

    Re: Supporting BME680 with BSEC on ESP32 using deep-sleep

    Hi woessmich,

    You can override that delay function by passing your custom idle task in the  begin function. Note that this is for all the internal delays, even the ones that a span several milliseconds. The format is defined in the BME680 API.  Below is a snippet for your reference.

    void myDelayMs(uint32_t periodMs)
    {
        // Go to sleep if periodMs is sufficiently long
    }
    
    void setup(void)
    {
        // Other stuff
         iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire, myDelayMs);
        //Other stuff
    }

      

    Highlighted
    New Poster

    Re: Supporting BME680 with BSEC on ESP32 using deep-sleep

    Hi kgoveas

    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