Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created December 5, 2023 07:57
Show Gist options
  • Select an option

  • Save penpencool/e2d03a5b06820a92805092cbaaa0dd95 to your computer and use it in GitHub Desktop.

Select an option

Save penpencool/e2d03a5b06820a92805092cbaaa0dd95 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include "Adafruit_CCS811.h"
#include "Adafruit_HDC1000.h"
Adafruit_CCS811 ccs;
Adafruit_HDC1000 hdc;
void setup() {
Serial.begin(9600);
Serial.println("CCS811 HDC1080 Example");
if(!ccs.begin()){
Serial.println("Failed to start CCS811 sensor! Please check your wiring.");
while(1);
}
if(!hdc.begin()){
Serial.println("Failed to start HDC1080 sensor! Please check your wiring.");
while(1);
}
}
void loop() {
if(ccs.available()){
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print(" ppm, TVOC: ");
Serial.println(ccs.getTVOC());
}
}
if(hdc.begin()){
float temp = hdc.readTemperature();
float humidity = hdc.readHumidity();
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print("°C, Humidity: ");
Serial.print(humidity);
Serial.println("%");
}
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment