Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
402023d9
Commit
402023d9
authored
Apr 19, 2021
by
Eric Duminil
Browse files
CO2 sensor: auto-calibrate command
parent
24443b0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
402023d9
...
...
@@ -14,7 +14,7 @@ namespace config {
#else
const
float
temperature_offset
=
-
3.0
;
// [K] Temperature measured by sensor is usually at least 3K too high.
#endif
const
bool
auto_calibrate_sensor
=
AUTO_CALIBRATE_SENSOR
;
// [true / false]
bool
auto_calibrate_sensor
=
AUTO_CALIBRATE_SENSOR
;
// [true / false]
}
namespace
sensor
{
...
...
@@ -78,6 +78,10 @@ namespace sensor {
" 600 (Starts calibration process, to given ppm)"
);
sensor_console
::
defineIntCommand
(
"calibrate!"
,
calibrateSensorRightNow
,
" 600 (Calibrates right now, to given ppm)"
);
sensor_console
::
defineIntCommand
(
"calibrate!"
,
calibrateSensorRightNow
,
" 600 (Calibrates right now, to given ppm)"
);
sensor_console
::
defineIntCommand
(
"auto_calibrate"
,
setAutoCalibration
,
" 0/1 (Disables/enables autocalibration)"
);
sensor_console
::
defineCommand
(
"reset"
,
[]()
{
ESP
.
restart
();
},
" (Restarts the sensor)"
);
...
...
@@ -211,6 +215,13 @@ namespace sensor {
Serial
.
println
(
co2
);
}
void
setAutoCalibration
(
int32_t
autoCalibration
)
{
config
::
auto_calibrate_sensor
=
autoCalibration
;
scd30
.
setAutoSelfCalibration
(
autoCalibration
);
Serial
.
print
(
F
(
"Setting auto-calibration to : "
));
Serial
.
println
(
autoCalibration
?
F
(
"On."
)
:
F
(
"Off."
));
}
void
setTimer
(
int32_t
timestep
)
{
if
(
timestep
>=
2
&&
timestep
<=
1800
)
{
Serial
.
print
(
F
(
"Setting Measurement Interval to : "
));
...
...
ampel-firmware/co2_sensor.h
View file @
402023d9
...
...
@@ -12,7 +12,7 @@
namespace
config
{
extern
uint16_t
measurement_timestep
;
// [s] Value between 2 and 1800 (range for SCD30 sensor)
extern
const
bool
auto_calibrate_sensor
;
// [true / false]
extern
bool
auto_calibrate_sensor
;
// [true / false]
extern
uint16_t
co2_calibration_level
;
// [ppm]
extern
const
float
temperature_offset
;
// [K] Sign isn't relevant.
}
...
...
@@ -32,5 +32,6 @@ namespace sensor {
void
setTimer
(
int32_t
timestep
);
void
calibrateSensorToSpecificPPM
(
int32_t
calibrationLevel
);
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
);
void
setAutoCalibration
(
int32_t
autoCalibration
);
}
#endif
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