-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathCCS811_test.ino
67 lines (50 loc) · 1.75 KB
/
CCS811_test.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
This is a library for the CCS811 air
This sketch reads the sensor
Designed specifically to work with the Adafruit CCS811 breakout
----> http://www.adafruit.com/products/3566
These sensors use I2C to communicate. The device's I2C address is 0x5A
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Written by Dean Miller for Adafruit Industries.
BSD license, all text above must be included in any redistribution
Adapted to CubeCell HTCC-AB01 by Mike Cochrane
Hardware Connections:
CubeCell Pin CCS811 Board Function
Vext VCC Power
GND GND Ground
SDA SDA I2C Data
SCL SCL I2C Clock
GND WAKE Wake, active low
***************************************************************************/
#include "Adafruit_CCS811.h"
Adafruit_CCS811 ccs;
void setup() {
Serial.begin(115200);
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW); //set vext to high
delay(500);
Serial.println("CCS811 test");
if(!ccs.begin()){
Serial.println("Failed to start sensor! Please check your wiring.");
while(1);
}
// Wait for the sensor to be ready
while(!ccs.available());
}
void loop() {
if(ccs.available()){
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.println(ccs.getTVOC());
}
else{
Serial.println("ERROR!");
while(1);
}
}
delay(1000);
}