software/ampel-firmware/co2_sensor.h

39 lines
1.3 KiB
C
Raw Normal View History

2021-05-09 18:45:59 +00:00
#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"
#include "util.h"
2021-11-15 12:45:36 +00:00
#include "sensor_console.h"
2021-05-09 18:45:59 +00:00
#include <Wire.h>
namespace config {
extern uint16_t measurement_timestep; // [s] Value between 2 and 1800 (range for SCD30 sensor)
2021-11-15 12:45:36 +00:00
extern bool auto_calibrate_sensor; // [true / false]
2021-05-09 18:45:59 +00:00
extern uint16_t co2_calibration_level; // [ppm]
extern const float temperature_offset; // [K] Sign isn't relevant.
}
namespace sensor {
extern SCD30 scd30;
2021-11-15 12:45:36 +00:00
extern uint16_t co2;
2021-05-09 18:45:59 +00:00
extern float temperature;
extern float humidity;
2021-11-15 12:45:36 +00:00
extern char timestamp[];
2021-05-09 18:45:59 +00:00
void initialize();
bool processData();
void startCalibrationProcess();
2021-11-15 12:45:36 +00:00
void setCO2forDebugging(int32_t fakeCo2);
void setTimer(int32_t timestep);
void calibrateSensorToSpecificPPM(int32_t calibrationLevel);
void calibrateSensorRightNow(int32_t calibrationLevel);
void setAutoCalibration(int32_t autoCalibration);
void resetSCD();
2021-05-09 18:45:59 +00:00
}
#endif