Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
27c096f8
Commit
27c096f8
authored
Dec 20, 2020
by
Eric Duminil
Browse files
Checking sensor timer deviation
parent
167acc9c
Changes
1
Show whitespace changes
Inline
Side-by-side
co2_sensor.cpp
View file @
27c096f8
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment