RAK12027 WisBlock Earthquake Sensor Module Quick Start Guide
Prerequisite
Package Inclusions
Before going through each and every step on using the RAK12027 WisBlock module, make sure to prepare the necessary items listed below:
Hardware
- RAK12027 WisBlock Earthquake Sensor Module
- Your choice of WisBlock Base
- Your choice of WisBlock Core
- USB Cable
- RAK19005 WisBlock Sensor Extension Cable (optional)
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install the Arduino IDE.
- To add the RAKwireless Core boards on your Arduino board, install the RAKwireless Arduino BSP. Follow the steps in the GitHub repo.
Product Configuration
Hardware Setup
The RAK12027 is an Earthquake Sensor Module, a part of the RAKwireless WisBlock sensor Series. It carries D7S, the world’s smallest high-precision seismic sensor from Omron, and which also has a collapse alert system that notifies if the device changes its horizontal position by more than 20 degrees, which assumed that the structure mounted has already collapsed. It communicates with the target MCU over I2C interface, and it communicates with the target MCU over I2C interface and interrupts pins.
For more information about RAK12027, refer to the Datasheet.
Do not use the sensor in safety devices or for applications in which the sensor operation would directly affect human life.
RAK12027 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 C to F. Also, always secure the connection of the WisBlock module by using compatible screws.
Assembling and Disassembling of WisBlock Modules
Assembling
As shown in Figure 2, the location for Slots 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.
Disassembling
The procedure in disassembling any type of WisBlock module is the same.
- First, remove the screws.
- Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
- Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts. RAK12027 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.
- 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
Initial Test of the RAK12027 WisBlock Module
-
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. -
You need to select first the WisBlock Core you have.
RAK4631 Board
RAK11200 Board
RAK11310 Board
- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK12027_Earthquake_Seismograph_D7S.ino
@author rakwireless.com
@brief When the trigger earthquake occurs, the serial port outputs the SI and PGA values in the current calculation.
About 2 minutes of seismic processing ends.
After the earthquake, the value is 0.
@version 0.1
@date 2022-03-02
@copyright Copyright (c) 2022
**/
#include "RAK12027_D7S.h" // Click here to get the library: http://librarymanager/RAK12027_D7S
RAK_D7S D7S;
void setup()
{
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, LOW);
delay(1000);
digitalWrite(WB_IO2, HIGH); // Power up the D7S.
time_t timeout = millis();
Serial.begin(115200); // Initialize Serial for debug output.
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK12027 Seismograph example.");
Wire.begin();
while (!D7S.begin())
{
Serial.print(".");
}
Serial.println("STARTED");
Serial.println("Setting D7S sensor to switch axis at inizialization time.");
D7S.setAxis(SWITCH_AT_INSTALLATION); // Setting the D7S to switch the axis at inizialization time.
Serial.println("Initializing the D7S sensor in 2 seconds. Please keep it steady during the initializing process.");
delay(2000);
Serial.print("Initializing");
D7S.initialize(); // Start the initial installation procedure.
delay(500);
while (!D7S.isReady()) // Wait until the D7S is ready (the initializing process is ended).
{
Serial.print(".");
delay(500);
}
Serial.println("INITIALIZED!");
Serial.println("\nListening for earthquakes!"); // READY TO GO.
}
void loop()
{
if (D7S.isEarthquakeOccuring()) // Checking if there is an earthquake occuring right now.
{
Serial.print("Instantaneus SI: ");
Serial.print(D7S.getInstantaneusSI()); // Getting instantaneus SI.
Serial.println(" [m/s]");
Serial.print("Instantaneus PGA (Peak Ground Acceleration): ");
Serial.print(D7S.getInstantaneusPGA()); // Getting instantaneus PGA.
Serial.println(" [m/s^2]\n");
}
delay(500); // Wait 500ms before checking again.
}
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 RAK12027 WisBlock Example Code Repository. This sample code in GitHub will work on all WisBlock Core.
- Once the example code is open, install the RAK12027-D7S library by clicking the yellow-highlighted link, as shown in Figure 9 and Figure 10.
- After the 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.
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.
- When you have successfully uploaded the example sketch, open the serial monitor of the Arduino IDE and set the baud rate correctly. Try to shake the sensor and you will then see the sensor's output as shown in Figure 13. Therefore, your RAK12027 is properly communicating with the WisBlock core.
- As you might have experienced while testing, the D7S is sometimes not responding when you try to initialize it. If the module is moved or shaken immediately after powering up, it goes into
earthquake detection mode
and is not responding on I2C. It will only respond to I2C initialization commands after it left theearthquake detection mode
. - After powering up the sensor is calibrating itself, and during this time, the sensor MUST NOT be moved.