aboutsummaryrefslogtreecommitdiff
path: root/co2.h
diff options
context:
space:
mode:
Diffstat (limited to 'co2.h')
-rw-r--r--co2.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/co2.h b/co2.h
index f75c94c..a6a1480 100644
--- a/co2.h
+++ b/co2.h
@@ -72,4 +72,42 @@ public:
Serial.println(errorMessage);
}
}
+
+ bool serialCommand(const String &tag, const String &command) {
+ if (command.startsWith("setco ")) {
+ uint16_t error;
+ char errorMessage[256];
+
+ uint16_t target = command.substring(6).toInt();
+ uint16_t correction;
+
+ scd4x.stopPeriodicMeasurement();
+ delay(500);
+ error = scd4x.performForcedRecalibration(target, correction);
+ if (error) {
+ Serial.print("! CO2 performForcedRecalibration() error: ");
+ errorToString(error, errorMessage, 256);
+ Serial.println(errorMessage);
+ }
+
+ Serial.print(tag);Serial.print(" setco ");
+ if (correction == 0xFFFF) {
+ Serial.println("failed");
+ }
+ else {
+ Serial.println(correction - 0x8000);
+ }
+
+ error = scd4x.startLowPowerPeriodicMeasurement();
+ if (error) {
+ Serial.print("! CO2 startLowPowerPeriodicMeasurement() error: ");
+ errorToString(error, errorMessage, 256);
+ Serial.println(errorMessage);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
};