trvrnrth / esphome-bsec-bme680

ESPHome component for the Bosch BME680 sensor via BSEC providing temperature, humidity, pressure and indoor air quality measurements.
85 stars 17 forks source link

How do I adjust the polling interval? #4

Closed lichtteil closed 3 years ago

lichtteil commented 3 years ago

I could not figure out how to change the update interval of the sensor. I think it is now at 15 seconds but I don't understand why :)

trvrnrth commented 3 years ago

This will be the median filtering (see https://github.com/trvrnrth/esphome-bsec-bme680/blob/master/src/.bsecsensor.yaml#L60 for temperature for example). For my use case a bit of smoothing and fewer data points was beneficial but you can safely take that filter out entirely if you prefer quicker updates.

lichtteil commented 3 years ago

Thanks for your reply. Does that mean that the loop in the custom sensor class ( https://github.com/trvrnrth/esphome-bsec-bme680/blob/master/src/bsecsensor.h#L146 ) runs without pause? I don't need quicker updates but prefer slower updates and have in mind that the lifespan of the sensor expands (at least thats what I think 😄).

trvrnrth commented 3 years ago

Yes, the loop runs continually with the BSEC library taking care of keeping track of when to actually next poll the sensor in its run function: https://github.com/trvrnrth/esphome-bsec-bme680/blob/9c5999f60221be149d51697467fc701068cceb49/src/bsecsensor.h#L147

You could provide a different config (see https://github.com/BoschSensortec/BSEC-Arduino-library/tree/c5503e0e85067e07e11b45b4215663f929e640c3/src/config): https://github.com/trvrnrth/esphome-bsec-bme680/blob/9c5999f60221be149d51697467fc701068cceb49/src/bsecsensor.h#L124 https://github.com/trvrnrth/esphome-bsec-bme680/blob/9c5999f60221be149d51697467fc701068cceb49/src/bsecsensor.h#L6

This would allow you to increase the interval to 5 minutes instead of 3 seconds though I couldn't say what impact a longer interval between sensor heat cycles would have on overall lifetime. Typically you'd do so to reduce power requirements / increase battery lifetime.

lichtteil commented 3 years ago

Thank you a lot! :)