RAK12037 WisBlock CO2 Sensor Module Quick Start Guide
Prerequisite
-
Assemble the RAK12037 with a WisBlock Base and WisBlock Core by following the RAK12037 Installation Guide.
-
Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
-
USB Cable
Initial Test of the RAK12037 WisBlock Module
-
This guide uses the RAK4631 WisBlock Core to demonstrate the configuration process. You can also use the RAK11200 or RAK11310 as the WisBlock Core.
-
When using the RAK11200, configure the BOOT0 pin correctly before uploading the source code. Otherwise, the upload may fail. For detailed instructions, refer to the RAK11200 Quick Start Guide.
-
Install the RAKwireless Arduino BSP for WisBlock by using the
package_rakwireless_index.jsonboard installation package. The WisBlock Core should now be available on the Arduino IDE. -
You need to select first the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@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();
delay(500);
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);
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module that can be found on the RAK12037 WisBlock Example Code Repository and this sample code in GitHub will work on all WisBlock Core.
- Once the example code is open, install the SparkFun_SCD30 library by clicking the yellow highlighted link.
Figure 1: Accessing the library used for RAK12037 Module
Figure 1: Installing the compatible library for RAK12037 Module- After the successful installation of the library, you can now select the right serial port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK12037 example code- When you have successfully uploaded the example sketch, open the serial monitor of the Arduino IDE and set the baud rate correctly. You will then see the sensor's output. Therefore, your RAK12037 is properly communicating with the WisBlock core.
Figure 1: RAK12037 CO2 Sensor Serial Readings