diff --git a/examples/Example2_SetOptions/Example2_SetOptions.ino b/examples/Example2_SetOptions/Example2_SetOptions.ino index dfbb76d..b82610d 100644 --- a/examples/Example2_SetOptions/Example2_SetOptions.ino +++ b/examples/Example2_SetOptions/Example2_SetOptions.ino @@ -42,18 +42,25 @@ void setup() airSensor.setMeasurementInterval(4); //Change number of seconds between measurements: 2 to 1800 (30 minutes) + //Read altitude compensation value + unsigned int altitude = airSensor.getAltitudeCompensation(); + Serial.print("Current altitude: "); + Serial.print(altitude); + Serial.println("m"); + //My desk is ~1600m above sealevel - airSensor.setAltitudeCompensation(1600); //Set altitude of the sensor in m + airSensor.setAltitudeCompensation(1600); //Set altitude of the sensor in m, stored in non-volatile memory of SCD30 //Pressure in Boulder, CO is 24.65inHg or 834.74mBar - airSensor.setAmbientPressure(835); //Current ambient pressure in mBar: 700 to 1200 + airSensor.setAmbientPressure(835); //Current ambient pressure in mBar: 700 to 1200, will overwrite altitude compensation + //Read temperature offset float offset = airSensor.getTemperatureOffset(); Serial.print("Current temp offset: "); Serial.print(offset, 2); Serial.println("C"); - //airSensor.setTemperatureOffset(5); //Optionally we can set temperature offset to 5°C + //airSensor.setTemperatureOffset(5); //Optionally we can set temperature offset to 5°C, stored in non-volatile memory of SCD30 } void loop() diff --git a/src/SparkFun_SCD30_Arduino_Library.cpp b/src/SparkFun_SCD30_Arduino_Library.cpp index 0922b0e..1284ae9 100644 --- a/src/SparkFun_SCD30_Arduino_Library.cpp +++ b/src/SparkFun_SCD30_Arduino_Library.cpp @@ -123,7 +123,7 @@ bool SCD30::setForcedRecalibrationFactor(uint16_t concentration) } //Get the temperature offset. See 1.3.8. -float SCD30::getTemperatureOffset() +float SCD30::getTemperatureOffset(void) { uint16_t response = readRegister(COMMAND_SET_TEMPERATURE_OFFSET); return (float)response / 100; @@ -136,6 +136,12 @@ bool SCD30::setTemperatureOffset(float tempOffset) return sendCommand(COMMAND_SET_TEMPERATURE_OFFSET, tickOffset); } +//Get the altitude compenstation. See 1.3.9. +uint16_t SCD30::getAltitudeCompensation(void) +{ + return readRegister(COMMAND_SET_ALTITUDE_COMPENSATION); +} + //Set the altitude compenstation. See 1.3.9. bool SCD30::setAltitudeCompensation(uint16_t altitude) { diff --git a/src/SparkFun_SCD30_Arduino_Library.h b/src/SparkFun_SCD30_Arduino_Library.h index 95dfea8..38b3b9f 100644 --- a/src/SparkFun_SCD30_Arduino_Library.h +++ b/src/SparkFun_SCD30_Arduino_Library.h @@ -61,6 +61,7 @@ class SCD30 float getHumidity(void); float getTemperature(void); float getTemperatureOffset(void); + uint16_t getAltitudeCompensation(void); bool setMeasurementInterval(uint16_t interval); bool setAmbientPressure(uint16_t pressure_mbar);