Skip to content

Commit

Permalink
Set auto-calibrate to false by default. Change example to enable cal.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseidle committed Feb 26, 2021
1 parent 42f08eb commit d820d0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15112
This example turns off the auto-calibrate function during .begin()
This example turns on the auto-calibrate function during .begin()
Please see section 1.3.6 of the SCD30 datasheet:
"When activated for the first time a
period of minimum 7 days is needed so that the algorithm can find its initial parameter set for ASC. The sensor has to be exposed
to fresh air for at least 1 hour every day. Also during that period, the sensor may not be disconnected from the power supply,
otherwise the procedure to find calibration parameters is aborted and has to be restarted from the beginning. The successfully
calculated parameters are stored in non-volatile memory of the SCD30 having the effect that after a restart the previously found
parameters for ASC are still present. "
Hardware Connections:
Attach RedBoard to computer using a USB cable.
Expand All @@ -29,7 +37,7 @@ void setup()
Wire.begin();

//Start sensor using the Wire port, but disable the auto-calibration
if (airSensor.begin(Wire, false) == false)
if (airSensor.begin(Wire, true) == false)
{
Serial.println("Air sensor not detected. Please check wiring. Freezing...");
while (1)
Expand Down
25 changes: 12 additions & 13 deletions src/SparkFun_SCD30_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
#define COMMAND_STOP_MEAS 0x0104
#define COMMAND_READ_FW_VER 0xD100

typedef union {
byte array[4];
float value;
typedef union
{
byte array[4];
float value;
} ByteToFl; // paulvha

class SCD30
Expand All @@ -69,9 +70,9 @@ class SCD30

bool begin(bool autoCalibrate) { return begin(Wire, autoCalibrate); }
#ifdef USE_TEENSY3_I2C_LIB
bool begin(i2c_t3 &wirePort = Wire, bool autoCalibrate=true, bool measBegin=true); //By default use Wire port
bool begin(i2c_t3 &wirePort = Wire, bool autoCalibrate = false, bool measBegin = true); //By default use Wire port
#else
bool begin(TwoWire &wirePort = Wire, bool autoCalibrate=true, bool measBegin=true); //By default use Wire port
bool begin(TwoWire &wirePort = Wire, bool autoCalibrate = false, bool measBegin = true); //By default use Wire port
#endif

void enableDebugging(Stream &debugPort = Serial); //Turn on debug printing. If user doesn't specify then Serial will be used.
Expand All @@ -82,11 +83,11 @@ class SCD30

// based on paulvha
bool getSettingValue(uint16_t registerAddress, uint16_t *val);
bool getForcedRecalibration(uint16_t *val) {return(getSettingValue(COMMAND_SET_FORCED_RECALIBRATION_FACTOR, val));}
bool getMeasurementInterval(uint16_t *val) {return(getSettingValue(COMMAND_SET_MEASUREMENT_INTERVAL, val));}
bool getTemperatureOffset(uint16_t *val) {return(getSettingValue(COMMAND_SET_TEMPERATURE_OFFSET, val));}
bool getAltitudeCompensation(uint16_t *val) {return(getSettingValue(COMMAND_SET_ALTITUDE_COMPENSATION, val));}
bool getFirmwareVersion(uint16_t *val) {return(getSettingValue(COMMAND_READ_FW_VER, val));}
bool getForcedRecalibration(uint16_t *val) { return (getSettingValue(COMMAND_SET_FORCED_RECALIBRATION_FACTOR, val)); }
bool getMeasurementInterval(uint16_t *val) { return (getSettingValue(COMMAND_SET_MEASUREMENT_INTERVAL, val)); }
bool getTemperatureOffset(uint16_t *val) { return (getSettingValue(COMMAND_SET_TEMPERATURE_OFFSET, val)); }
bool getAltitudeCompensation(uint16_t *val) { return (getSettingValue(COMMAND_SET_ALTITUDE_COMPENSATION, val)); }
bool getFirmwareVersion(uint16_t *val) { return (getSettingValue(COMMAND_READ_FW_VER, val)); }

uint16_t getCO2(void);
float getHumidity(void);
Expand Down Expand Up @@ -115,12 +116,11 @@ class SCD30
uint8_t computeCRC8(uint8_t data[], uint8_t len);

private:

//Variables
#ifdef USE_TEENSY3_I2C_LIB
i2c_t3 *_i2cPort; //The generic connection to user's chosen I2C hardware
#else
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
#endif
//Global main datums
float co2 = 0;
Expand All @@ -136,6 +136,5 @@ class SCD30
//Debug
Stream *_debugPort; //The stream to send debug messages to if enabled. Usually Serial.
boolean _printDebug = false; //Flag to print debugging variables

};
#endif

0 comments on commit d820d0c

Please sign in to comment.