#include <XTronical_ST7735.h> // Hardware-specific library #include <SPI.h> #include <Adafruit_GFX.h> // Core graphics library #include <sSense-CCS811.h> #include <dht.h>
#define SERIAL_SPEED 9600
#define TFT_SCLK 13 // SPI clock
#define TFT_MOSI 11 // SPI Data
#define TFT_CS 10 // Display enable (Chip select), if not enabled will not talk on SPI bus
#define TFT_RST 9 // Display reset pin, you can also connect this to the Arduino reset
// in which case, set this #define pin to -1!
#define TFT_DC 8
CCS811 ssenseCCS811;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
dht DHT;
#define DHT11_PIN 7
void setup() { DebugPort.begin(SERIAL_SPEED); delay(5000); Serial.println("s-Sense CCS811 I2C sensor."); if(!ssenseCCS811.begin(uint8_t(I2C_CCS811_ADDRESS), uint8_t(CCS811_WAKE_PIN), driveMode_1sec)) DebugPort.println("Initialization failed."); tft.init(); // initialize a ST7735S chip, tft.setRotation(0); tft.fillScreen(ST7735_GREEN); tft.setTextColor(ST7735_RED); tft.setCursor(0, 30); tft.setTextSize(1); }
void loop() { ssenseCCS811.setEnvironmentalData((float)(21.102), (float)(57.73)); // replace with temperature and humidity values from HDC2010 sensor int chk = DHT.read11(DHT11_PIN); if (ssenseCCS811.checkDataAndUpdate()) {
#include <XTronical_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <sSense-CCS811.h>
#include <dht.h>
#define SERIAL_SPEED 9600
#define TFT_SCLK 13 // SPI clock
#define TFT_MOSI 11 // SPI Data
#define TFT_CS 10 // Display enable (Chip select), if not enabled will not talk on SPI bus
#define TFT_RST 9 // Display reset pin, you can also connect this to the Arduino reset
// in which case, set this #define pin to -1!
#define TFT_DC 8
CCS811 ssenseCCS811;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
dht DHT;
#define DHT11_PIN 7
void setup()
{
DebugPort.begin(SERIAL_SPEED);
delay(5000);
Serial.println("s-Sense CCS811 I2C sensor.");
if(!ssenseCCS811.begin(uint8_t(I2C_CCS811_ADDRESS), uint8_t(CCS811_WAKE_PIN), driveMode_1sec))
DebugPort.println("Initialization failed.");
tft.init(); // initialize a ST7735S chip,
tft.setRotation(0);
tft.fillScreen(ST7735_GREEN);
tft.setTextColor(ST7735_RED);
tft.setCursor(0, 30);
tft.setTextSize(1);
}
void loop()
{
ssenseCCS811.setEnvironmentalData((float)(21.102), (float)(57.73)); // replace with temperature and humidity values from HDC2010 sensor
int chk = DHT.read11(DHT11_PIN);
if (ssenseCCS811.checkDataAndUpdate())
{
tft.fillScreen(ST7735_GREEN);
tft.setCursor(10,10);
tft.print("CO2 ppm ");
tft.print(ssenseCCS811.getCO2());
tft.setCursor(10,40);
tft.print("tVOC ppb ");
tft.print(ssenseCCS811.gettVOC());
tft.setCursor(10,70);
tft.print("Temp C ");
tft.print(DHT.temperature);
tft.setCursor(10,100);
tft.print("Humid % ");
tft.print(DHT.humidity);
}
else if (ssenseCCS811.checkForError())
{
ssenseCCS811.printError();
}
delay(2000);
}
} else if (ssenseCCS811.checkForError()) { ssenseCCS811.printError(); }
delay(2000); }