Commit 27c096f8 authored by Eric Duminil's avatar Eric Duminil
Browse files

Checking sensor timer deviation

parent 167acc9c
......@@ -46,6 +46,7 @@ namespace sensor {
}
// SCD30 has its own timer.
//NOTE: The timer seems to be inaccurate, though, possibly depending on voltage. Should it be offset?
Serial.println();
Serial.print(F("Setting SCD30 timestep to "));
Serial.print(config::measurement_timestep);
......@@ -66,10 +67,21 @@ namespace sensor {
Serial.println(config::auto_calibrate_sensor ? "ON." : "OFF.");
}
//NOTE: should time offset be used to reset measurement_timestep?
void checkTimerDeviation() {
static int32_t previous_measurement_at = 0; // Used to monitor sensor timer offset.
int32_t now = millis();
Serial.print("Measurement time offset : ");
Serial.print(now - previous_measurement_at - config::measurement_timestep * 1000);
Serial.println(" ms.");
previous_measurement_at = now;
}
bool updateDataIfAvailable() {
//TODO: Save count of stable measurements
//TODO: Compare time to previous measurements, check that it's not too far away from config::measurement_interval
static int16_t previous_co2 = 0;
if (scd30.dataAvailable()) {
// checkTimerDeviation();
co2 = scd30.getCO2();
temperature = scd30.getTemperature();
humidity = scd30.getHumidity();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment