Skip to content

Commit fd1c400

Browse files
committed
update links
1 parent 0cbc028 commit fd1c400

File tree

11 files changed

+37
-32
lines changed

11 files changed

+37
-32
lines changed

examples/Example1_BasicReadings/Example1_BasicReadings.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
9-
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
9+
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813
1212

examples/Example2_RawSignals/Example2_RawSignals.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example3_Humidity/Example3_Humidity.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example4_ErrorChecking/Example4_ErrorChecking.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example5_DeviceInfo/Example5_DeviceInfo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example6_SchedulerReadings/Example6_SchedulerReadings.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example7_Reset/Example7_Reset.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example8_OtherI2C/Example8_OtherI2C.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

examples/Example9_UnitTest/Example9_UnitTest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: June 28th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
SGP30 Datasheet: https://cdn.sparkfun.com/assets/4/7/d/f/b/Sensirion_SGP30_Datasheet.pdf
8+
SGP30 Datasheet: https://cdn.sparkfun.com/assets/c/0/a/2/e/Sensirion_Gas_Sensors_SGP30_Datasheet.pdf
99
1010
Feel like supporting our work? Buy a board from SparkFun!
1111
https://www.sparkfun.com/products/14813

src/SparkFun_SGP30_Library.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939

4040
#include "SparkFun_SGP30_Library.h"
4141

42-
const uint8_t init_air_quality[2] = {0x20, 0x03};
43-
const uint8_t measure_air_quality[2] = {0x20, 0x08};
44-
const uint8_t get_baseline[2] = {0x20, 0x15};
45-
const uint8_t set_baseline[2] = {0x20, 0x1E};
46-
const uint8_t set_humidity[2] = {0x20, 0x61};
47-
const uint8_t measure_test[2] = {0x20, 0x32};
48-
const uint8_t get_feature_set_version[2] = {0x20, 0x2F};
49-
const uint8_t get_serial_id[2] = {0x36, 0x82};
50-
const uint8_t measure_raw_signals[2] = {0x20, 0x50};
42+
//const uint8_t init_air_quality[2] = {0x20, 0x03};
43+
//const uint8_t measure_air_quality[2] = {0x20, 0x08};
44+
//const uint8_t get_baseline[2] = {0x20, 0x15};
45+
//const uint8_t set_baseline[2] = {0x20, 0x1E};
46+
//const uint8_t set_humidity[2] = {0x20, 0x61};
47+
//const uint8_t measure_test[2] = {0x20, 0x32};
48+
//const uint8_t get_feature_set_version[2] = {0x20, 0x2F};
49+
//const uint8_t get_serial_id[2] = {0x36, 0x82};
50+
//const uint8_t measure_raw_signals[2] = {0x20, 0x50};
5151

5252
//Constructor
5353
SGP30::SGP30() {
@@ -65,6 +65,7 @@ SGP30::SGP30() {
6565
}
6666

6767
//Start I2C communication using specified port
68+
//Returns SUCCESS if successful or other error code if unsuccessful
6869
SGP30ERR SGP30::begin(TwoWire &wirePort) {
6970
_i2cPort = &wirePort; //Grab which port the user wants us to use
7071
_i2cPort->begin();
@@ -86,7 +87,7 @@ void SGP30::initAirQuality(void) {
8687
//Call in regular intervals of 1 second to maintain synamic baseline calculations
8788
//CO2 returned in ppm, Total Volatile Organic Compounds (TVOC) returned in ppb
8889
//Will give fixed values of CO2=400 and TVOC=0 for first 15 seconds after init
89-
//returns ERR_BAD_CRC if CRC8 check failed and SUCCESS if successful
90+
//Returns SUCCESS if successful or other error code if unsuccessful
9091
SGP30ERR SGP30::measureAirQuality(void) {
9192
_i2cPort->beginTransmission(_SGP30Address);
9293
_i2cPort->write(measure_air_quality, 2); //command to measure air quality
@@ -110,7 +111,6 @@ SGP30ERR SGP30::measureAirQuality(void) {
110111
_TVOC |= _i2cPort->read(); //store LSB in TVOC
111112
checkSum = _i2cPort->read(); //verify checksum
112113
if (checkSum != _CRC8(_TVOC)) return ERR_BAD_CRC; //checksum failed
113-
_i2cPort->endTransmission();
114114
CO2 = _CO2; //publish valid data
115115
TVOC = _TVOC; //publish valid data
116116
return SUCCESS;
@@ -121,7 +121,7 @@ SGP30ERR SGP30::measureAirQuality(void) {
121121
//Save baseline periodically to non volatile memory
122122
//(like EEPROM) to restore after new power up or
123123
//after soft reset using setBaseline();
124-
//returns ERR_BAD_CRC if CRC8 check failed and SUCCESS if successful
124+
//Returns SUCCESS if successful or other error code if unsuccessful
125125
SGP30ERR SGP30::getBaseline(void) {
126126
_i2cPort->beginTransmission(_SGP30Address);
127127
_i2cPort->write(get_baseline, 2);
@@ -145,7 +145,6 @@ SGP30ERR SGP30::getBaseline(void) {
145145
_baselineTVOC |= _i2cPort->read(); //store LSB in _baselineTVOC
146146
checkSum = _i2cPort->read(); //verify checksum
147147
if (checkSum != _CRC8(_baselineTVOC)) return ERR_BAD_CRC; //checksum failed
148-
_i2cPort->endTransmission();
149148
baselineCO2 = _baselineCO2; //publish valid data
150149
baselineTVOC = _baselineTVOC; //publish valid data
151150
return SUCCESS;
@@ -183,7 +182,7 @@ void SGP30::setHumidity(uint16_t humidity) {
183182
}
184183

185184
//gives feature set version number (see data sheet)
186-
//returns ERR_BAD_CRC if CRC8 check failed and SUCCESS if successful
185+
//Returns SUCCESS if successful or other error code if unsuccessful
187186
SGP30ERR SGP30::getFeatureSetVersion(void) {
188187
_i2cPort->beginTransmission(_SGP30Address);
189188
_i2cPort->write(get_feature_set_version, 2); //command to get feature version
@@ -203,13 +202,13 @@ SGP30ERR SGP30::getFeatureSetVersion(void) {
203202
_featureSetVersion |= _i2cPort->read(); //store LSB in featureSetVersion
204203
uint8_t checkSum = _i2cPort->read(); //verify checksum
205204
if (checkSum != _CRC8(_featureSetVersion)) return ERR_BAD_CRC; //checksum failed
206-
_i2cPort->endTransmission();
207205
featureSetVersion = _featureSetVersion; //publish valid data
208206
return SUCCESS;
209207
}
210208

211209
//Intended for part verification and testing
212210
//these raw signals are used as inputs to the onchip calibrations and algorithms
211+
//Returns SUCCESS if successful or other error code if unsuccessful
213212
SGP30ERR SGP30::measureRawSignals(void) {
214213
_i2cPort->beginTransmission(_SGP30Address);
215214
_i2cPort->write(measure_raw_signals, 2); //command to measure raw signals
@@ -233,7 +232,6 @@ SGP30ERR SGP30::measureRawSignals(void) {
233232
_ethanol |= _i2cPort->read(); //store LSB in ethanol
234233
checkSum = _i2cPort->read(); //verify checksum
235234
if (checkSum != _CRC8(_ethanol)) return ERR_BAD_CRC; //checksum failed
236-
_i2cPort->endTransmission();
237235
H2 = _H2; //publish valid data
238236
ethanol = _ethanol; //publish valid data
239237
return SUCCESS;
@@ -248,7 +246,7 @@ void SGP30::generalCallReset(void) {
248246
}
249247

250248
//readout of serial ID register can identify chip and verify sensor presence
251-
//returns ERR_BAD_CRC if CRC8 check failed and SUCCESS if successful
249+
//Returns SUCCESS if successful or other error code if unsuccessful
252250
SGP30ERR SGP30::getSerialID(void) {
253251
_i2cPort->beginTransmission(_SGP30Address);
254252
_i2cPort->write(get_serial_id, 2); //command to get serial ID
@@ -267,22 +265,21 @@ SGP30ERR SGP30::getSerialID(void) {
267265
_serialID1 = _i2cPort->read() << 8; //store MSB to top of _serialID1
268266
_serialID1 |= _i2cPort->read(); //store next byte in _serialID1
269267
uint8_t checkSum1 = _i2cPort->read(); //verify checksum
268+
if (checkSum1 != _CRC8(_serialID1)) return ERR_BAD_CRC; //checksum failed
270269
_serialID2 = _i2cPort->read() << 8; //store next byte to top of _serialID2
271270
_serialID2 |= _i2cPort->read(); //store next byte in _serialID2
272271
uint8_t checkSum2 = _i2cPort->read(); //verify checksum
272+
if (checkSum2 != _CRC8(_serialID2)) return ERR_BAD_CRC; //checksum failed
273273
_serialID3 = _i2cPort->read() << 8; //store next byte to top of _serialID3
274274
_serialID3 |= _i2cPort->read() ; //store LSB in _serialID3
275275
uint8_t checkSum3 = _i2cPort->read(); //verify checksum
276-
if (checkSum1 != _CRC8(_serialID1)) return ERR_BAD_CRC; //checksum failed
277-
if (checkSum2 != _CRC8(_serialID2)) return ERR_BAD_CRC; //checksum failed
278276
if (checkSum3 != _CRC8(_serialID3)) return ERR_BAD_CRC; //checksum failed
279277
serialID = ((uint64_t)_serialID1 << 32) + ((uint64_t)_serialID2 << 16) + ((uint64_t)_serialID3); //publish valid data
280-
_i2cPort->endTransmission();
281278
return SUCCESS;
282279
}
283280

284281
//Sensor runs on chip self test
285-
//returns SUCCESS if successful
282+
//Returns SUCCESS if successful or other error code if unsuccessful
286283
SGP30ERR SGP30::measureTest(void) {
287284
_i2cPort->beginTransmission(_SGP30Address);
288285
_i2cPort->write(measure_test, 2); //command to get self test
@@ -304,7 +301,6 @@ SGP30ERR SGP30::measureTest(void) {
304301
uint8_t checkSum = _i2cPort->read(); //verify checksum
305302
if (checkSum != _CRC8(results)) return ERR_BAD_CRC; //checksum failed
306303
if (results != 0xD400) return SELF_TEST_FAIL; //self test results incorrect
307-
_i2cPort->endTransmission();
308304
return SUCCESS;
309305
}
310306

src/SparkFun_SGP30_Library.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ typedef enum {
5050
SELF_TEST_FAIL
5151
} SGP30ERR;
5252

53+
const uint8_t init_air_quality[2] = {0x20, 0x03};
54+
const uint8_t measure_air_quality[2] = {0x20, 0x08};
55+
const uint8_t get_baseline[2] = {0x20, 0x15};
56+
const uint8_t set_baseline[2] = {0x20, 0x1E};
57+
const uint8_t set_humidity[2] = {0x20, 0x61};
58+
const uint8_t measure_test[2] = {0x20, 0x32};
59+
const uint8_t get_feature_set_version[2] = {0x20, 0x2F};
60+
const uint8_t get_serial_id[2] = {0x36, 0x82};
61+
const uint8_t measure_raw_signals[2] = {0x20, 0x50};
5362

5463
class SGP30
5564
{

0 commit comments

Comments
 (0)