From ca9218486fbf64df121bf8fb85a89ceb77c57010 Mon Sep 17 00:00:00 2001 From: beegee-tokyo Date: Mon, 18 Sep 2023 15:03:28 +0800 Subject: [PATCH] Separate RAK12037 examples for the Core modules --- README.md | 4 +- .../RAK12037-RAK11200/.rak11300.test.skip | 0 .../RAK12037-RAK11200/.rak4631.test.skip | 0 .../RAK12037-RAK11200/RAK12037-RAK11200.ino | 154 ++++++++++++++++++ .../IO/RAK12037_CO2_SCD30/.rak11200.test.skip | 0 .../IO/RAK12037_CO2_SCD30/.rak4631.test.skip | 0 .../.rak11200.test.skip | 0 .../.rak4631.test.skip | 0 .../RAK12037_AutoCalibrate_SCD30.ino | 0 .../.rak11200.test.skip | 0 .../.rak4631.test.skip | 0 .../RAK12037_BasicReadings_SCD30.ino | 0 .../.rak11200.test.skip | 0 .../.rak4631.test.skip | 0 .../RAK12037_GetSettings_SCD30.ino | 0 .../.rak11200.test.skip | 0 .../.rak4631.test.skip | 0 .../RAK12037_SetOptions_SCD30.ino | 0 .../IO/RAK12037_CO2_SCD30/.rak11200.test.skip | 0 .../IO/RAK12037_CO2_SCD30/.rak11300.test.skip | 0 .../.rak11200.test.skip | 0 .../.rak11300.test.skip | 0 .../RAK12037_AutoCalibrate_SCD30.ino | 75 +++++++++ .../.rak11200.test.skip | 0 .../.rak11300.test.skip | 0 .../RAK12037_BasicReadings_SCD30.ino | 69 ++++++++ .../.rak11200.test.skip | 0 .../.rak11300.test.skip | 0 .../RAK12037_GetSettings_SCD30.ino | 147 +++++++++++++++++ .../.rak11200.test.skip | 0 .../.rak11300.test.skip | 0 .../RAK12037_SetOptions_SCD30.ino | 97 +++++++++++ 32 files changed, 545 insertions(+), 1 deletion(-) create mode 100644 examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak11300.test.skip create mode 100644 examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak4631.test.skip create mode 100644 examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/RAK12037-RAK11200.ino create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak11200.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak4631.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak4631.test.skip rename examples/{common => RAK11300}/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino (100%) create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak4631.test.skip rename examples/{common => RAK11300}/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino (100%) create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak4631.test.skip rename examples/{common => RAK11300}/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino (100%) create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip create mode 100644 examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak4631.test.skip rename examples/{common => RAK11300}/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino (100%) create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11200.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11300.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11300.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11300.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11300.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11300.test.skip create mode 100644 examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino diff --git a/README.md b/README.md index e25c2f7c..f12cd461 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,6 @@ To buy WisBlock modules please visit our [online store](https://store.rakwireles - [RAK12029-LDC1614](/examples/common/IO/RAK12029-LDC1614) - [RAK12031_T_Fork_SX1041](/examples/common/IO/RAK12031_T_Fork_SX1041) - [RAK12035_SoilMoisture](/examples/common/IO/RAK12035_SoilMoisture) - - [RAK12037_CO2_SCD30](/examples/common/IO/RAK12037_CO2_SCD30) - [RAK12035_SoilMoisture](/examples/common/IO/RAK12035_SoilMoisture) - [RAK12039_Dust_Detection](/examples/common/IO/RAK12039_Dust_Detection) - [RAK12052 IR Array](/examples/common/IO/RAK12052) @@ -199,6 +198,7 @@ To buy WisBlock modules please visit our [online store](https://store.rakwireles - [RAK5801_4-20mA](/examples/RAK4630/IO/RAK5801_4-20mA/) - [RAK5802_RS485](/examples/RAK4630/IO/RAK5802_RS485/) - [RAK5811_0-5V](/examples/RAK4630/IO/RAK5811_0-5V/) + - [RAK12037_CO2_SCD30](/examples/RAK4630/IO/RAK12037_CO2_SCD30) - [RAK15002_SD_Card](/examples/RAK4630/IO/RAK15002_SD_Card) - [RAK17000_Motor_Driver_DRV8833](/examples/RAK4630/IO/RAK17000_Motor_Driver_DRV8833) - [RAK17000_Stepper_Driver_DRV8833](/examples/RAK4630/IO/RAK17000_Stepper_Driver_DRV8833) @@ -274,6 +274,7 @@ To buy WisBlock modules please visit our [online store](https://store.rakwireles - [RAK5801_4-20mA](/examples/RAK11200/IO/RAK5801_4-20mA/) - [RAK5802_RS485](/examples/RAK11200/IO/RAK5802_RS485/) - [RAK5811_0-5V](/examples/RAK11200/IO/RAK5811_0-5V/) + - [RAK12037_CO2_SCD30](/examples/RAK11200/IO/RAK12037_CO2_SCD30) - [RAK15002_SD_Card](/examples/RAK11200/IO/RAK15002_SD_Card) - [RAK17000_Motor_Driver_DRV8833](/examples/RAK11200/IO/RAK17000_Motor_Driver_DRV8833) - [RAK17000_Stepper_Driver_DRV8833](/examples/RAK11200/IO/RAK17000_Stepper_Driver_DRV8833) @@ -329,6 +330,7 @@ To buy WisBlock modules please visit our [online store](https://store.rakwireles - [RAK5802_RS485](/examples/RAK11300/IO/RAK5802_RS485/) - [RAK5801_4-20mA](/examples/RAK11300/IO/RAK5801_4-20mA/) - [RAK5811_0-5V](/examples/RAK11300/IO/RAK5811_0-5V/) + - [RAK12037_CO2_SCD30](/examples/RAK11300/IO/RAK12037_CO2_SCD30) - [RAK15002_SD_Card](/examples/RAK11300/IO/RAK15002_SD_Card) - [RAK17000_Motor_Driver_DRV8833](/examples/RAK11300/IO/RAK17000_Motor_Driver_DRV8833) - [RAK17000_Stepper_Driver_DRV8833](/examples/RAK11300/IO/RAK17000_Stepper_Driver_DRV8833) diff --git a/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak11300.test.skip b/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak4631.test.skip b/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/RAK12037-RAK11200.ino b/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/RAK12037-RAK11200.ino new file mode 100644 index 00000000..d5896c4c --- /dev/null +++ b/examples/RAK11200/IO/RAK12037_CO2_SCD30/RAK12037-RAK11200/RAK12037-RAK11200.ino @@ -0,0 +1,154 @@ +/** + @file RAK12037_BasicReadings_SCD30.ino + @author rakwireless.com + @brief Example of reading SCD30 sensor and displaying data through serial port. + @version 0.1 + @date 2022-1-18 + @copyright Copyright (c) 2022 +**/ + +#include + +#include // Click here to get the library: http://librarymanager/All#Adafruit_SCD30 + +#ifdef NRF52 +#include +#endif + +Adafruit_SCD30 scd30; + +void setup() +{ + pinMode(WB_IO2, OUTPUT); + digitalWrite(WB_IO2, HIGH); + + // Initialize Serial for debug output + time_t timeout = millis(); + Serial.begin(115200); + while (!Serial) + { + if ((millis() - timeout) < 5000) + { + delay(100); + } + else + { + break; + } + } + + Serial.println("SCD30 Basic Readings Example."); + + Wire.begin(); + + if (scd30.begin() == false) + { + Serial.println("Air sensor not detected. Please check wiring. Freezing..."); + while (1) + { + delay(10); + } + } + + /*** Adjust the rate at which measurements are taken, from 2-1800 seconds */ + // if (!scd30.setMeasurementInterval(5)) { + // Serial.println("Failed to set measurement interval"); + // while(1){ delay(10);} + // } + Serial.print("Measurement interval: "); + Serial.print(scd30.getMeasurementInterval()); + Serial.println(" seconds"); + + /*** Restart continuous measurement with a pressure offset from 700 to 1400 millibar. + * Giving no argument or setting the offset to 0 will disable offset correction + */ + // if (!scd30.startContinuousMeasurement(15)){ + // Serial.println("Failed to set ambient pressure offset"); + // while(1){ delay(10);} + // } + Serial.print("Ambient pressure offset: "); + Serial.print(scd30.getAmbientPressureOffset()); + Serial.println(" mBar"); + + /*** Set an altitude offset in meters above sea level. + * Offset value stored in non-volatile memory of SCD30. + * Setting an altitude offset will override any pressure offset. + */ + // if (!scd30.setAltitudeOffset(110)){ + // Serial.println("Failed to set altitude offset"); + // while(1){ delay(10);} + // } + Serial.print("Altitude offset: "); + Serial.print(scd30.getAltitudeOffset()); + Serial.println(" meters"); + + /*** Set a temperature offset in hundredths of a degree celcius. + * Offset value stored in non-volatile memory of SCD30. + */ + // if (!scd30.setTemperatureOffset(1984)){ // 19.84 degrees celcius + // Serial.println("Failed to set temperature offset"); + // while(1){ delay(10);} + // } + Serial.print("Temperature offset: "); + Serial.print((float)scd30.getTemperatureOffset() / 100.0); + Serial.println(" degrees C"); + + /*** Force the sensor to recalibrate with the given reference value + * from 400-2000 ppm. Writing a recalibration reference will overwrite + * any previous self calibration values. + * Reference value stored in non-volatile memory of SCD30. + */ + // if (!scd30.forceRecalibrationWithReference(400)){ + // Serial.println("Failed to force recalibration with reference"); + // while(1) { delay(10); } + // } + Serial.print("Forced Recalibration reference: "); + Serial.print(scd30.getForcedCalibrationReference()); + Serial.println(" ppm"); + + /*** Enable or disable automatic self calibration (ASC). + * Parameter stored in non-volatile memory of SCD30. + * Enabling self calibration will override any previously set + * forced calibration value. + * ASC needs continuous operation with at least 1 hour + * 400ppm CO2 concentration daily. + */ + // if (!scd30.selfCalibrationEnabled(true)){ + // Serial.println("Failed to enable or disable self calibration"); + // while(1) { delay(10); } + // } + if (scd30.selfCalibrationEnabled()) + { + Serial.println("Self calibration enabled"); + } + else + { + Serial.println("Self calibration disabled"); + } +} + +void loop() +{ + if (scd30.dataReady()) + { + if (!scd30.read()) + { + Serial.println("Error reading sensor data"); + return; + } + Serial.print("co2(ppm):"); + Serial.print(scd30.CO2,3); + + Serial.print(" temp(C):"); + Serial.print(scd30.temperature, 1); + + Serial.print(" humidity(%):"); + Serial.print(scd30.relative_humidity, 1); + + Serial.println(); + } + else + Serial.println("Waiting for new data"); + + delay(3000); +} \ No newline at end of file diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak11200.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak4631.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak4631.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/common/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino similarity index 100% rename from examples/common/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino rename to examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak4631.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/common/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino similarity index 100% rename from examples/common/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino rename to examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak4631.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/common/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino similarity index 100% rename from examples/common/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino rename to examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak4631.test.skip b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak4631.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/common/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino b/examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino similarity index 100% rename from examples/common/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino rename to examples/RAK11300/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11200.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11300.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11300.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino new file mode 100644 index 00000000..5de11403 --- /dev/null +++ b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_AutoCalibrate_SCD30/RAK12037_AutoCalibrate_SCD30.ino @@ -0,0 +1,75 @@ +/** + @file RAK12037_AutoCalibrate_SCD30.ino + @author rakwireless.com + @brief SCD30 Automatic self-calibration(ASC) Example. + @version 0.1 + @date 2022-1-18 + @copyright Copyright (c) 2022 +**/ +#include + +#include "SparkFun_SCD30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SCD30 + +SCD30 airSensor; + +void setup() +{ + pinMode(WB_IO2, OUTPUT); + digitalWrite(WB_IO2, HIGH); + + // Initialize Serial for debug output + time_t timeout = millis(); + Serial.begin(115200); + while (!Serial) + { + if ((millis() - timeout) < 5000) + { + delay(100); + } + else + { + break; + } + } + + Serial.println("SCD30 Automatic self-calibration Example."); + + Wire.begin(); + + //Start sensor using the Wire port and enable the auto-calibration (ASC) + if (airSensor.begin(Wire, true) == false) + { + Serial.println("Air sensor not detected. Please check wiring. Freezing..."); + while (1) + { + delay(10); + } + } + + Serial.print("Automatic self-calibration set to:"); + if (airSensor.getAutoSelfCalibration() == true) + Serial.println("true"); + else + Serial.println("false"); +} + +void loop() +{ + if (airSensor.dataAvailable()) + { + Serial.print("co2(ppm):"); + Serial.print(airSensor.getCO2()); + + Serial.print(" temp(C):"); + Serial.print(airSensor.getTemperature(), 1); + + Serial.print(" humidity(%):"); + Serial.print(airSensor.getHumidity(), 1); + + Serial.println(); + } + else + Serial.println("Waiting for new data"); + + delay(3000); +} diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11300.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino new file mode 100644 index 00000000..8c698917 --- /dev/null +++ b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_BasicReadings_SCD30/RAK12037_BasicReadings_SCD30.ino @@ -0,0 +1,69 @@ +/** + @file RAK12037_BasicReadings_SCD30.ino + @author rakwireless.com + @brief Example of reading SCD30 sensor and displaying data through serial port. + @version 0.1 + @date 2022-1-18 + @copyright Copyright (c) 2022 +**/ + +#include + +#include "SparkFun_SCD30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SCD30 + +SCD30 airSensor; + +void setup() +{ + pinMode(WB_IO2, OUTPUT); + digitalWrite(WB_IO2, HIGH); + + // Initialize Serial for debug output + time_t timeout = millis(); + Serial.begin(115200); + while (!Serial) + { + if ((millis() - timeout) < 5000) + { + delay(100); + } + else + { + break; + } + } + + Serial.println("SCD30 Basic Readings Example."); + + Wire.begin(); + + if (airSensor.begin() == false) + { + Serial.println("Air sensor not detected. Please check wiring. Freezing..."); + while (1) + { + delay(10); + } + } +} + +void loop() +{ + if (airSensor.dataAvailable()) + { + Serial.print("co2(ppm):"); + Serial.print(airSensor.getCO2()); + + Serial.print(" temp(C):"); + Serial.print(airSensor.getTemperature(), 1); + + Serial.print(" humidity(%):"); + Serial.print(airSensor.getHumidity(), 1); + + Serial.println(); + } + else + Serial.println("Waiting for new data"); + + delay(3000); +} diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11300.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino new file mode 100644 index 00000000..028b1cc5 --- /dev/null +++ b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_GetSettings_SCD30/RAK12037_GetSettings_SCD30.ino @@ -0,0 +1,147 @@ +/** + @file RAK12037_GetSettings_SCD30.ino + @author rakwireless.com + @brief SCD30 get setting information example. + @version 0.1 + @date 2022-1-18 + @copyright Copyright (c) 2022 +**/ + +#include + +#include "SparkFun_SCD30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SCD30 + +SCD30 airSensor; + +void setup() +{ + pinMode(WB_IO2, OUTPUT); + digitalWrite(WB_IO2, HIGH); + + // Initialize Serial for debug output + time_t timeout = millis(); + Serial.begin(115200); + while (!Serial) + { + if ((millis() - timeout) < 5000) + { + delay(100); + } + else + { + break; + } + } + Serial.println("SCD30 Get Settings Example."); + + Wire.begin(); + + // Start sensor using the Wire port, but disable the auto-calibration + if (airSensor.begin(Wire, false) == false) + { + Serial.println("Air sensor not detected. Please check wiring. Freezing..."); + while (1) + { + delay(10); + } + } + + uint16_t settingVal; // The settings will be returned in settingVal + + if (airSensor.getForcedRecalibration(&settingVal) == true) // Get the setting + { + Serial.print("Forced recalibration factor (ppm) is "); + Serial.println(settingVal); + } + else + { + Serial.print("getForcedRecalibration failed! Freezing..."); + while (1) + { + delay(10); + } + } + + if (airSensor.getMeasurementInterval(&settingVal) == true) // Get the setting + { + Serial.print("Measurement interval (s) is "); + Serial.println(settingVal); + } + else + { + Serial.print("getMeasurementInterval failed! Freezing..."); + while (1) + { + delay(10); + } + } + + if (airSensor.getTemperatureOffset(&settingVal) == true) // Get the setting + { + Serial.print("Temperature offset (C) is "); + Serial.println(((float)settingVal) / 100.0, 2); + } + else + { + Serial.print("getTemperatureOffset failed! Freezing..."); + while (1) + { + delay(10); + } + } + + if (airSensor.getAltitudeCompensation(&settingVal) == true) // Get the setting + { + Serial.print("Altitude offset (m) is "); + Serial.println(settingVal); + } + else + { + Serial.print("getAltitudeCompensation failed! Freezing..."); + while (1) + { + delay(10); + } + } + + if (airSensor.getFirmwareVersion(&settingVal) == true) // Get the setting + { + Serial.print("Firmware version is 0x"); + Serial.println(settingVal, HEX); + } + else + { + Serial.print("getFirmwareVersion! Freezing..."); + while (1) + { + delay(10); + } + } + + Serial.print("Auto calibration set to "); + if (airSensor.getAutoSelfCalibration() == true) + Serial.println("true"); + else + Serial.println("false"); +} + +void loop() +{ + if (airSensor.dataAvailable()) + { + Serial.print("co2(ppm):"); + Serial.print(airSensor.getCO2()); + + Serial.print(" temp(C):"); + Serial.print(airSensor.getTemperature(), 1); + + Serial.print(" humidity(%):"); + Serial.print(airSensor.getHumidity(), 1); + + Serial.println(); + } + else + Serial.println("Waiting for new data"); + + delay(3000); +} diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11200.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11300.test.skip b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/.rak11300.test.skip new file mode 100644 index 00000000..e69de29b diff --git a/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino new file mode 100644 index 00000000..8309a5e8 --- /dev/null +++ b/examples/RAK4630/IO/RAK12037_CO2_SCD30/RAK12037_SetOptions_SCD30/RAK12037_SetOptions_SCD30.ino @@ -0,0 +1,97 @@ +/** + @file RAK12037_GetSettings_SCD30.ino + @author rakwireless.com + @brief Example of SCD30 set options. + @version 0.1 + @date 2022-1-18 + @copyright Copyright (c) 2022 +**/ + +#include + +#include "SparkFun_SCD30_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_SCD30 +SCD30 airSensor; + +void setup() +{ + pinMode(WB_IO2, OUTPUT); + digitalWrite(WB_IO2, HIGH); + + // Initialize Serial for debug output + time_t timeout = millis(); + Serial.begin(115200); + while (!Serial) + { + if ((millis() - timeout) < 5000) + { + delay(100); + } + else + { + break; + } + } + Serial.println("SCD30 Set Options Example."); + + Wire.begin(); + + if (airSensor.begin() == false) + { + Serial.println("Air sensor not detected. Please check wiring. Freezing..."); + while (1) + { + delay(10); + } + } + + // Change number of seconds between measurements: 2 to 1800 (30 minutes), stored in non-volatile memory of SCD30 + airSensor.setMeasurementInterval(16); + + // While the setting is recorded, it is not immediately available to be read. + delay(200); + + int interval = airSensor.getMeasurementInterval(); + Serial.print("Measurement Interval: "); + Serial.println(interval); + + // My desk is ~1600m above sealevel + airSensor.setAltitudeCompensation(1600); // Set altitude of the sensor in m, stored in non-volatile memory of SCD30 + + // Read altitude compensation value + unsigned int altitude = airSensor.getAltitudeCompensation(); + Serial.print("Current altitude: "); + Serial.print(altitude); + Serial.println("m"); + + // Pressure in Boulder, CO is 24.65inHg or 834.74mBar + airSensor.setAmbientPressure(835); // Current ambient pressure in mBar: 700 to 1200, will overwrite altitude compensation + + airSensor.setTemperatureOffset(5); // Optionally we can set temperature offset to 5°C, stored in non-volatile memory of SCD30 + + // Read temperature offset + float offset = airSensor.getTemperatureOffset(); + Serial.print("Current temp offset: "); + Serial.print(offset, 2); + Serial.println("C"); +} + +void loop() +{ + if (airSensor.dataAvailable()) + { + Serial.print("co2(ppm):"); + Serial.print(airSensor.getCO2()); + + Serial.print(" temp(C):"); + Serial.print(airSensor.getTemperature(), 1); + + Serial.print(" humidity(%):"); + Serial.print(airSensor.getHumidity(), 1); + + Serial.println(); + } + else + Serial.print("."); + + delay(1000); +}