RAK12011 WisBlock Barometer WT Sensor Module Quick Start Guide
Prerequisite
- Assemble the RAK12011 with a WisBlock Base and WisBlock Core by following the RAK12011 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Initial Test of the RAK12011 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 example
/**
@file RAK1902_MEMS_Pressure_LPS33HW.ino
@author rakwireless.com
@brief Setup and read values from a lps33hw sensor
@version 0.1
@date 2021-07-23
@copyright Copyright (c) 2021
**/
#include <Wire.h>
#include <Adafruit_LPS2X.h>
#include <Adafruit_Sensor.h> // Click here to get the library: http://librarymanager/All#Adafruit_LPS2X
Adafruit_LPS22 g_lps22hb;
void setup(void) {
time_t timeout = millis();
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("Adafruit LPS33 test!");
// Try to initialize!
if (!g_lps22hb.begin_I2C(0x5d))
{
Serial.println("Failed to find LPS33 chip");
while (1)
{
delay(10);
}
}
Serial.println("LPS33 Found!");
g_lps22hb.setDataRate(LPS22_RATE_10_HZ);
Serial.print("Data rate set to: ");
switch (g_lps22hb.getDataRate())
{
case LPS22_RATE_ONE_SHOT: Serial.println("One Shot / Power Down");
break;
case LPS22_RATE_1_HZ: Serial.println("1 Hz");
break;
case LPS22_RATE_10_HZ: Serial.println("10 Hz");
break;
case LPS22_RATE_25_HZ: Serial.println("25 Hz");
break;
case LPS22_RATE_50_HZ: Serial.println("50 Hz");
break;
}
}
void loop() {
sensors_event_t temp;
sensors_event_t pressure;
g_lps22hb.getEvent(&pressure, &temp);
Serial.print("Temperature: ");Serial.print(temp.temperature);Serial.println(" degrees C");
Serial.print("Pressure: ");Serial.print(pressure.pressure);Serial.println(" hPa");
Serial.println("");
delay(1000);
}
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 RAK12011 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.
- Once the example code is open, install the Adafruit LPS2X library by clicking the yellow highlighted link.
Figure 1: Accessing the library used for RAK12011 Module
Figure 1: Installing the compatible library for RAK12011 Module- After 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 RAK12011 example code- When you successfully uploaded the example sketch, open the Serial Monitor of the Arduino IDE to see the sensor's reading logs. If you see the logs, then your RAK12011 is properly communicating to the WisBlock core.
Figure 1: RAK12011 Pressure & Temperature data logs