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!



Stefano

Hello,

the data check is in this function in sgp30.c
[code]/**

  • 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;
    }[/code]
    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…

Hello,

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:

Hello,

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};
i++;
Serial.println(i);
if(i==3600)
{
i=0;

if(sgp_get_iaq_baseline(&iaq_baseline)!=STATUS_OK)
  {
     Serial.println("get baseline failed!");
   }
   else
   {
    Serial.println(iaq_baseline,HEX);
    Serial.println("get baseline");
    
    u32_to_array(iaq_baseline,value_array);
    
    for(j=0;j<4;j++){
      EEPROM.write(j,value_array[j]);
      Serial.print(value_array[j]);
      Serial.println("...");
      }
      
      EEPROM.write(j,BASELINE_IS_STORED_FLAG);
   }

}
delay(LOOP_TIME_INTERVAL_MS);
}[/code]

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:

Hello, I have an issue with the Grove SGP 30 Gas Sensor. I’m using adruino 1.8.12, i have the arduino uno, the shield and the SGP30 1.1. I had imported the specific library in seeestudio.com wich is " SGP30_Gas_Sensor-master.zip", and when I upload the “base-example” code, in the monitoring part, I see this lines, which you can see in the picture I had imported.
Can anyone help me resolving this please.
Capturepppp