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
21.75k stars 4.72k forks source link

After a powercycle or reset the CO2 sensor MHZ19 needs time to report correct values #16309

Closed arnowelzel closed 1 year ago

arnowelzel commented 1 year ago

PROBLEM DESCRIPTION

When powercycling or resetting the device, it will need 3 minutes for the "preheat" before the MHZ19 will report valid data. Also see https://www.winsen-sensor.com/d/files/PDF/Infrared%20Gas%20Sensor/NDIR%20CO2%20SENSOR/MH-Z19%20CO2%20Ver1.0.pdf, page 4.

However Tasmota will not wait but use the invalid data right away and report them to MQTT which will result in having zero values for CO2 and temperature during a period of 5 minutes (which is the default telemetry interval in Tasmota).

REQUESTED INFORMATION

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

10:26:32.866 MQT: stat/tasmota_DD2940/RESULT = {"NAME":"Generic","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18} 10:26:33.079 MQT: stat/tasmota_DD2940/RESULT = {"Module":{"18":"Generic"}} 10:26:33.335 MQT: stat/tasmota_DD2940/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"1440":"MHZ Rx"},"GPIO2":{"0":"None"},"GPIO3":{"1408":"MHZ Tx"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua

### TO REPRODUCE
Install Tasmota on a D1 Mini.

Connect a MHZ19B and configure Tasmota so it can talk to the MHZ19B.

Configure MQTT so it will send the data to a MQTT server (e.g. Home Assistant with Mosquitto).

Powercycle the device.

### EXPECTED BEHAVIOUR
Tasmota will not send any data at all for that sensor before the MHZ19 reports correct values for CO2 and temperature and not just 0 but will wait for about 30 seconds. It would be better just to have a 5 minute gap without any values at all instead of wrong zero values. To indicate that the sensor is still "preheating" and can not be used yet, maybe a status message in the WebUI might be added to the values like this:

MHZ19B Carbon dioxide (preheat) 0 ppm MHZ19B Temperature (preheat) 0 °C



Also see here: https://www.winsen-sensor.com/d/files/PDF/Infrared%20Gas%20Sensor/NDIR%20CO2%20SENSOR/MH-Z19%20CO2%20Ver1.0.pdf

### SCREENSHOTS

When powercycling the device there are periods of 5 minutes with zero values visible in Home Assistant:

![image](https://user-images.githubusercontent.com/6613614/186121938-4560d2e4-4231-4f06-8b0a-cf4070b5c706.png)

### ADDITIONAL CONTEXT

**(Please, remember to close the issue when the problem has been addressed)**
arnowelzel commented 1 year ago

Just do emphasize what this issue causes - when the sensor needed to reset (e.g. for calibration outside) the whole diagram in Home Assistant becomes quite useless with the 0 values in it for about 24 hours:

image