MallocArray / airgradient_esphome

ESPHome definition for an AirGradient DIY device to send data to HomeAssistant and AirGradient servers
GNU General Public License v3.0
234 stars 40 forks source link

Problems with CO2 reading / unresponsiveness / different configuartion between sensor_s8.yaml & ag-pro.yaml(?) #35

Closed moritz1000 closed 7 months ago

moritz1000 commented 8 months ago

Hello,

I am having problems with the CO2 reading of my Airgradient Pro DIY (with an d1_mini). I don't know what is causing this so I just throw out there what I do know:

image

this should not matter I guess since sgp4x does not measure the CO2 value - senseair does.


I assume you either install https://github.com/MallocArray/airgradient_esphome/blob/main/airgradient-pro.yaml where you are able to choose between different packages or install https://github.com/MallocArray/airgradient_esphome/blob/main/full_config/ag-pro.yaml ?

During my troubleshooting efforts, I observed that https://github.com/MallocArray/airgradient_esphome/blob/main/full_config/ag-pro.yaml sets update_interval: 60s (https://github.com/MallocArray/airgradient_esphome/blob/main/full_config/ag-pro.yaml#L261), while sensor_s8.yaml does not specify this interval. Could you please clarify if this difference is intentional?


Despite these observations, I'm uncertain about the root cause of my issue. Given that my Airgradient DIY device is less than a year old, I suspect it's not a hardware problem.

Kind regards & thank you for your help.

MallocArray commented 8 months ago

Have you done a full power cycle of the device? I assume so, but sometimes I get weird readings until I fully remove power for a few seconds and then restore, when just a soft reboot or reinstall from ESPHome doesn't clear it.

The difference in the update_interval is only that the full_config folder uses the esphome config command which parses out all of the options including any of the defaults, so you'll see many more options defined for each sensor, but these are the defaults, just fully laid out. So sensor_s8.yaml doesn't define the update_interval, which means it uses the default, which is 60s, so no difference.

I'm not sure if it would cause any extra hassle to the ESPHome config to have the NOx sensor defined and then ignored because your model doesn't have it, compared to not defining it at all, but I wouldn't expect it to cause your issue. You could try removing the line in the Packages section for the SGP41 and just copy and paste this code below the entire Packages section

sensor:
  - platform: sgp4x
    # SGP41 https://esphome.io/components/sensor/sgp4x.html
    voc:
      name: "VOC Index"
      id: voc
    compensation:  # Remove this block if no temp/humidity sensor present for compensation
      temperature_source: temp
      humidity_source: humidity
moritz1000 commented 8 months ago

Thank you for your help. Sadly the idea does not work: Couldn't find ID 'nox'. Please check you have defined an ID with that name in your configuration. image

Since my Airgradient/CO2 reading is unusable in the last few days I will create a minimal configuartion which just sends the CO2 value and nothing more in order to rule out a hardware defect. I'll report back!

MallocArray commented 8 months ago

Shoot, didn't think that all the way through. Since the API upload and Display modules all reference the nox sensor ID, just removing it would cause both of them to have an error.

moritz1000 commented 8 months ago

I think I fixed my issue. When looking at the logs I saw things like:

[08:04:40][D][senseair:059]: SenseAir Received CO₂=216ppm Status=0x00
[08:04:40][D][sensor:093]: 'CO2': Sending state 350.00000 ppm with 0 decimals of accuracy

which explained the value being stuck at 350 so often! For whatever reason the SenseAir was measuring impossible low values and then sending the min_value: 350 to Home Assistant. Also errors like

[16:52:40][W][senseair:030]: Invalid preamble from SenseAir! ac4737fe 04080000 00000001 00
# and
[12:33:40] [E] [uart:015]: Reading from UART timed out at byte 9!
[12:33:40] [W] [senseair:024]: Reading data from SenseAir failed!

I completely re-flashed my the ESPHome with airgradient_esphome and the error side of things was already looking much better but the CO2 values were still "impossible" wrong. So I ran a SenseAir S8 Calibration near an open window and now everything seems back to normal :).

I'll disable SenseAir S8 Automatic Background Calibration and observe for now.


Again thank you for your help! I guess sometimes it takes more than a reboot - a re-flash to fix things :).

MallocArray commented 8 months ago

Glad you got it going. A reading fixed at 350 does currently mean that the readings are showing possible invalid values, since I would be surprised if there was a situation that you would hit actual 350 ppm environment, but I might end up removing that, and if you get lower than 400, it will be what it is.

I have had to reinstall a few times. I do also see the "Invalid preamble" message sometimes even when things looks to be running as expected, but it doesn't result in a value of 65k for me.

Glad it is going

moritz1000 commented 7 months ago

Hey :), So small update here: The problems came back. I think it has to do with the automatic background calibration!

[21:49:06][D][senseair:059]: SenseAir Received CO₂=57ppm Status=0x00
[21:49:06][D][sensor:093]: 'CO2': Sending state 350.00000 ppm with 0 decimals of accuracy

The CO2 sensor is measuring absolute garbage e.g.: 57ppm.

EDIT: I also get impossible high values again: 2024-03-15_08-17

I am pretty sure that my problems started happening again after about 180 hours = 7,5 days, so exactly when the automatic background calibration happens.


I'll re-flash the firmware soon, disable abc and see what happens.

MallocArray commented 7 months ago

You probably don't even need to reflash the firmware. You should already have a button to trigger a manual calibration, so if you take it outside for 5 minutes (or near an open window), then do the manual calibration, and wait another 5-10 minutes and bring inside, hopefully that takes care of it.

There is another issue open for very similar, I'm going to update there as well.

moritz1000 commented 7 months ago

hopefully that takes care of it.

Thank you! This time a simple manual calibration seems to have worked, last time I did have to re-flash.

What I don't understand is why I keep having problems with the abc. The implementen in your repository is not different from what is described here, I think: https://esphome.io/components/sensor/senseair.html#senseair-co-2-sensor


Anyways I turned off abc for good and hope that I won't see the problem again in 8 days.

Again, many thanks!