Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the BME680 goes to sleep and read very low resistance when Tasmota web UI is not open #1647

Closed
anpj123 opened this issue Jan 20, 2018 · 9 comments
Labels
stale Action - Issue left behind - Used by the BOT to call for attention

Comments

@anpj123
Copy link

anpj123 commented Jan 20, 2018

The “gas” readings from BME680 are correct only when the Sonoff Tasmota UI is open in browser. If it’s open then the reading is correct about 170 kOhm , but as soon as the browser is closed the reading reported via MQTT droops down to about 36 kOhm. The temperature and pressure are OK, but the GAS seems to not work. I think the sensor goes to sleep. Is there any way to keep it alive all the time or at least in some intervals?

@arendst
Copy link
Owner

arendst commented Jan 20, 2018

You might want to make the following change to file xsns_09_bmp.ino at line 503 to see if it fixes the problem:

  if (i2c_flg) {
    switch (function) {
      case FUNC_PREP_BEFORE_TELEPERIOD:
        BmpDetect();
        break;
      case FUNC_EVERY_SECOND:
#ifdef USE_BME680
        if (tele_period == Settings.tele_period -3) {
          Bme680PerformReading();
        }
#endif  // USE_BME680
        break;
      case FUNC_JSON_APPEND:
        BmpShow(1);
        break;

arendst added a commit that referenced this issue Jan 20, 2018
5.11.1d
 * Add locale Decimal Separator to Web sensor page
 * Add
command State to retrieve device state information (same data as
teleperiod state and status 11 in slightly different JSON format)
 *
Extent state information with Light parameters
 * Fix IRSend parameter
translation (#1636)
 * Add optional login to Webserver AP mode (#1587,
#1635)
 * Fix BME680 teleperiod resistance measuring (#1647)
@anpj123
Copy link
Author

anpj123 commented Jan 20, 2018

I checked my 4 BME680 and they all need about 3-4min stabilization time to get a meaningful GAS reading. So I added the following code (below) to sample sensor every 1s for 5min before the telemetry reporting. With that modification firmware v 5.11.1b works perfect with different tele periods.
Like always thanks for all your help!

  if (i2c_flg) {
    switch (function) {
      case FUNC_PREP_BEFORE_TELEPERIOD:
        BmpDetect();
      break;                                     // this line was added     
      case FUNC_EVERY_SECOND:                    // check every second 
        #ifdef USE_BME680
          if ((Settings.tele_period - tele_period) < 300) {     // reads BME680 300s before teleperiod - required for GAS stabilization
          Bme680PerformReading();
          BmpShow(1);                                         // added to append JSON 
          }                                                 // end if < 300s
        #endif  // USE_BME680
      break;                                    
   case FUNC_JSON_APPEND:
        BmpShow(1);
   break;

@arendst
Copy link
Owner

arendst commented Jan 20, 2018

In that case forget the FUNC_EVERY_SECOND part an add the Bmp680PerformReading function in the FUNC_JSON_APPEND part just below BmpShow(1).

@anpj123
Copy link
Author

anpj123 commented Jan 20, 2018

When I put it in FUNC_JSON_APPEND then it doesn't work, as the sensor needs to be actively pulled at least every 2s (2s is in Adafruit example) to stabilize. I see FUNC_JSON_APPEND is executed only when the telemetry is called. The current minimum for telemetry is 10s and that's too long.

@pascalsaul
Copy link

pascalsaul commented Jan 30, 2018

This is the effect on mine BME680, is that as expected:
image

I'm only have trouble reading the 'value' in kOhm. Can I compare it with the table from the datasheet:
image

So is my Air Quality a 'little bad' now?

@anpj123
Copy link
Author

anpj123 commented Jan 31, 2018

Did you try to keep the browser open with your Sonoff Tasmota firmware website ? Did you notice any spike during that time ? When I have the browser open my kOhms readings can double within 60s or so. When I close the browser then the readings goes down. I think this is the problem with the BME680 gas internal heater . In the library you can set the heater temperature and time with the flowing function:
bme.setGasHeater(320, 1000); // 320*C for 1000 ms (Adafruit default is 150ms)
I tested it on the regular Arduino and I had to increase the heat time to around 1000ms to have reliable reading at the first pull request. If you pull the sensor frequently (like every 1s or so) and have low "heating time" then you can see that the sensor resistance gradually increase every time you pull the data. This is exactly what's happening when you have the Sonoff Tasmota device website open - the sensor is updating every 1s and your resistance increases.
To transform the kOhms to "IAQ Index" , I found the flowing post. This guy read resistance and made some conversions. On my sensors (I have 5 running now) I read about 300-400 kOhm in relatively fresh air and about 50 kOhms when I stick the sensor in the bag with my son's used diapers :-)

https://forums.pimoroni.com/t/bme680-observed-gas-ohms-readings/6608

@pascalsaul
Copy link

pascalsaul commented Jan 31, 2018

You're right... as soon as I opened the webgui the kOhm increased immediately! It's almost doubled now in the browser...
image

arendst added a commit that referenced this issue Feb 9, 2018
5.12.0 20180209
* Change library PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to
1000 for Home Assistant  support
* Change relation of define MESSZ being dependent on PubSubClient.h
define MQTT_MAX_PACKET_SIZE
* Change command color parameter input checks to less strict for Home
Assistant support
* Change command Ina219Mode into command Sensor13
* Change commands HlwPCal, HlwUCal and HlwICal to PowerCal, VoltageCal
and CurrentCal to be used for both Pow and S31 calibration
* Change commands HlwPSet, HlwUSet and HlwISet to PowerSet, VoltageSet
and CurrentSet to be used for both Pow and S31 calibration
* Change uptime from hour to second resulting in a display of
123T13:45:21 where 123 is days
* Change module name Wemos D1 mini into Generic (#1220)
* Change HTML from width=100% to style=width:100% supporting HTML5
(#1358)
* Change OSWATCH_RESET_TIME (Blocked loop) from 30 to 120 seconds to
allow slow networks (#1556)
* Change WIFI_MANAGER_SEC into WIFI_CONFIG_SEC (#1616)
* Change function pointers code to save code space and memory (#1683)
* Change webserver argument processing gaining 5k code space (#1705)
* Change weblog memory usage (#1730, #1793, #1819)
* Update TasmotaSerial library to 1.1.0
* Update language files Italian (#1594), Dutch (#1723) and Spanish
(#1722)
* Fix Non-English JSON temperature unit attachement
* Fix Arilux RF induced exception by moving interrupt handler to iram on
non ESP8266/Arduino lib v2.3.0
* Fix truncated command names and wrong response for DomoticzSwitchIdx
(#1571)
* Fix %-sign issue as printf escape character in Humidity and Sonoff SC
(#1579)
* Fix DS18B20 temperature JSON decimal dot (#1561)
* Fix Energy JSON message (#1621)
* Fix IRSend parameter translation (#1636)
* Fix TSL2561 device detection (#1644, #1825)
* Fix BME680 teleperiod resistance measuring (#1647)
* Fix Energy Monitoring Energy Today and Energy Total reading after
restart (#1648)
* Fix IRReceive Data value (#1663)
* Fix Energy Monitoring Energy Period roll-over (#1688)
* Fix compiler warnings (#1774)
* Fix command PWM response if no PWM channel is configured (#1783)
* Add locale Decimal Separator to Web sensor page
* Add ColorTemperature to light status message
* Add command PowerOnState option 5 which inverts PulseTime and allows
for delayed always on after power on
* Add OtaMagic two step Web server OTA upgrade using filename-minimal
image if OTA free space is too small
* Add support for PMS5003 and PMS7003 particle concentration sensor
* Add command SetOption21 1 to allow Energy Monitoring when power is off
on Sonoff Pow and Sonoff S31 (#1420)
* Add Chinese language file (#1551)
* Add French language file (#1561)
* Add Spanish language file (#1589)
* Add HTTP Allow Cross Origin removed from ESP8266/Arduino lib v2.4.0
(#1572)
* Add Home Assistant MQTT Discovery for switch and light to be enabled
by command SetOption19 1 (#1534) or define
HOME_ASSISTANT_DISCOVERY_ENABLE in user_config.h (#1685)
* Add command State to retrieve device state information (same data as
teleperiod state and status 11 in slightly different JSON format)
* Add optional login to Webserver AP mode (#1587, #1635)
* Add command Sensor15 2 to start MHZ19(B) Zero Point Calibration
(#1643)
* Add support for Sonoff S31 Smart Socket with Power Consumption
Detection (#1626)
* Add command SetOption20 to allow update of Dimmer/Color/Ct without
turning power on (#1719, #1741)
* Add NTP sync time slot based on chip id (#1773)
* Add cursor pointer to web button (#1836)
@stale
Copy link

stale bot commented May 31, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label May 31, 2018
@stale
Copy link

stale bot commented Jun 15, 2018

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

@stale stale bot closed this as completed Jun 15, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.11.1d
 * Add locale Decimal Separator to Web sensor page
 * Add
command State to retrieve device state information (same data as
teleperiod state and status 11 in slightly different JSON format)
 *
Extent state information with Light parameters
 * Fix IRSend parameter
translation (arendst#1636)
 * Add optional login to Webserver AP mode (arendst#1587,
arendst#1635)
 * Fix BME680 teleperiod resistance measuring (arendst#1647)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

No branches or pull requests

3 participants