htu21 sensor
This commit is contained in:
parent
5a16fccbad
commit
ed2778fa65
2 changed files with 24 additions and 13 deletions
|
@ -15,4 +15,5 @@ platform = atmelavr
|
|||
board = uno
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
adafruit/Adafruit BME280 Library @ ^2.1.2
|
||||
; adafruit/Adafruit BME280 Library @ ^2.1.2
|
||||
sparkfun/SparkFun HTU21D Humidity and Temperature Sensor Breakout @ ^1.1.3
|
||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -1,6 +1,6 @@
|
|||
#include <Arduino.h>
|
||||
#include <MQ135.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <SparkFunHTU21D.h>
|
||||
|
||||
#define PIN_MQ135 A0
|
||||
#define PIN_NOISE 2
|
||||
|
@ -12,26 +12,29 @@
|
|||
#define PIN_LED_RED2 8
|
||||
|
||||
MQ135 co2_sensor(PIN_MQ135);
|
||||
Adafruit_BME280 bme;
|
||||
HTU21D envSensor;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// if (!bme.begin(0x76)) {
|
||||
// Serial.println(F("Could not find a valid BME280 sensor, check wiring!"));
|
||||
// }
|
||||
co2_sensor.setR0(200);
|
||||
|
||||
envSensor.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// float temp = bme.readTemperature();
|
||||
// float humidity = bme.readHumidity();
|
||||
float temp = envSensor.readTemperature();
|
||||
float humidity = envSensor.readHumidity();
|
||||
|
||||
// float r0 = co2_sensor.getCorrectedR0(temp, humidity);
|
||||
float r0c = co2_sensor.getCorrectedR0(temp, humidity);
|
||||
float in = analogRead(PIN_MQ135);
|
||||
double v = co2_sensor.getVoltage();
|
||||
double r = co2_sensor.getResistance();
|
||||
float r0 = co2_sensor.getR0();
|
||||
|
||||
double co2 = co2_sensor.getCO2();
|
||||
double co2c = co2_sensor.getCorrectedCO2(temp, humidity);
|
||||
|
||||
Serial.print("Analog Read: ");
|
||||
Serial.println(in);
|
||||
Serial.print("Voltage: ");
|
||||
|
@ -39,12 +42,19 @@ void loop() {
|
|||
Serial.print("Resistance: ");
|
||||
Serial.println(r);
|
||||
|
||||
// Serial.print("Temperature: ");
|
||||
// Serial.println(temp);
|
||||
// Serial.print("Humidity: ");
|
||||
// Serial.println(humidity);
|
||||
Serial.print("R0: ");
|
||||
Serial.println(r0);
|
||||
Serial.print("Temperature: ");
|
||||
Serial.println(temp);
|
||||
Serial.print("Humidity: ");
|
||||
Serial.println(humidity);
|
||||
Serial.print("R0 Corrected: ");
|
||||
Serial.println(r0c);
|
||||
|
||||
Serial.print("CO2: ");
|
||||
Serial.println(co2);
|
||||
Serial.print("CO2 Corrected: ");
|
||||
Serial.println(co2c);
|
||||
|
||||
Serial.println("-----------------------------");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue