RAK12027 WisBlock Earthquake Sensor Module Quick Start Guide
Prerequisite
-
Assemble the RAK12027 with a WisBlock Base and WisBlock Core by following the RAK12027 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 RAK12027 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 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.
Figure 1: Accessing the library used for RAK12027 Module
Figure 1: Installing the compatible library for RAK12027 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 RAK12027 example code- 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. 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 modeand 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.
Figure 1: RAK12027 Earthquake Sensor serial readings