56 lines
1.1 KiB
Arduino
56 lines
1.1 KiB
Arduino
|
#include <Wire.h>
|
||
|
#include <Adafruit_Sensor.h>
|
||
|
#include <Adafruit_TSL2561_U.h>
|
||
|
#include "Adafruit_CCS811.h"
|
||
|
#include "DHT.h"
|
||
|
|
||
|
#define DHTPIN 2
|
||
|
#define DHTTYPE DHT11
|
||
|
|
||
|
Adafruit_CCS811 ccs;
|
||
|
DHT dht(DHTPIN, DHTTYPE);
|
||
|
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(9600);
|
||
|
Serial.println("Let's Talk Science!");
|
||
|
|
||
|
dht.begin();
|
||
|
ccs.begin();
|
||
|
tsl.begin();
|
||
|
|
||
|
while(!ccs.available());
|
||
|
float temp = ccs.calculateTemperature();
|
||
|
ccs.setTempOffset(temp - 25.0);
|
||
|
|
||
|
tsl.enableAutoRange(true);
|
||
|
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
delay(500);
|
||
|
float humidity = dht.readHumidity();
|
||
|
float temp = dht.readTemperature();
|
||
|
|
||
|
Serial.print(humidity);
|
||
|
Serial.print(" ");
|
||
|
Serial.print(temp);
|
||
|
Serial.print(" ");
|
||
|
|
||
|
ccs.readData();
|
||
|
int co2 = ccs.geteCO2();
|
||
|
int tvoc = ccs.getTVOC();
|
||
|
|
||
|
Serial.print(co2/100);
|
||
|
Serial.print(" ");
|
||
|
Serial.print(tvoc/10);
|
||
|
Serial.print(" ");
|
||
|
|
||
|
sensors_event_t event;
|
||
|
tsl.getEvent(&event);
|
||
|
|
||
|
Serial.print(event.light/10);
|
||
|
|
||
|
Serial.println("");
|
||
|
}
|