Adafruit SGP30 Arduino Library
Go to the documentation of this file.
21 #ifndef ADAFRUIT_SGP30_H
22 #define ADAFRUIT_SGP30_H
24 #include "Arduino.h"
25 #include <Adafruit_BusIO_Register.h>
26 #include <Adafruit_I2CDevice.h>
28 // the i2c address
29 #define SGP30_I2CADDR_DEFAULT 0x58
31 // commands and constants
32 #define SGP30_FEATURESET 0x0020
33 #define SGP30_CRC8_POLYNOMIAL 0x31
34 #define SGP30_CRC8_INIT 0xFF
35 #define SGP30_WORD_LEN 2
42 public:
44  boolean begin(TwoWire *theWire = &Wire, boolean initSensor = true);
45  boolean softReset();
46  boolean IAQinit();
47  boolean IAQmeasure();
48  boolean IAQmeasureRaw();
50  boolean getIAQBaseline(uint16_t *eco2_base, uint16_t *tvoc_base);
51  boolean setIAQBaseline(uint16_t eco2_base, uint16_t tvoc_base);
52  boolean setHumidity(uint32_t absolute_humidity);
56  uint16_t TVOC;
60  uint16_t eCO2;
64  uint16_t rawH2;
68  uint16_t rawEthanol;
72  uint16_t serialnumber[3];
74 private:
75  Adafruit_I2CDevice *i2c_dev = NULL;
76  void write(uint8_t address, uint8_t *data, uint8_t n);
77  void read(uint8_t address, uint8_t *data, uint8_t n);
78  bool readWordFromCommand(uint8_t command[], uint8_t commandLength,
79  uint16_t delay, uint16_t *readdata = NULL,
80  uint8_t readlen = 0);
81  uint8_t generateCRC(uint8_t data[], uint8_t datalen);
82 };
83 #endif // ndef ADAFRUIT_SGP30_H
boolean IAQmeasure()
Commands the sensor to take a single eCO2/VOC measurement. Places results in TVOC and eCO2...
Definition: Adafruit_SGP30.cpp:114
boolean softReset()
Commands the sensor to perform a soft reset using the "General Call" mode. Take note that this is not...
Definition: Adafruit_SGP30.cpp:88
boolean setHumidity(uint32_t absolute_humidity)
Set the absolute humidity value [mg/m^3] for compensation to increase precision of TVOC and eCO2...
Definition: Adafruit_SGP30.cpp:202
uint16_t TVOC
Definition: Adafruit_SGP30.h:56
uint16_t serialnumber[3]
Definition: Adafruit_SGP30.h:72
uint16_t eCO2
Definition: Adafruit_SGP30.h:60
boolean getIAQBaseline(uint16_t *eco2_base, uint16_t *tvoc_base)
Request baseline calibration values for both CO2 and TVOC IAQ calculations. Places results in paramet...
Definition: Adafruit_SGP30.cpp:155
uint16_t rawEthanol
Definition: Adafruit_SGP30.h:68
boolean begin(TwoWire *theWire=&Wire, boolean initSensor=true)
Setups the hardware and detects a valid SGP30. Initializes I2C then reads the serialnumber and checks...
Definition: Adafruit_SGP30.cpp:47
Class that stores state and functions for interacting with SGP30 Gas Sensor.
Definition: Adafruit_SGP30.h:41
boolean IAQinit()
Commands the sensor to begin the IAQ algorithm. Must be called after startup.
Definition: Adafruit_SGP30.cpp:101
boolean setIAQBaseline(uint16_t eco2_base, uint16_t tvoc_base)
Assign baseline calibration values for both CO2 and TVOC IAQ calculations.
Definition: Adafruit_SGP30.cpp:178
boolean IAQmeasureRaw()
Commands the sensor to take a single H2/ethanol raw measurement. Places results in rawH2 and rawEthan...
Definition: Adafruit_SGP30.cpp:132
Instantiates a new SGP30 class.
Definition: Adafruit_SGP30.cpp:34
uint16_t rawH2
Definition: Adafruit_SGP30.h:64