Landslide Introduction
Landslides or often called soil movements are a geological event that occurs due to the movement of masses of rocks or soil with various types and types such as falling rocks or large lumps of soil. In general, landslides are caused by two factors, namely driving factors and triggering factors. Driving factors are factors that affect the condition of the material itself, while trigger factors are factors that cause the movement of the material.
We propose a landslide detector prototype that measures the vital parameters of landslides at the same time using an accelerometer and gyroscope sensor. The sensor detection results will be received by the transmitter and transmitted wirelessly to the receiver unit which will then be displayed on a digital information board in the form of a warning system in landslide-prone areas. Thus, this information can be accessed easily by the public. The prototype is expected to be a tool for early mitigation of landslides that are precise, accurate, and can reduce the risk of casualties. In addition, the expected outcome of this research is the publication of scientific articles as initial information in the development of landslide disaster mitigation studies.
Landslide Early Warning System Based on Internet of Things and Machine Learning
Using LSM6DS3 accelerometer and gyroscope module sensor embedded with The Nano 33 will be used to collect the raw data. Then, the data will be analyzed by edge impulse studio. Arduino Nano 33 IoT is advanced Arduino dev kit designed for IoT implementation. It has a network module such as WiFi and BLE, allowing us to send the data to Arduino cloud over MQTT and HTTP by using internet connectivity.
This project is to aim to how we could integrate LSM6DS3 (accelerometer and gyroscope) module sensor embedded on Arduino nano 33 IoT, so this dev kit is very easy to do an experiment. We will implement it to connect with the cloud. so then data sent to cloud, accelerometer, and gyroscope data will be visualized on the thingsboard dashboard https://thingsboard.io.
We will do deployment this project which nano 33 IoT is used to collect accelerometer data (x, y, z) by LSM6DS3 IMU sensor module embedded on dev kit. MQTT is the standard messaging protocol for Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. MQTT today is used in a wide variety of industries, such as automotive, manufacturing, telecommunications, oil and gas, etc. https://mqtt.org/
Connecting to MQTT https://mosquitto.org/ broker (mosquitto) deploying on raspberry pi 4, nano 33 IoT is a node sensor. We use https://github.com/knolleary/pubsubclient library for MQTT client.
#include <SPI.h>
#include <Wire.h>
#include <Arduino_LSM6DS3.h>
#include <ArduinoJson.h>
#include <PubSubClient.h>
#include <WiFiNINA.h>
#define CONVERT_G_TO_MS2 9.80665f
#define FREQUENCY_HZ 104
#define INTERVAL_MS (1000 / (FREQUENCY_HZ + 1))
struct Acc_senseData{
float acc_x = 0.0F;
float acc_y = 0.0F;
float acc_z = 0.0F;
};
struct Gyr_senseData
{
float gyr_x = 0.0F;
float gyr_y = 0.0F;
float gyr_z = 0.0F;
};
void setup_wifi();
void reconnect();
static char payload[256];
static Acc_senseData acc_data;
static Gyr_senseData gyr_data;
StaticJsonDocument<256> doc;
#define TOKEN ""
#define DEVICEID ""
const char* ssid = "";
const char* password = "";
const char mqtt_server[] = "demo.thingsboard.io";
const char publishTopic[] = "v1/devices/me/telemetry";
WiFiClient wifiClient;
PubSubClient mqtt(wifiClient);
void setup_wifi(){
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while( WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print(".");
}
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect(){
while(!mqtt.connected()){
//Serial.print("Attempting MQTT connection ....");
//String clientID = "nano33_accelerometer-";
//clientID += String(random(0xffff), HEX);
if (mqtt.connect(DEVICEID, TOKEN, NULL)) {
Serial.println("Connected to MQTT broker");
digitalWrite(LED_BUILTIN, HIGH);
}
else
{
Serial.print("failed to connect to MQTT broker, rc=");
Serial.print(mqtt.state());
Serial.println("try again in 5 second");
digitalWrite(LED_BUILTIN, LOW);
delay(5000);
}
}
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
while (!Serial);
if (!IMU.begin())
{
Serial.println("Failed to initialize IMU!");
while(1);
}
setup_wifi();
mqtt.setServer(mqtt_server, 1883);
}
void loop() {
if (!mqtt.connected())
{
reconnect();
}
mqtt.loop();
static unsigned long last_interval_ms = 0;
float a_x, a_y, a_z;
float g_x, g_y, g_z;
if (millis() > last_interval_ms + INTERVAL_MS)
{
last_interval_ms = millis();
IMU.readAcceleration(a_x, a_y, a_z);
acc_data.acc_x = a_x;
acc_data.acc_y = a_y;
acc_data.acc_z = a_z;
doc["ACC_X"] = acc_data.acc_x * CONVERT_G_TO_MS2;
doc["ACC_Y"] = acc_data.acc_y * CONVERT_G_TO_MS2;
doc["ACC_Z"] = acc_data.acc_z * CONVERT_G_TO_MS2;
IMU.readGyroscope(g_x, g_y, g_z);
gyr_data.gyr_x = g_x;
gyr_data.gyr_y = g_y;
gyr_data.gyr_z = g_z;
doc["GYR_X"] = gyr_data.gyr_x;
doc["GYR_Y"] = gyr_data.gyr_y;
doc["GYR_Z"] = gyr_data.gyr_z;
serializeJsonPretty(doc, payload);
mqtt.publish(publishTopic, payload);
Serial.println(payload);
}
}
Finally, we can train all of the data collected using edge impulse studio which Edge Impulse is the leading development platform for machine learning on edge devices, free for developers and trusted by enterprises. https://www.edgeimpulse.com/.
The data forwarder is used to easily relay data from any device to Edge Impulse over serial. Devices write sensor values over a serial connection, and the data forwarder collects the data, signs the data, and sends the data to the ingestion service. The data forwarder is useful to quickly enable data collection from a wide variety of development boards without having to port the full remote management protocol and serial protocol, but only supports collecting data at relatively low frequencies (https://docs.edgeimpulse.com/docs/cli-data-forwarder).
To use the data forwarder, load an application (examples for Arduino, Mbed OS, and Zephyr below) on your development board, and run:
$ edge-impulse-data-forwarder
#include <SPI.h>
#include <Wire.h>
#include <Arduino_LSM6DS3.h>
#define CONVERT_G_TO_MS2 9.80665F
#define FREQUENCY_HZ 104
#define INTERVAL_MS (1000 / (FREQUENCY_HZ + 1))
struct Acc_senseData
{
float acc_x = 0.0F;
float acc_y = 0.0F;
float acc_z = 0.0F;
};
static Acc_senseData acc_data;
void setup() {
Serial.println(9600);
Serial.println("Started");
if (!IMU.begin())
{
Serial.println("Failed to initialize IMU!");
while(1);
}
}
void loop() {
static unsigned long last_interval_ms = 0;
float a_x, a_y, a_z;
if (millis() > last_interval_ms + INTERVAL_MS)
{
IMU.readAcceleration(a_x, a_y, a_z);
acc_data.acc_x = a_x;
acc_data.acc_y = a_y;
acc_data.acc_z = a_z;
Serial.print(acc_data.acc_x * CONVERT_G_TO_MS2);
Serial.print('\t');
Serial.print(acc_data.acc_y * CONVERT_G_TO_MS2);
Serial.print('\t');
Serial.println(acc_data.acc_z * CONVERT_G_TO_MS2);
}
}
All source code: https://github.com/radhyahmad/Arduino-Nano-33-IoT
This project is aimed to use IoT standard protocol MQTT and edge impulse to build a machine learning model, with an Arduino Nano 33 IoT to collect data related to landslide movement patterns (vertical, horizontal, idle, and fault). It has been made by programming with Arduino IDE, MQTT Pubsubclient, and WiFiNINA library to connect to the MQTT broker. We could send the data to the ThingsBoard cloud in real-time, which is able to visualize raw data of sensors.
A network sensor system consists of MCU (Arduino 33 IoT) Dev Kit as data acquisition that collects and processes raw data of sensors, and embedded WiFi module as internet connectivity, and an integrated LSM6DS3 which is an accelerometer and gyroscope sensor. The implementation has been connected to a local MQTT broker on raspberry board as IoT gateway, and Thingsboard cloud. Also, it has been used to train data on edge impulse studio to build a machine learning model to classify the patterns of landslides.