Skip to content

Commit

Permalink
Separate RAK12037 examples for the Core modules
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo committed Sep 18, 2023
1 parent 4d5e565 commit ca92184
Show file tree
Hide file tree
Showing 32 changed files with 545 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -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 <Wire.h>

#include <Adafruit_SCD30.h> // Click here to get the library: http://librarymanager/All#Adafruit_SCD30

#ifdef NRF52
#include <Adafruit_TinyUSB.h>
#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);
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -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 <Wire.h>

#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);
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -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 <Wire.h>

#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);
}
Empty file.
Empty file.
Loading

0 comments on commit ca92184

Please sign in to comment.