Skip to main content

RAK1902 WisBlock Barometer Pressure Sensor Module Quick Start Guide

Prerequisite

What Do You Need?

Before going through each and every step on using the RAK1902 WisBlock module, make sure to prepare the necessary items listed below:

Hardware

Software

Product Configuration

Hardware Setup

WisBlock can integrate this module, which calculates temperature and makes it easy to build up a barometric air pressure data acquisition system.

For more information about the RAK1902, refer to the Datasheet.

The RAK1902 module gives us information about:

  • Barometric Pressure
  • Environment Temperature

RAK1902 module can be connected to the sensor's slot of WisBlock Base to communicate with the WisBlock Core, as shown in Figure 1. It will work on SLOT A to F. Also, always secure the connection of the WisBlock module by using compatible screws.

Figure 1: RAK1902 connection to WisBlock Base

Assembling and Disassembling of WisBlock Modules

Assembling

As shown in Figure 2, the location for Slot A, B, C, and D are properly marked by silkscreen. Follow carefully the procedure defined in WisBlock Base board assembly/disassembly instructions to attach a WisBlock module. Once attached, carefully fix the module with one or more pieces of M1.2 x 3 mm screws depending on the module.

Figure 2: RAK1902 connection to WisBlock Base
Disassembling

The procedure in disassembling any type of WisBlock modules is the same.

  1. Remove the screws.
Figure 3: Removing screws from the WisBlock module
  1. Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
Figure 4: Detaching silkscreen on the WisBlock module
  1. Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
Figure 5: Applying even forces on the proper location of a WisBlock module
NOTE

If you will connect other modules to remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts. RAK1902 uses I2C communication lines, and it can cause possible conflict especially on some IO modules.

After all this setup, you can now connect the battery (optional) and USB cable to start programming your WisBlock Core.

warning
  • Batteries can cause harm if not handled properly.
  • Only 3.7-4.2 V Rechargeable LiPo batteries are supported. It is highly recommended not to use other types of batteries with the system unless you know what you are doing.
  • If a non-rechargeable battery is used, it has to be unplugged first before connecting the USB cable to the USB port of the board to configure the device. Not doing so might damage the battery or cause a fire.
  • Only 5 V solar panels are supported. Do not use 12 V solar panels. It will destroy the charging unit and eventually other electronic parts.
  • Make sure the battery wires match the polarity on the WisBlock Base board. Not all batteries have the same wiring.

Software Configuration and Example

The RAK1902 is a pressure sensor board that contains LPS22HB chip. The LPS22HB is an ultra-compact piezoresistive absolute pressure sensor that functions as a digital output barometer. The device comprises a sensing element and an IC interface which communicates through I2C from the sensing element to the application.

Initial Test of the RAK1902 WisBlock Module

  1. Install the RAKwireless Arduino BSP for WisBlock by using the package_rakwireless_index.json board installation package. The WisBlock Core should now be available on the Arduino IDE.

  2. You need to select the WisBlock Core you have.

RAK4631 Board

Figure 6: Selecting RAK4631 as WisBlock Core

RAK11200 Board

Figure 7: Selecting RAK11200 as WisBlock Core

RAK11310 Board

Figure 8: Selecting RAK11310 as WisBlock Core
  1. Copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK1902_Pressure_LPS22HB.ino
@author rakwireless.com
@brief Setup and read values from a lps22hb sensor
@version 0.1
@date 2020-12-28
@copyright Copyright (c) 2020
**/


#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 LPS22 test!");

// Try to initialize!
if (!g_lps22hb.begin_I2C(0x5c))
{
Serial.println("Failed to find LPS22 chip");
while (1)
{
delay(10);
}
}

Serial.println("LPS22 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);
}
NOTE

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 RAK1902 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.

  1. Once the example code is open, install the Adafruit LPS2X library by clicking the yellow highlighted link, as shown in Figure 9 and Figure 10.
Figure 9: Accessing the library used for RAK1902 Module
Figure 10: Installing the compatible library for RAK1902 Module
  1. After successful installation of the library, you can now select the right serial port and upload the code, as shown in Figure 11 and Figure 12.
NOTE

If you are using the RAK11200 as your WisBlock Core, the RAK11200 requires the Boot0 pin to be configured properly first before uploading. If not done properly, uploading the source code to RAK11200 will fail. Check the full details on the RAK11200 Quick Start Guide.

Figure 11: Selecting the correct Serial Port
Figure 12: Uploading the RAK1902 example code
  1. 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, as shown in Figure 13, then your RAK1902 is properly communicating to the WisBlock core.
Figure 13: RAK1902 pressure and temperature data logs

LoRaWAN Weather Monitoring with RAK1902

For WisBlock Core RAK4630, it has an example for LoRaWAN Weather Monitoring with RAK1902 Pressure Module.

Figure 14: LoRaWAN Weather Monitoring example