Ercan Sain
Published © CC BY-NC

Earthquake Moment

Our project makes environmental measurements at the time of an earthquake. Our project measures when it detects seismic waves.

IntermediateWork in progress2 hours36
Earthquake Moment

Things used in this project

Hardware components

RAKwireless RAK19007
×1
RAKwireless RAK4631
×1
RAKwireless RAK12027
×1
RAKwireless RAK1906
×1
RAKwireless RAK12033
×1

Software apps and online services

Arduino IDE
Arduino IDE
The Things Stack
The Things Industries The Things Stack
Fusion
Autodesk Fusion

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Solder Paste, Silver Bearing
Solder Paste, Silver Bearing
Pulley
3D Printer (generic)
3D Printer (generic)

Story

Read more

Code

Untitled file

Arduino
/**
**/
@file RAK12033_6_Axis_BasicReadings_IIM_42652.ino
@author rakwireless.com
@brief Get IIM-42652 sensor data and output data on the serial port.
@version 0.1
@date 2021-12-28
@copyright Copyright (c) 2021
#include "RAK12033-IIM42652.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h> // Click to install library:
http://librarymanager/All#Adafruit_BME680
#include "RAK12027_D7S.h" // Click here to get the library:
http://librarymanager/RAK12027_D7S
///////////////////////////////////////////////////////////Deprem
RAK_D7S D7S;
///////////////////////////////////////////////////////////Deprem
7
//////////////////////////////////////////////////////////Çevre Sensörü
Adafruit_BME680 bme;
// Might need adjustments
#define SEALEVELPRESSURE_HPA (1010.0)
void bme680_init()
{
Wire.begin();
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME680 sensor, check wiring!");
return;
}
// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
}
void bme680_get()
{
Serial.print("Temperature = ");
8
Serial.print(bme.temperature);
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.pressure / 100.0);
Serial.println(" hPa");
Serial.print("Humidity = ");
Serial.print(bme.humidity);
Serial.println(" %");
Serial.print("Gas = ");
Serial.print(bme.gas_resistance / 1000.0);
Serial.println(" KOhms");
Serial.println();
}
///////////////////////////Çevre
////////////////////////////İvme
IIM42652 IMU;
////////////////////////////İvme
void setup()
{
//////////////////////////////////////////////////////////Deprem
pinMode(WB_IO2, OUTPUT);
9
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("CELEBI Seismograph.");
Wire.begin();
while (!D7S.begin())
{
Serial.print(".");
}
Serial.println("STARTED");
10
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.
//////////////////////////////////////////////////////////Deprem
///////////////////////////////////////////////////////////Çevre
// Initialize the built in LED
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
// Initialize Serial for debug output
11
Serial.begin(115200);
time_t serial_timeout = millis();
// On nRF52840 the USB serial is not available immediately
while (!Serial)
{
if ((millis() - serial_timeout) < 5000)
{
delay(100);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
else
{
break;
}
}
bme680_init();
////////////////////////////////////////////////Çevre
////////////////////////////////////////////////İvme
time_t timeoutt = millis();
// Initialize Serial for debug output.
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeoutt) < 5000)
12
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK12033 Basic Reading example.");
Wire.begin();
if (IMU.begin() == false)
{
while (1)
{
Serial.println("IIM-42652 is not connected.");
delay(5000);
}
}
////////////////////////////////////////////////////İvme
}
void loop()
{
//////////////////////////////////////////////////////////Deprem
13
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.
//////////////////////////////////////////////////////////Deprem
///////////////////////////////////////////////Çevre
if (! bme.performReading())
{
Serial.println("Failed to perform reading :(");
}
bme680_get();
delay(5000);
////////////////////////////////////////////////Çevre
/////////////////////////////////////////////////İvme
IIM42652_axis_t accel_data;
IIM42652_axis_t gyro_data;
float temp;
14
float acc_x ,acc_y ,acc_z;
float gyro_x,gyro_y,gyro_z;
IMU.ex_idle();
IMU.accelerometer_enable();
IMU.gyroscope_enable();
IMU.temperature_enable();
delay(100);
IMU.get_accel_data(&accel_data );
IMU.get_gyro_data(&gyro_data );
IMU.get_temperature(&temp );
/*
* ±16 g : 2048 LSB/g
* ±8 g : 4096 LSB/g
* ±4 g : 8192 LSB/g
* ±2 g : 16384 LSB/g
*/
acc_x = (float)accel_data.x / 2048;
acc_y = (float)accel_data.y / 2048;
acc_z = (float)accel_data.z / 2048;
Serial.print("Accel X: ");
15
Serial.print(acc_x);
Serial.print("[g] Y: ");
Serial.print(acc_y);
Serial.print("[g] Z: ");
Serial.print(acc_z);
Serial.println("[g]");
/*
* ±2000 º/s : 16.4 LSB/(º/s)
* ±1000 º/s : 32.8 LSB/(º/s)
* ±500 º/s : 65.5 LSB/(º/s)
* ±250 º/s : 131 LSB/(º/s)
* ±125 º/s : 262 LSB/(º/s)
* ±62.5 º/s : 524.3 LSB/(º/s)
* ±31.25 º/s : 1048.6 LSB/(º/s)
* ±15.625 º/s : 2097.2 LSB/(º/s)
*/
gyro_x = (float)gyro_data.x / 16.4;
gyro_y = (float)gyro_data.y / 16.4;
gyro_z = (float)gyro_data.z / 16.4;
Serial.print("Gyro X:");
Serial.print(gyro_x);
Serial.print("º/s Y: ");
Serial.print(gyro_y);
Serial.print("º/s Z: ");
16
Serial.print(gyro_z);
Serial.println("º/s");
Serial.print("Temper : ");
Serial.print(temp);
Serial.println("[ºC]");
IMU.accelerometer_disable();
IMU.gyroscope_disable();
IMU.temperature_disable();
IMU.idle();
delay(2000);
/////////////////////////////////////////////////İvme
}

Credits

Ercan Sain
1 project • 0 followers
Information Technology Teacher

Comments