Closed keniji closed 4 years ago
It's quite strange, I have now set:
eco2_baseline: 0x94F9
tvoc_baseline: 0x8BD9
Then the log stays on:
[05:40:06][I][sgp30:112]: Current eCO2 baseline: 0x94F9, TVOC baseline: 0x8BD9
And the readings are not changed to smaller or larger as just now, which seems to be normal... But I am sure when I got the calibrated readings, they are:
Current eCO2 baseline: 0x8BD9, TVOC baseline: 0x94F9
I will make another test environment and try to see if I can reproduce this issue. Will update later.
According to the datasheet the order for getting the baseline is first eco2 then the tvoc. But to set it the order is first tvoc and then the eco2. While getting does seem implemented correctly, setting does not. In esphome/components/sgp30/sgp30.cpp the code should be changed from this:
void SGP30Component::write_iaq_baseline_(uint16_t eco2_baseline, uint16_t tvoc_baseline) {
uint8_t data[7];
data[0] = SGP30_CMD_SET_IAQ_BASELINE & 0xFF;
data[1] = eco2_baseline >> 8;
data[2] = eco2_baseline & 0xFF;
data[3] = sht_crc_(data[1], data[2]);
data[4] = tvoc_baseline >> 8;
data[5] = tvoc_baseline & 0xFF;
data[6] = sht_crc_(data[4], data[5]);
to this:
void SGP30Component::write_iaq_baseline_(uint16_t eco2_baseline, uint16_t tvoc_baseline) {
uint8_t data[7];
data[0] = SGP30_CMD_SET_IAQ_BASELINE & 0xFF;
data[1] = tvoc_baseline >> 8;
data[2] = tvoc_baseline & 0xFF;
data[3] = sht_crc_(data[1], data[2]);
data[4] = eco2_baseline >> 8;
data[5] = eco2_baseline & 0xFF;
data[6] = sht_crc_(data[4], data[5]);
Hi babblerz, Thanks for the reply.
I just have a test environment set and will see if it works fine.
Hi @babblerz , I have a quick check and seems the component should works fine now, thanks again for your help!
Hi @keniji,
Have you made the suggested changes and tested that, or you tested the original code? The fix I have suggested is not incorporated in the sources yet, it was just a comment.
Operating environment/Installation (Hass.io/Docker/pip/etc.): Docker
ESP (ESP32/ESP8266, Board/Sonoff): ESP8266
Affected component: SGP30
Description of problem: According to Issue 950, baseline readings are separated in an update: SGP30, and I am now using this update. However, after I set the baseline readings and get the new readings after 1 hour, I found the readings are "exchanged". For example, if I set:
After 1 hour (the readings can be recalculated) I will see in log:
Current eCO2 baseline: 0xBBBB, TVOC baseline: 0xAAAA
Problem-relevant YAML-configuration entries:
Logs (if applicable):
Additional information and things you've tried: In the environment above, I found the eCO2 baseline is getting smaller and TVOC's is larger, so I think the correct readings should be 0x8BD9 for eCO2 and 0x94F9 for TVOC?