just4give / SGP30_Gas_Sensor_Grove

A arduino example for SGP30_Gas_Sensor,Measurement of TVOC and CO2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SGP30_Gas_Sensor

This is a fork from Seeed SGP30_Gas_Sensor to make it compatible with Paricle. Please visit orginal repo for details about the sensor.


Usage:

Connect SGP30 hardware to the Particle board via the I2C ports, add the SGP30_Gas_Sensor_Grove library to your project. The sensor can be polled via the following code:

#include "Particle.h"
#include "sensirion_common.h"
#include "sgp30.h"

void setup()
{
    s16 err;
    u16 scaled_ethanol_signal, scaled_h2_signal;
    Serial.begin(115200);
    Serial.println("serial start!!");

    /*  Init module, reset all baseline,The initialization takes up to around 15 seconds, during which
        all APIs measuring IAQ(Indoor air quality ) output will not change.
        Default value is 400(ppm) for co2,0(ppb) for tvoc*/
    while (sgp_probe() != STATUS_OK)
    {
        Serial.println("SGP failed");
        while (1)
            ;
    }
    /*Read H2 and Ethanol signal in the way of blocking*/
    err = sgp_measure_signals_blocking_read(&scaled_ethanol_signal,
                                            &scaled_h2_signal);
    if (err == STATUS_OK)
    {
        Serial.println("get ram signal!");
    }
    else
    {
        Serial.println("error reading signals");
    }
    err = sgp_iaq_init();
}

void loop()
{
    s16 err = 0;
    u16 tvoc_ppb, co2_eq_ppm;
    err = sgp_measure_iaq_blocking_read(&tvoc_ppb, &co2_eq_ppm);
    if (err == STATUS_OK)
    {
        Serial.print("tVOC  Concentration:");
        Serial.print(tvoc_ppb);
        Serial.println("ppb");

        Serial.print("CO2eq Concentration:");
        Serial.print(co2_eq_ppm);
        Serial.println("ppm");
    }
    else
    {
        Serial.println("error reading IAQ values\n");
    }
    delay(1000);
}

About

A arduino example for SGP30_Gas_Sensor,Measurement of TVOC and CO2

License:Other


Languages

Language:C 93.9%Language:C++ 6.1%