co2_sensor.h 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
#ifndef CO2_SENSOR_H_
#define CO2_SENSOR_H_

// The SCD30 from Sensirion is a high quality Nondispersive Infrared (NDIR) based CO₂ sensor capable of detecting 400 to 10000ppm with an accuracy of ±(30ppm+3%).
// https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library
#include "src/lib/SparkFun_SCD30_Arduino_Library/src/SparkFun_SCD30_Arduino_Library.h"  // From: http://librarymanager/All#SparkFun_SCD30
#include "config.h"
#include "led_effects.h"
Eric Duminil's avatar
Eric Duminil committed
9
#include "util.h"
10
#include "sensor_console.h"
11
12
13
#include <Wire.h>

namespace config {
14
  extern uint16_t measurement_timestep; // [s] Value between 2 and 1800 (range for SCD30 sensor)
15
  extern bool auto_calibrate_sensor; // [true / false]
16
  extern uint16_t co2_calibration_level; // [ppm]
17
18
19
20
21
  extern const float temperature_offset; // [K] Sign isn't relevant.
}

namespace sensor {
  extern SCD30 scd30;
22
  extern uint16_t co2;
23
24
  extern float temperature;
  extern float humidity;
Eric Duminil's avatar
Eric Duminil committed
25
  extern char timestamp[];
26
27

  void initialize();
Eric Duminil's avatar
Eric Duminil committed
28
  bool processData();
29
  void startCalibrationProcess();
30
31
32
33
34

  void setCO2forDebugging(int32_t fakeCo2);
  void setTimer(int32_t timestep);
  void calibrateSensorToSpecificPPM(int32_t calibrationLevel);
  void calibrateSensorRightNow(int32_t calibrationLevel);
35
  void setAutoCalibration(int32_t autoCalibration);
36
  void resetSCD();
37
38
}
#endif