Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BME680 warning code : 2 and BME680 error code : -2 on NodeMcu esp8266.

    BME680 warning code : 2 and BME680 error code : -2 on NodeMcu esp8266.



    I am running the "basic_config_state.ino"  from on a NodeMcu esp8266.

    The measurement starts then I get a bunch of BME680 warning code: 2 in a row (1200+ lines) and then the measurement resume. This continues for a while until I get BME680 error code : -2

    This is my code: 

    I have the latest Arduino 1.8.10, the latest esp8566 library (2.6.1), BSEC library version (downloaded yesterday from github)

    The modification explained in github/readme are applied to and platform.txt 

    Thanks a lot for your help!


    Explanation of the error code and solution found in the forum

    ○ BME680 error code : -2 = "BME680_E_COM_FAIL" was solved here by replacing Wire.begin() by Wire.begin(I2C_PIN_SDA, I2C_PIN_SCL) but in that case, the code never run. In my case, the code run for a while  and then I get this bug  si this isn't a fix 

    ○ BME680 warning code : 2 = BME680_W_NO_NEW_DATA

    My log


    Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%]
    7455, 16.96, 98149.37, 67.71, 11152.22, 25.00, 0, 16.85, 67.85
    .... measurements continue without bug
    124456, 18.81, 98151.98, 64.74, 19586.68, 25.00, 0, 18.71, 62.69
    1268 lines of : BME680 warning code : 2
    130457, 17.67, 98147.52, 64.48, 18958.91, 25.00, 0, 17.61, 66.40
    .... measurements continue without bug
    298457, 18.98, 98157.34, 64.36, 20297.18, 25.00, 0, 18.88, 62.17
    2500+ lines  of BME680 warning code : 2
    307458, 17.82, 98152.27, 64.05, 19081.22, 25.00, 0, 17.79, 65.79
    .... measurements continue without bug
    385457, 18.84, 98157.93, 64.24, 20217.90, 25.00, 0, 18.73, 62.45
    1280+ lines of BME680 warning code : 2
    391458, 17.82, 98154.58, 64.00, 19512.84, 25.00, 0, 17.76, 65.70
    .... measurements continue without bug
    475457, 19.16, 98150.90, 64.08, 20975.81, 25.00, 0, 19.05, 61.78
    1260+ lines of BME680 warning code : 2
    481460, 17.82, 98156.16, 63.77, 19476.13, 25.00, 0, 17.77, 66.06
    .... measurements continue without bug
    520460, 17.85, 98156.33, 63.82, 18634.68, 25.00, 0, 17.74, 65.90
    1300+ lines of BME680 warning code : 2
    526462, 17.86, 98155.77, 63.83, 19348.71, 25.00, 0, 17.81, 65.29
    .... measurements continue without bug
    736462, 18.79, 98162.40, 64.18, 20703.13, 25.00, 0, 18.68, 62.33
    1300+ lines of BME680 warning code : 2
    742462, 17.74, 98157.47, 63.96, 19736.06, 25.00, 0, 17.69, 65.70
    .... measurements continue without bug
    823461, 18.85, 98165.16, 64.05, 20933.39, 25.00, 0, 18.74, 62.14
    BME680 error code : -2



    I also tried with the basic.ino and I get a similar log (but the bug comes sooner):


    Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent
    6092, 17.53, 98178.95, 66.61, 12085.89, 25.00, 0, 17.47, 66.01, 25.00, 500.00, 0.50
    .... measurements continue without bug
    15093, 18.50, 98189.98, 66.46, 14548.93, 25.00, 0, 18.43, 63.65, 25.00, 500.00, 0.50
    1265 lines of : BME680 warning code : 2
    21094, 17.37, 98181.46, 65.98, 14268.18, 25.00, 0, 17.34, 67.33, 25.00, 500.00, 0.50
    .... measurements continue without bug
    102094, 18.74, 98188.98, 64.72, 17909.28, 25.00, 0, 18.67, 62.62, 25.00, 500.00, 0.50
    BME680 error code : -2



    Something I tried that didn't work

    I tried to solve the BME680 warning code : 2  (meaning no new date) by adding a delay just before updateState() in the loop() like this:





    But I still get the BME680 warning code : 2 and BME680 error code : -2 and I even get BSEC warning code : 100 and BSEC error code : -2 

    ○ BSEC Error code : -2 = "BSEC_E_DOSTEPS_VALUELIMITS" which means the value of the input (physical) sensor signal passed to bsec_do_steps() is not in the valid range.The solution proposed  here  is a fix in the code but I already have it.

    ○ BSEC warning code : 100 = "BSEC_W_SC_CALL_TIMING_VIOLATION " : Difference between actual and defined sampling intervals of bsec_sensor_control() greater than allowed


    5 REPLIES 5

    Hi user001,

    this may not be a complete fix, but we can see from your log that your sampling is not aligned with your own internal clock. The timestamps start with a value of *.455s and the error occur when the timestamp drifts to *.456. It eventually drifts another 6ms to *.462.

    If your timing cannot be guaranteed by design, I would recommend that you fake the timestamps to be exactly 3000ms apart. Let me know if that solves your issue.


    Thanks a lot for your help! 

    Just to be clear, I'm not looking for precise delay between measurement, I just want to read the data (every 3 second, or so: any value between 3 to 60 will be fine), and then I want to send them to opensensemap API.

    Concerning "If your timing cannot be guaranteed by design": I'm not sure to understand. Does that mean : the time of each of my loop varies (each of my loop doesn't last exactly 3 sec.) ? 

    Concerning "your sampling is not aligned with your own internal clock" : I guess by "sampling" you mean "the moment when I start a new measurement" and by "internal clock" you mean the time that I can retrieve with the "millis()".

    Concerning your option to "fake the timestamps", I am not sure how to do it so I have created my own "timekeeping" function that would make the BME680 "think" that I am taking a measurement it every 3 sec but in reality the interval varies 

    So I created a var time_trigger  that is simply the number of loop already completed * 3000. I then pass this time to

    See below for the changes I made. This is workign for a 1 min or so and then I keep getting "BME680 warning code : 2" and no new measurement. 

    In the mean time, I have tested with a delay(3000) (and without any delay)  at the end of loop. 

    I also tried to add/remove a connection to a server so I can save my data (which probably adds delay and makes my interval between my measurement unstable). 

    For basic.ino, if I add a delay of 3 sec and no connection to the server I didn't not get any warning or  errors during a 7h test (before that it was crashing before 20min) - I had to disconnect the sensor so it may have continue indefinitly without errors. But without the delay of 3 sec, I get "BME680 error code : -2"  after a couple of seconds. 

    I made other test with the same configuration, sometimes I had the several  warnings "BSEC warning code : 100" and "BME680 warning code : 2" during 6 seconds at the beginning but then the sketch carries on. 

    I tried to replicate this succes with basic_config_state.ino but it didn't work.  I still go many "BME680 warning code : 2" and it ended with "BME680 error code : -2" after 10-20min. 

    I have measurement the interval between each measurement of "basic_config_state.ino" (without unsing any delay) and they are mostly between "2 sec 999" and "3 sec 001" but I sometimes get interval between loop as long as "6 sec" and even "45s" 

    I also tried to use the 5 min version with basic_config_state.ino (I thought that this config might tolerate more offset between the measurement). So I change  "config/generic_33v_3s_4d/bsec_iaq.txt" to "config/generic_33v_300s_4d /bsec_iaq.txt" inside "const uint8_t bsec_config_iaq[]". But it did not work. I got "BME680 error code : -2" right from the start, before receiving any measurement. I guess I don't understand how to set the 5min config in "basic_config_state.ino".

    + + + + + + + + + 

    List of all the changes I made to run my own timekeeping clock:

    At the top of my skecth I added 

    int number_loop = 1;

    long time_trigger = 0;


    At the begining of loop() I changed the "unsigned long time_trigger_mill = millis(); " into 

        time_trigger = 3000 * number_loop;


     and then I call


    In bsec.cpp, I modified in  "bool Bsec::run(void)" into "bool Bsec::run(long time_trigger)" and then I call getTimeMs(time_trigger);

    I also replaced "int64_t Bsec::getTimeMs(void)" by " int64_t Bsec::getTimeMs(long time_trigger)" and the "set int64_t timeMs = time_trigger;" instead of  "int64_t timeMs = millis();"


    In bsec.h I also modifed the declaration fo run like this "bool run(long time_trigger);"



    See the files here:


    basi.ino modified :

    bsec.cpp :

    bsec.h :



    In terms of physical sensor, I do not think that sampling 1ms before or after makes a big difference, however BSEC expects you to have exactly 3000ms between samples, this is why I recommend that you simply create a timestamp by incrementing a counter by 3000 each time (like what you are doing). I do not think that you require a delay, rather simply use a timer interrupt to have the function execute every 3000ms, regardless of what is happening in your main loop.

    The 300s second config string cannot run at 3s interval, but the 3s config string can run at both data rate. Better to simply ignore this and use 3s config string.

    Please keep your logs for further debugging, it seems to me that since the basic.ino example is working without issues, and that adding server communication, the timing of the function calls must be the issue here.

    Thanks so much for your patience! I didn't know we could have timer interrupt, that's super !

    I found a way to step this up with my NodeMU esp8266 and the ticker library. I made a simplified version with only the basic.ino and the print (I didn't yet try to add the conenction). Please have a look here: 

    This is my output ( ). You can see that something is really wrong: the new lines are added every 3 secs (as expected) but it seems the new measurement are only taken every 45 sec (each measurement is printed 15 times) even though I set the ticker to call "takeMeasurement()" every 3 sec. I am not sure why this is happening.  

    There are also a couple of "BME680 error code : -2" but somehow the sketch continues and start again.