Skip to content

Commit 1deb17a

Browse files
Reformatted example, fixed readme links, added keywords
1 parent 83a1984 commit 1deb17a

File tree

5 files changed

+158
-183
lines changed

5 files changed

+158
-183
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
SparkFun CCS811 Arduino Library
22
========================================
33

4-
**BROKEN** ![CCS811 Breakout](https://www.sparkfun.com/)
4+
![SparkFun CCS811 Breakout](https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/blob/master/extras/readme_picture.jpg)
55

6-
**BROKEN** [*CCS811 Breakout (SEN-XXXXX)*](https://www.sparkfun.com/)
6+
[*SparkFun CCS811 (SEN-14193)*](https://www.sparkfun.com/products/14193)
77

88
This is an arduino IDE library to control the CCS811.
99

10-
This has been tested with Arduino Uno.
10+
This has been tested with Arduino Uno, ESP32, and Teensy 3.2 using Arduino 1.8.1.
1111

1212
Repository Contents
1313
-------------------
@@ -21,28 +21,31 @@ Repository Contents
2121
Examples
2222
--------------
2323

24-
* BasicReadings -
25-
* Core -
26-
* GetBaseline -
27-
* setEnvironmentalReadings -
28-
* TwentyMinuteTest -
24+
* BaselineOperator - Save and restore baselines to the EEPROM
25+
* BasicReadings - Get data from the CCS811 as fast as possible
26+
* BME280Compensated - Compensate the CCS811 with data from your BME280 sensor
27+
* Core - Shows how the underlying hardware object works
28+
* NTCCompensated - Compensate the CCS811 with data from a supplied NTC Thermistor
29+
* setEnvironmentalReadings - Compensate the CCS with random data
30+
* TwentyMinuteTest - Report data with timestamp.
31+
* WakeAndInterrupt - Shows how to use the nWake and nInt pins
2932

3033
Documentation
3134
--------------
3235

3336
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
34-
* **BROKEN** **[Product Repository](https://www.sparkfun.com/)** - Main repository (including hardware files) for the LIS3DH Breakout.
35-
* **BROKEN** **[Hookup Guide](https://www.sparkfun.com/)** - Basic hookup guide for the LIS3DH Breakout.
37+
* **[Product Repository](https://github.com/sparkfun/CCS811_Air_Quality_Breakout)** - Main repository (including hardware files) for the CCS811 Breakout.
38+
* **[Hookup Guide](https://learn.sparkfun.com/tutorials/ccs811-air-quality-breakout-hookup-guide)** - Basic hookup guide for the CCS811 Breakout.
3639

3740
Products that use this Library
3841
---------------------------------
3942

40-
* [SEN-XXXXX](https://www.sparkfun.com/)- CCS811 Breakout board
43+
* [SEN-14193](https://www.sparkfun.com/)- CCS811 Breakout board
4144

4245
Version History
4346
---------------
4447

45-
* **BROKEN**[V 1.0.0](https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/releases/tag/V_1.0.0) -- Initial commit of Arduino 1.6-compatible library.
48+
* [V 1.0.0](https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/releases/tag/V_1.0.0) -- Initial commit of Arduino compatible library.
4649

4750
License Information
4851
-------------------
Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
/******************************************************************************
2-
NTCCompensated.ino
2+
NTCCompensated.ino
33
4-
Marshall Taylor @ SparkFun Electronics
4+
Marshall Taylor @ SparkFun Electronics
55
6-
April 4, 2017
6+
April 4, 2017
77
8-
https://github.com/sparkfun/CCS811_Air_Quality_Breakout
9-
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library
8+
https://github.com/sparkfun/CCS811_Air_Quality_Breakout
9+
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library
1010
11-
This example uses an NTC thermistor to gather temperature data that is then used
12-
to compensate the CCS811. (humidity defaulted at 50%)
11+
This example uses an NTC thermistor to gather temperature data that is then used
12+
to compensate the CCS811. (humidity defaulted at 50%)
1313
14-
Hardware Connections (Breakoutboard to Arduino):
14+
Hardware Connections (Breakoutboard to Arduino):
1515
3.3V to 3.3V pin
1616
GND to GND pin
1717
SDA to A4
1818
SCL to A5
1919
SEN-00250 (NTCLE100E3103JB0) between NTC terminals
2020
21-
Resources:
22-
Uses Wire.h for i2c operation
21+
Resources:
22+
Uses Wire.h for i2c operation
2323
24-
Development environment specifics:
25-
Arduino IDE 1.8.1
24+
Development environment specifics:
25+
Arduino IDE 1.8.1
2626
27-
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
27+
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
2828
29-
Please review the LICENSE.md file included with this example. If you have any questions
30-
or concerns with licensing, please contact [email protected].
29+
Please review the LICENSE.md file included with this example. If you have any questions
30+
or concerns with licensing, please contact [email protected].
3131
32-
Distributed as-is; no warranty is given.
32+
Distributed as-is; no warranty is given.
3333
******************************************************************************/
3434
#include <SparkFunCCS811.h>
3535

@@ -40,64 +40,64 @@ CCS811 myCCS811(CCS811_ADDR);
4040

4141
void setup()
4242
{
43-
Serial.begin(9600);
44-
Serial.println();
45-
Serial.println("Apply NTC data to CCS811 for compensation.");
46-
status_t returnCode = myCCS811.begin();
47-
Serial.print("CCS811 begin exited with: ");
48-
printDriverError( returnCode );
49-
Serial.println();
50-
51-
myCCS811.setRefResistance( 9950 );
43+
Serial.begin(9600);
44+
Serial.println();
45+
Serial.println("Apply NTC data to CCS811 for compensation.");
46+
status_t returnCode = myCCS811.begin();
47+
Serial.print("CCS811 begin exited with: ");
48+
printDriverError( returnCode );
49+
Serial.println();
50+
51+
myCCS811.setRefResistance( 9950 );
5252

5353
}
5454

5555
void loop()
5656
{
57-
if (myCCS811.dataAvailable())
58-
{
59-
myCCS811.readAlgorithmResults(); //Calling this function updates the global tVOC and CO2 variables
60-
61-
Serial.println("CCS811 data:");
62-
Serial.print(" CO2 concentration : ");
63-
Serial.print(myCCS811.getCO2());
64-
Serial.println(" ppm");
65-
66-
Serial.print(" TVOC concentration : ");
67-
Serial.print(myCCS811.getTVOC());
68-
Serial.println(" ppb");
69-
70-
//.readNTC() causes the CCS811 library to gather ADC data and save value
71-
myCCS811.readNTC();
72-
Serial.print(" Measured resistance : ");
73-
//After .readNTC() is called, .getResistance() can be called to actually
74-
//get the resistor value. This is not needed to get the temperature,
75-
//but can be useful information for debugging.
76-
//
77-
//Use the resistance value for custom thermistors, and calculate the
78-
//temperature yourself.
79-
Serial.print( myCCS811.getResistance() );
80-
Serial.println(" ohms");
81-
82-
//After .readNTC() is called, .getTemperature() can be called to get
83-
//a temperature value providing that part SEN-00250 is used in the
84-
//NTC terminals. (NTCLE100E3103JB0)
85-
Serial.print(" Converted temperature : ");
86-
float readTemperature = myCCS811.getTemperature();
87-
Serial.print( readTemperature, 2);
88-
Serial.println(" deg C");
89-
90-
//Pass the temperature back into the CCS811 to compensate
91-
myCCS811.setEnvironmentalData( 50, readTemperature);
92-
93-
Serial.println();
94-
}
95-
else if (myCCS811.checkForStatusError())
96-
{
97-
printSensorError();
98-
}
99-
100-
delay(10); //Don't spam the I2C bus
57+
if (myCCS811.dataAvailable())
58+
{
59+
myCCS811.readAlgorithmResults(); //Calling this function updates the global tVOC and CO2 variables
60+
61+
Serial.println("CCS811 data:");
62+
Serial.print(" CO2 concentration : ");
63+
Serial.print(myCCS811.getCO2());
64+
Serial.println(" ppm");
65+
66+
Serial.print(" TVOC concentration : ");
67+
Serial.print(myCCS811.getTVOC());
68+
Serial.println(" ppb");
69+
70+
//.readNTC() causes the CCS811 library to gather ADC data and save value
71+
myCCS811.readNTC();
72+
Serial.print(" Measured resistance : ");
73+
//After .readNTC() is called, .getResistance() can be called to actually
74+
//get the resistor value. This is not needed to get the temperature,
75+
//but can be useful information for debugging.
76+
//
77+
//Use the resistance value for custom thermistors, and calculate the
78+
//temperature yourself.
79+
Serial.print( myCCS811.getResistance() );
80+
Serial.println(" ohms");
81+
82+
//After .readNTC() is called, .getTemperature() can be called to get
83+
//a temperature value providing that part SEN-00250 is used in the
84+
//NTC terminals. (NTCLE100E3103JB0)
85+
Serial.print(" Converted temperature : ");
86+
float readTemperature = myCCS811.getTemperature();
87+
Serial.print( readTemperature, 2);
88+
Serial.println(" deg C");
89+
90+
//Pass the temperature back into the CCS811 to compensate
91+
myCCS811.setEnvironmentalData( 50, readTemperature);
92+
93+
Serial.println();
94+
}
95+
else if (myCCS811.checkForStatusError())
96+
{
97+
printSensorError();
98+
}
99+
100+
delay(10); //Don't spam the I2C bus
101101
}
102102

103103
//printDriverError decodes the status_t type and prints the
@@ -107,47 +107,47 @@ void loop()
107107
//to this function to see what the output was.
108108
void printDriverError( status_t errorCode )
109109
{
110-
switch( errorCode )
111-
{
112-
case SENSOR_SUCCESS:
113-
Serial.print("SUCCESS");
114-
break;
115-
case SENSOR_ID_ERROR:
116-
Serial.print("ID_ERROR");
117-
break;
118-
case SENSOR_I2C_ERROR:
119-
Serial.print("I2C_ERROR");
120-
break;
121-
case SENSOR_INTERNAL_ERROR:
122-
Serial.print("INTERNAL_ERROR");
123-
break;
124-
case SENSOR_GENERIC_ERROR:
125-
Serial.print("GENERIC_ERROR");
126-
break;
127-
default:
128-
Serial.print("Unspecified error.");
129-
}
110+
switch ( errorCode )
111+
{
112+
case SENSOR_SUCCESS:
113+
Serial.print("SUCCESS");
114+
break;
115+
case SENSOR_ID_ERROR:
116+
Serial.print("ID_ERROR");
117+
break;
118+
case SENSOR_I2C_ERROR:
119+
Serial.print("I2C_ERROR");
120+
break;
121+
case SENSOR_INTERNAL_ERROR:
122+
Serial.print("INTERNAL_ERROR");
123+
break;
124+
case SENSOR_GENERIC_ERROR:
125+
Serial.print("GENERIC_ERROR");
126+
break;
127+
default:
128+
Serial.print("Unspecified error.");
129+
}
130130
}
131131

132132
//printSensorError gets, clears, then prints the errors
133133
//saved within the error register.
134134
void printSensorError()
135135
{
136-
uint8_t error = myCCS811.getErrorRegister();
137-
138-
if( error == 0xFF )//comm error
139-
{
140-
Serial.println("Failed to get ERROR_ID register.");
141-
}
142-
else
143-
{
144-
Serial.print("Error: ");
145-
if (error & 1 << 5) Serial.print("HeaterSupply");
146-
if (error & 1 << 4) Serial.print("HeaterFault");
147-
if (error & 1 << 3) Serial.print("MaxResistance");
148-
if (error & 1 << 2) Serial.print("MeasModeInvalid");
149-
if (error & 1 << 1) Serial.print("ReadRegInvalid");
150-
if (error & 1 << 0) Serial.print("MsgInvalid");
151-
Serial.println();
152-
}
136+
uint8_t error = myCCS811.getErrorRegister();
137+
138+
if ( error == 0xFF ) //comm error
139+
{
140+
Serial.println("Failed to get ERROR_ID register.");
141+
}
142+
else
143+
{
144+
Serial.print("Error: ");
145+
if (error & 1 << 5) Serial.print("HeaterSupply");
146+
if (error & 1 << 4) Serial.print("HeaterFault");
147+
if (error & 1 << 3) Serial.print("MaxResistance");
148+
if (error & 1 << 2) Serial.print("MeasModeInvalid");
149+
if (error & 1 << 1) Serial.print("ReadRegInvalid");
150+
if (error & 1 << 0) Serial.print("MsgInvalid");
151+
Serial.println();
152+
}
153153
}

extras/class diagrams.pdf

-24.6 KB
Binary file not shown.

extras/readme_picture.jpg

107 KB
Loading

0 commit comments

Comments
 (0)