VOC and eCO2 gas sensor (SGP30) doubts

HI, i just bought a VOC and eCO2 Gas sensor (SGP30) and i’m looking at the examples provided with the library. I’m not sure I fully understood what I should run to achieve accurate readings. As I understood I should run the baseline_operation_example first to store the baseline (the sketch should be run for 12h at least? Should I need a “VOC free” environment for the baseline storage?) and then I should run the base_example sketch to read TVOC and eCO2 values with the previously stored baseline correction, am i right or can the same baseline_operation_example be used as well? Moreover, should I run the baseline_operation_example once a week at least to update the baseline? What happens if I use the same baseline for more than a week? And finally: in the baseline_operation_example there is a commented section saying:

/* if(baseline record in EEPROM is older than seven days) { return;} /*

Shouldn’t this comment be implemented as code to check if the baseline stored is older than a week? Why is it just a comment?

Thank you for your help!



the data check is in this function in sgp30.c

  • sgp_get_iaq_baseline() - read out the baseline from the chip

  • The IAQ baseline should be retrieved and persisted for a faster sensor

  • startup. See sgp_set_iaq_baseline() for further documentation.

  • A valid baseline value is only returned approx. 60min after a call to

  • sgp_iaq_init() when it is not followed by a call to sgp_set_iaq_baseline()

  • with a valid baseline.

  • This functions returns STATUS_FAIL if the baseline value is not valid.

  • @baseline: Pointer to raw u32 where to store the baseline

  •          If the method returns STATUS_FAIL, the baseline value must be
  •          discarded and must not be passed to sgp_set_iaq_baseline().
  • Return: STATUS_OK on success, else STATUS_FAIL
    s16 sgp_get_iaq_baseline(u32 *baseline) {
    s16 ret = sgp_run_profile_by_number(PROFILE_NUMBER_IAQ_GET_BASELINE);
    if (ret == STATUS_FAIL)
    return STATUS_FAIL;

    ((u16 *)baseline)[0] = client_data.word_buf[0];
    ((u16 *)baseline)[1] = client_data.word_buf[1];

    if (!SGP_VALID_IAQ_BASELINE(*baseline))
    return STATUS_FAIL;

    return STATUS_OK;
    And it is sure that you should run the baseline_operation_example first to store the baseline for 12h at least in a VOC free environment.

thank you bestlux, i tried indeed to run baseline_operation_example but it stucks repeating “serial start!!” on the serial monitor…

any idea about this issue? i didn’t modify the supplied code, so it should work but, as i said, it keeps repeating “serial start!!”.

The other two supplied codes works flawlessly instead…


The “Serial start” is in line 101 of the function setup() in baseline_operation_example.ino.

and then it should output"get ram signal!" or “error reading signals” I’m afraid there is something wrong. I guess it is with the following lines of code. So could you tell me which Arduino board are you using?
</s> #if defined(ESP8266) pinMode(15,OUTPUT); digitalWrite(15,1); Serial.println("Set wio link power!"); delay(500); #endif <e>

<LINK_TEXT text=“https://github.com/Seeed-Studio/SGP30_G … xample.ino”>https://github.com/Seeed-Studio/SGP30_Gas_Sensor/blob/master/examples/baseline_operation_example/baseline_operation_example.ino</LINK_TEXT>

Hi, i’m using an original Arduino Uno Rev3.

I noticed that if I comment the line 145 (that is store_baseline():wink: the program doesn’t stuck, returns the phrase “There is no baseline value in EEPROM”

and starts showing TVOC and eCO2 values… it doesn’t perform the store_baseline anyway… :?:

any news? :frowning:


The function store_baseline() stored the baseline in the EEPROM, if you comment it, this example is just the same as a normal reading example. You should go into the function and see which step does it stuck.
[code]void store_baseline(void)
static u32 i=0;
u32 j=0;
u32 iaq_baseline=0;
u8 value_array[4]={0};

     Serial.println("get baseline failed!");
    Serial.println("get baseline");


Hi, well thank you for your time but i just figured out that it was only matter of memory… i bought a compatible Arduino Mega and it works flawlessly! :mrgreen:

Now i’m looking to implement a RTC module to be able to check if the baseline is older than 7 days…the only problem is that i don’t know how to add date to the stored baseline in EEPROM… :?: i’ll have to study quite a lot i think :stuck_out_tongue: