arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.17k stars 4.8k forks source link

BME280 returns values that are too low if deepsleep is set up #13236

Closed sohnvonoff closed 3 years ago

sohnvonoff commented 3 years ago

PROBLEM DESCRIPTION

Have a battery operated ESP8266 with BME280 (and DS18b20) as a climate sensor with Tasmota. Deepsleep is active. every 15 minutes the climate data of the BME280 is transmitted with MQTT. Since the update from 8.4 to 9.5, the BME280 returns values that are too low. This only happens after waking up from deep sleep. If Deepsleep is deactivated, the BME280 runs stably again.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [x] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here: /BRE-ET161/stat/RESULT = {"Rule1":{"State":"OFF","Once":"OFF","StopOnError":"OFF","Length":33,"Free":478,"Rules":"ON System#Save DO Delay 150 ENDON"}}
- [x] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:
--> The output between waking up and falling asleep 

00:00:00.001 HDW: ESP8266EX
00:00:00.050 CFG: Loaded from flash at FA, Count 4907
00:00:00.056 CFG: CR 439/699, Busy 0
00:00:00.060 CFG: CR 439/699, Busy 0
00:00:00.063 SRC: Restart
00:00:00.064 Project tasmota BRE-ET161 Version 9.5.0(sensors)-2_7_4_9(2021-06-17T08:26:50)
00:00:00.097 DSB: Sensors found 2
00:00:00.109 SHT: Sensor did not ACK command
00:00:00.148 I2C: BME280 found at 0x77
00:00:00.465 WIF: Checking connection...
00:00:00.466 WIF: Attempting connection...
00:00:00.802 WIF: Connecting to AP1 Fuchsbau Channel 11 BSSId DC:39:6F:86:2B:53 in mode 11n as BRE-ET161-1478...
00:00:01.754 WIF: Checking connection...
00:00:01.755 WIF: Attempting connection...
00:00:02.754 WIF: Checking connection...
00:00:02.755 WIF: Attempting connection...
00:00:03.754 WIF: Checking connection...
00:00:03.755 WIF: Attempting connection...
00:00:04.754 WIF: Checking connection...
00:00:04.755 WIF: Attempting connection...
00:00:05.757 WIF: Checking connection...
00:00:05.758 WIF: Connected
00:00:06.010 HTP: Web server active on BRE-ET161-1478 with IP address 192.168.10.161
00:00:06.242 RTC: UTC 2021-09-28T18:23:09, DST 2021-03-28T02:00:00, STD 2021-10-31T03:00:00
19:23:10.028 MQT: Attempting connection...
19:23:10.112 MQT: Connected
19:23:10.116 MQT: /BRE-ET161/tele/LWT = Online (retained)
19:23:10.119 MQT: /BRE-ET161/cmnd/POWER = 
19:23:10.120 MQT: Subscribe to /BRE-ET161/cmnd/#
19:23:10.122 MQT: Subscribe to /tasmotas/cmnd/#
19:23:10.123 MQT: Subscribe to cmnd/DVES_2445C6_fb/#
19:23:10.125 MQT: Unsubscribe from homeassistant/status
19:23:10.334 SRC: MQTT
19:23:10.336 CMD: Grp 0, Cmnd 'DEEPSLEEPTIME', Idx 1, Len 2, Data '30'
19:23:10.341 MQT: /BRE-ET161/stat/RESULT = {"DeepSleepTime":30}
19:23:11.145 DSL: Reset wrong settings wakeup: 0, slip 10000
19:23:11.150 MQT: /BRE-ET161/stat/RESULT = {"DeepSleep":{"Time":"2021-09-28T19:23:30","Epoch":1632853410}}

TO REPRODUCE

Steps to reproduce the behavior: Configure a esp8266 (D1 mini) w. BME2800 and DS18B20 Configure Deppsleep (e.g. 15min)

without deepsleep are all values ok

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen. Before the update from 8.4 to 9.5, the measured values were always plausible

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

barbudor commented 3 years ago

@sohnvonoff How would you qualify "too low" ? By 0.1° by 1° by 10° ? I can't see much code changes in recently in the BMP/BME driver that could be impacted by DeepSleep. Is your BME280 always powered or are you using some circuitry to switch it off between the measures ?

Milbert-R commented 3 years ago

I made a test with connected DHT22 and BME280. The screenshoots will show, that output for BME280 in webUI will change during NodeMCU is in deepsleep. Wrong data is NOT sent via MQTT.

NodeMCU is waked up: test_up

NodeMCU is in deepsleep: test_sleep

Weblog 4 about this time from wakeup to deepsleep:

`00:00:00.001 HDW: ESP8266EX
00:00:00.050 CFG: aus Flash geladen am F6, Anzahl 514
00:00:00.055 CFG: CR 553/699, Busy 0
00:00:00.060 MSH: Initialized
00:00:00.061 SRC: Restart
00:00:00.062 Projekt RkM - RkM_NodeMCU_Deepsleep_Test Version 9.5.0.4(tasmota)-2_7_4_9(2021.08.02 17:55:13)
00:00:00.064 DHT: (v5) Sensor gefunden 1
00:00:00.076 I2C: BME280 gefunden bei 0x76
00:00:00.183 WIF: Prüfe Verbindung...
00:00:00.184 WIF: Verbindungsversuch...
00:00:00.520 WIF: verbinden mit AP1 RKMWLAN Channel 5 BSSId 44:4E:6D:A0:7F:20 in Modus 11n als RkM-NodeMCU-Deepsleep-Test-7681...
00:00:01.753 WIF: Prüfe Verbindung...
00:00:01.754 WIF: verbunden
00:00:02.006 HTP: Web-Server aktiv bei RkM-NodeMCU-Deepsleep-Test-7681 mit IP-Adresse 192.168.0.219
00:00:02.469 RTC: UTC 2021-10-05T15:23:59, DST 2021-03-28T02:00:00, STD 2021-10-31T03:00:00
17:24:00.048 MQT: Verbindungsversuch...
17:24:00.065 MQT: verbunden
17:24:00.068 MQT: tele/RkM_NodeMCU_Deepsleep_Test/LWT = Online (beibehalten)
17:24:00.071 MQT: cmnd/RkM_NodeMCU_Deepsleep_Test/POWER = 
17:24:00.072 MQT: abonniere cmnd/RkM_NodeMCU_Deepsleep_Test/#
17:24:00.074 MQT: abonniere cmnd/tasmotas/#
17:24:00.077 MQT: abonniere cmnd/RkM_NodeMCU_Deepsleep_Test_fb/#
17:24:00.078 MQT: löse abo. von homeassistant/status
17:24:04.494 MQT: tele/RkM_NodeMCU_Deepsleep_Test/STATE = {"Time":"2021-10-05T17:24:04","Uptime":"0T00:00:09","UptimeSec":9,"Heap":18,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"MqttCount":1,"Wifi":{"AP":1,"SSId":"RKMWLAN","BSSId":"44:4E:6D:A0:7F:20","Channel":5,"Mode":"11n","RSSI":100,"Signal":-36,"LinkCount":1,"Downtime":"0T00:00:03"}}
17:24:04.530 MQT: tele/RkM_NodeMCU_Deepsleep_Test/SENSOR = {"Time":"2021-10-05T17:24:04","Switch1":"OFF","AM2301":{"Temperature":24.2,"Humidity":56.1,"DewPoint":14.9},"BME280":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.8,"SeaPressure":1012.3},"Global":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.8,"SeaPressure":1012.3},"PressureUnit":"hPa","TempUnit":"C"}
17:24:09.442 MQT: tasmota/discovery/3C6105CFDE01/config = {"ip":"192.168.0.219","dn":"RkM_NodeMCU_Deepsleep_Test","fn":["RkM_NodeMCU_Deepsleep_Test",null,null,null,null,null,null,null],"hn":"RkM-NodeMCU-Deepsleep-Test-7681","mac":"3C6105CFDE01","md":"Generic","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0.4","t":"RkM_NodeMCU_Deepsleep_Test","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[0,0,0,0,0,0,0,0],"swc":[1,-1,-1,-1,-1,-1,-1,-1],"swn":["Switch1",null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":1,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1} (beibehalten)
17:24:09.453 MQT: tasmota/discovery/3C6105CFDE01/sensors = {"sn":{"Time":"2021-10-05T17:24:09","Switch1":"OFF","AM2301":{"Temperature":24.2,"Humidity":56.0,"DewPoint":14.9},"BME280":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.8,"SeaPressure":1012.3},"Global":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.8,"SeaPressure":1012.3},"PressureUnit":"hPa","TempUnit":"C"},"ver":1} (beibehalten)
17:24:18.780 WIF: Prüfe Verbindung...
17:24:38.802 WIF: Prüfe Verbindung...
17:24:58.797 WIF: Prüfe Verbindung...
17:25:04.423 MQT: tele/RkM_NodeMCU_Deepsleep_Test/STATE = {"Time":"2021-10-05T17:25:04","Uptime":"0T00:01:09","UptimeSec":69,"Heap":17,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"RKMWLAN","BSSId":"44:4E:6D:A0:7F:20","Channel":5,"Mode":"11n","RSSI":100,"Signal":-37,"LinkCount":1,"Downtime":"0T00:00:03"}}
17:25:04.454 MQT: tele/RkM_NodeMCU_Deepsleep_Test/SENSOR = {"Time":"2021-10-05T17:25:04","Switch1":"OFF","AM2301":{"Temperature":24.2,"Humidity":55.8,"DewPoint":14.8},"BME280":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.7,"SeaPressure":1012.3},"Global":{"Temperature":23.6,"Humidity":48.2,"DewPoint":12.0,"Pressure":966.7,"SeaPressure":1012.3},"PressureUnit":"hPa","TempUnit":"C"}
17:25:04.501 MQT: stat/RkM_NodeMCU_Deepsleep_Test/RESULT = {"DeepSleep":{"Time":"2021-10-05T17:25:00","Epoch":1633447500}}`
barbudor commented 3 years ago

I still don't understand There would be no data displayed on the web page when the NodeMCU is in deepsleep because the ESP is sleeping And you just said that the correct values are send over MQTT

Also you should have a teleperiod of 10 or 300 when using DeepSleep in order to minimize time on of the ESP and go back to sleep immediately atyer the 1st SENSOR message

sfromis commented 3 years ago

Those air pressure numbers in your last screenshot match what I see when the sensor is not in a correct "state". Haven't explored details of what happens, but I suspect that it may be more likely to happen with some sort of power issue, which easily could be the case with a battery setup. When I've seen similar, the readings have usually been fixed.

Not sure what you mean with "NodeMCU is in deepsleep".

Milbert-R commented 3 years ago

I just flashed precompiled http://ota.tasmota.com/tasmota/release/tasmota-sensors.bin.gz

Teleperiod set to 300

Same result as above...

The second screenshot is the display of the website during deepsleep.

The unit is not battery powered but powered by a 5v power supply.

Unit is in deepsleep means the time between

MQT: stat/RkM_NodeMCU_Deepsleep_Test/RESULT = {"DeepSleep":{"Time":"2021-10-05T18:24:00","Epoch":1633454640}}

and next

00:00:00.050 CFG: Loaded from flash at F8, Count 544
00:00:00.055 CFG: CR 553/699, Busy 0
00:00:00.060 SRC: Restart

Weblog 4:

00:00:00.001 HDW: ESP8266EX
00:00:00.050 CFG: Loaded from flash at F8, Count 544
00:00:00.055 CFG: CR 553/699, Busy 0
00:00:00.060 SRC: Restart
00:00:00.062 Project tasmota RkM_NodeMCU_Deepsleep_Test Version 9.5.0(sensors)-2_7_4_9(2021-06-17T08:26:50)
00:00:00.064 DHT: (v5) Sensors found 1
00:00:00.075 SHT: Sensor did not ACK command
00:00:00.116 I2C: BME280 found at 0x76
00:00:00.460 WIF: Checking connection...
00:00:00.460 WIF: Attempting connection...
00:00:00.797 WIF: Connecting to AP1 RKMWLAN Channel 5 BSSId 44:4E:6D:A0:7F:20 in mode 11n as RkM_NodeMCU_Deepsleep_Test-7681...
00:00:01.752 WIF: Checking connection...
00:00:01.753 WIF: Connected
00:00:02.005 HTP: Web server active on RkM_NodeMCU_Deepsleep_Test-7681 with IP address 192.168.0.219
00:00:02.221 RTC: UTC 2021-10-05T17:23:02, DST 2021-03-28T02:00:00, STD 2021-10-31T03:00:00
18:23:03.093 MQT: Attempting connection...
18:23:03.123 MQT: Connected
18:23:03.127 MQT: tele/RkM_NodeMCU_Deepsleep_Test/LWT = Online (retained)
18:23:03.129 MQT: cmnd/RkM_NodeMCU_Deepsleep_Test/POWER = 
18:23:03.130 MQT: Subscribe to cmnd/RkM_NodeMCU_Deepsleep_Test/#
18:23:03.134 MQT: Subscribe to cmnd/tasmotas/#
18:23:03.135 MQT: Subscribe to cmnd/RkM_NodeMCU_Deepsleep_Test_fb/#
18:23:03.137 MQT: Unsubscribe from homeassistant/status
18:23:07.169 MQT: tele/RkM_NodeMCU_Deepsleep_Test/STATE = {"Time":"2021-10-05T18:23:07","Uptime":"0T00:00:09","UptimeSec":9,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"RKMWLAN","BSSId":"44:4E:6D:A0:7F:20","Channel":5,"Mode":"11n","RSSI":100,"Signal":-36,"LinkCount":1,"Downtime":"0T00:00:03"}}
18:23:07.198 MQT: tele/RkM_NodeMCU_Deepsleep_Test/SENSOR = {"Time":"2021-10-05T18:23:07","AM2301":{"Temperature":25.1,"Humidity":56.1,"DewPoint":15.7},"BME280":{"Temperature":25.5,"Humidity":46.2,"DewPoint":13.0,"Pressure":967.3,"SeaPressure":1012.9},"PressureUnit":"hPa","TempUnit":"C"}
18:23:07.227 MQT: stat/RkM_NodeMCU_Deepsleep_Test/RESULT = {"DeepSleep":{"Time":"2021-10-05T18:24:00","Epoch":1633454640}}
sfromis commented 3 years ago

Tasmota does not update the web page display (or anything else) while in deep sleep. It cannot be "between" as you describe. Is it first update after wakeup, or last update before sleep?

My comment about potential power issue was not restricted to battery operation, but generally.

TD-er commented 3 years ago

Please be aware that the Bosch sensors have a moving average filter. This can be configured in the chip itself. It does cause some delay in response and especially on the first N samples the value can be (far) too low, depending on this filter setting.

No idea how Tasmota does use the Bosch sensors, but I guess that if you need a short measurement interval right after boot, you may need to perform N readings before accepting the value. (or change the filter setting :) )

ascillato2 commented 3 years ago

@Milbert-R

Hi, any news on this?

sohnvonoff commented 3 years ago

On 28.8. that made the update from tasmota version 8.4 to 9.5. Then the above-mentioned problems with the air pressure and temperature values became apparent. On 28.9. I posted the problem. Because of other problems I didn't have the time to take care of the post and the problem. The outdoor sensor with the BME280 just kept running. He has diligently continued to fill my database with the nonsensical values. The sensor runs for about three months on one battery charge. When I checked the log a few days ago, I was surprised to find that after about six weeks (on October 8th) the sensor suddenly delivers plausible values. Without any change!!!!!. In the six weeks, the battery voltage hasn't changed much either. I've seen @ Milbert-R reproduce the air pressure problem. First I'm at a loss. Will change the battery in the next few days. Then the sensor is de-energized. Let's see what happens? I'll get back.

ascillato2 commented 3 years ago

Hi, Great to know that your issue is solved. Please, post here your next tests. Thanks.