Improve ccs811 precision - #1428
Conversation
Update ccs811 environment precision
|
According to that document on that page, it says "Currently the CCS811 supports fractional values in increments of 0.5, resultantly only the most significant bit of the fraction field needs to be set." So the current code is correct and it even mentions that in the comment. |
Yes, you are correct regarding the Cambridge CMOS Censor's CCS811 Programming Guide (page 18). But I'm using Adafruit CCS811 which doesn't mention such a limitation (page 19). Personally, I think it still makes sense to improve the accuracy in general CCS811 sensors. |
| ESP_LOGD(TAG, " Env Humidity: %u", hum_conv); | ||
| ESP_LOGD(TAG, " Env Temperature: %u", temp_conv); |
There was a problem hiding this comment.
I don't think this is useful. If you're going to log, then print the actual values, not the coded ones.
There was a problem hiding this comment.
Agreed, I just deleted these log outputs. I previously used them to debug my code, but it seems not useful to others.
|
It's the same sensor. I really don't think there could be more than one with the same name anyway. However, I guess there's no harm in using the full resolution even if it's going to be ignored by the chip for now. |
|
The newer datasheet linked from Adafruit doesn't specifically mention that only one bit is used, but the examples still only go to .5 and have the second byte as 0. |
Update ccs811 environment setting precision
Description:
Related issue (if applicable):
This pull request improves the ccs811 sensor's environment value precision.
The previous implementation just left shift 1 bit of humidity and temperature value as high byte, and leave low byte as 0x00.
According to ccs811 programmer manual page 18, this approach loses the precision of the 9bit fraction field.
A better implementation is from Adafruit_CCS811. I ported this implementation and created this pull request.
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#esphome-docsis not affected.Checklist:
Tests have been added to verify that the new code works (undertests/folder).I added serial debug output of the humidity and temperature value sent to ccs811, see line 111-112DeletedIf user exposed functionality or configuration variables are added/changed:
Documentation added/updated in esphome-docs.