From af8672b1434e0be245dad4ef2d5e653bd2e85963 Mon Sep 17 00:00:00 2001 From: Joel Brun Date: Thu, 26 Dec 2019 15:47:29 +0100 Subject: [PATCH] Add "getTemperatureOffset()" --- examples/Example2_SetOptions/Example2_SetOptions.ino | 5 ++++- keywords.txt | 1 + src/SparkFun_SCD30_Arduino_Library.cpp | 7 +++++++ src/SparkFun_SCD30_Arduino_Library.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/Example2_SetOptions/Example2_SetOptions.ino b/examples/Example2_SetOptions/Example2_SetOptions.ino index e53049f..4c66955 100644 --- a/examples/Example2_SetOptions/Example2_SetOptions.ino +++ b/examples/Example2_SetOptions/Example2_SetOptions.ino @@ -45,6 +45,10 @@ void setup() //Pressure in Boulder, CO is 24.65inHg or 834.74mBar airSensor.setAmbientPressure(835); //Current ambient pressure in mBar: 700 to 1200 + + float offset = airSensor.getTemperatureOffset(); //Get current temperature offset and save it in the variable "offset" + + airSensor.setTemperatureOffset(5); //Set temperature offset to 5°C } void loop() @@ -67,4 +71,3 @@ void loop() delay(1000); } - diff --git a/keywords.txt b/keywords.txt index 943a8a5..82d47f8 100644 --- a/keywords.txt +++ b/keywords.txt @@ -19,6 +19,7 @@ beginMeasuring KEYWORD2 getCO2 KEYWORD2 getHumidity KEYWORD2 getTemperature KEYWORD2 +getTemperatureOffset KEYWORD2 setMeasurementInterval KEYWORD2 setAmbientPressure KEYWORD2 setAltitudeCompensation KEYWORD2 diff --git a/src/SparkFun_SCD30_Arduino_Library.cpp b/src/SparkFun_SCD30_Arduino_Library.cpp index 3c5d2a9..e3a805a 100644 --- a/src/SparkFun_SCD30_Arduino_Library.cpp +++ b/src/SparkFun_SCD30_Arduino_Library.cpp @@ -123,6 +123,13 @@ void SCD30::setForcedRecalibrationFactor(uint16_t concentration) sendCommand(COMMAND_SET_FORCED_RECALIBRATION_FACTOR, concentration); } +//Get the temperature offset. See 1.3.8. +float SCD30::getTemperatureOffset() +{ + uint16_t response = readRegister(COMMAND_SET_TEMPERATURE_OFFSET); + return (float) response / 100; +} + //Set the temperature offset. See 1.3.8. void SCD30::setTemperatureOffset(float tempOffset) { diff --git a/src/SparkFun_SCD30_Arduino_Library.h b/src/SparkFun_SCD30_Arduino_Library.h index 9517cfa..6251aa5 100644 --- a/src/SparkFun_SCD30_Arduino_Library.h +++ b/src/SparkFun_SCD30_Arduino_Library.h @@ -62,6 +62,7 @@ class SCD30 uint16_t getCO2(void); float getHumidity(void); float getTemperature(void); + float getTemperatureOffset(void); void setMeasurementInterval(uint16_t interval); void setAmbientPressure(uint16_t pressure_mbar);