diff options
Diffstat (limited to 'co2.h')
-rw-r--r-- | co2.h | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -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; + } }; |