Seismodesk: a DIY Simple and Effective Seismometer

by MarcoF40 in Circuits > Arduino

54 Views, 1 Favorites, 0 Comments

Seismodesk: a DIY Simple and Effective Seismometer

2025-02-13 09 28 26.jpg

The Lifeshell Seismodesk is a simple, Do It Yourself, affordable solution for addressing Earthquake Early Warning System. Made of a few commonly available electronic parts, the system is highly modular and can be expanded with ease, for example for personalizing the alert code (now just a red and a white LED) for visual impaired persons or other personalizations.

This Instructables is part of a project funded by the European Union – Next Generation EU.

Basically, the Lifeshell project is engineering furniture capable of providing shelter during an earthquake. The furniture are licensed under the Creative Commons 4.0 license: everybody can make, modify and even sell them!

https://www.ibe.cnr.it/lifeshell/

https://www.lifeshell.net/

Supplies

  1. Arduino NANO (or other Arduino)
  2. MPU6050 sensor (or other accelerometer, but you will have to change library)
  3. wires and perfboard or breadboard

at least one of the following output:

  1. LED and a few resistors
  2. buzzer/speaker
  3. vibration motor


The Bill of Material is:

  1. Arduino Nano (or clone, or other type), 3 to 20 €
  2. MPU6050 accelerometer, 2 to 4 €
  3. LED, 1 €
  4. Connection wires, resistors, 1 €

TOTAL: 7 to 26 €.

Hardware Connection

2025-02-13 09 19 43.jpg
2025-02-13 09 19 36.jpg

MPU6050 connections: 5V, GND, SCL on A4, SDA on A5 (SCL and SDA Pins for Arduino Nano, modify for your Arduino)

Green LED on PIN D9 to GND via a 120 (100-200) Ohm resistor

Yellow LED on PIN D10 to GND via a 120 (100-200) Ohm resistor

RED LED on PIN D11 to GND via a 220 (150-250) Ohm resistor

White LED on PIN D3 to GND via a 120 (100-200) Ohm resistor

Schematics can be found also here:

https://app.cirkitdesigner.com/project/3985b239-634e-4ed1-b15b-e672beb83c64

Code

Copy/paste the following or open the attached .ino file at the end of the step and upload it to Arduino.

/*Lifeshell Project, PI Marco Fellin
Jan 2025
Seismodesk, Seismic activity sensor and alert system
Earthquake Early Warning System
Basic example code, please do not trust 100% electronic devices including this piece of software when lives are at stake.

SCOPE:
Monitoring earth acceleration and alert users when an earthquake hits your house.

USE:
Power ON, a calibration and a self check runs automatically. All LED lit shortly.
If green LED is steady ON, system is running correctly.
Shall vibrations exceed certain threshold, yellow or red LED power on, roughly indicating the acceleration amount.
An alert sounds/vibrate/light, according to the output device(s) connected.

Serial print output can be deactivated.

Hardware: MPU6050 sensor and Arduino NANO (other accelerometers and Arduino can be used)
MPU6050 connections: 5V, GND, SCL on A4, SDA on A5 (SCL and SDA Pins for Arduino Nano, modify for your Arduino)
Green LED on PIN D9 to GND via a 120 (100-200) Ohm resistor
Yellow LED on PIN D10 to GND via a 120 (100-200) Ohm resistor
RED LED on PIN D11 to GND via a 220 (150-250) Ohm resistor
White LED on PIN D3 to GND via a 120 (100-200) Ohm resistor

*/
// Based on the Basic demo for accelerometer readings from Adafruit MPU6050
//https://learn.adafruit.com/mpu6050-6-dof-accelerometer-and-gyro/python-and-circuitpython
//https://forum.arduino.cc/t/how-to-export-data-from-arduino-serial-monitor-to-a-csv-or-txt-file/354651/5

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>


Adafruit_MPU6050 mpu;
int LEDwhite = 3; //led pin
int LEDgreen = 9; //led pin
int LEDyellow = 10; //led pin
int LEDred = 11; //led pin
unsigned long eventTime = 0; //variable for storing the time since the seism event was detected

void setup(void) {
Serial.begin(115200);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit MPU6050 test!");
pinMode(LEDgreen, OUTPUT); //define LED as output
pinMode(LEDyellow, OUTPUT);
pinMode(LEDred, OUTPUT);
pinMode(LEDwhite, OUTPUT);

//LED welcome and check display, on power up
digitalWrite(LEDgreen, HIGH);
delay(300);
digitalWrite(LEDyellow, HIGH);
delay(300);
digitalWrite(LEDred, HIGH);
delay(300);
digitalWrite(LEDwhite, HIGH);
delay(300);
digitalWrite(LEDwhite, LOW);
delay(300);
digitalWrite(LEDred, LOW);
delay(300);
digitalWrite(LEDyellow, LOW);

// Try to initialize!
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");

mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
Serial.print("Accelerometer range set to: ");
switch (mpu.getAccelerometerRange()) {
case MPU6050_RANGE_2_G:
Serial.println("+-2G");
break;
case MPU6050_RANGE_4_G:
Serial.println("+-4G");
break;
case MPU6050_RANGE_8_G:
Serial.println("+-8G");
break;
case MPU6050_RANGE_16_G:
Serial.println("+-16G");
break;
}
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
Serial.print("Gyro range set to: ");
switch (mpu.getGyroRange()) {
case MPU6050_RANGE_250_DEG:
Serial.println("+- 250 deg/s");
break;
case MPU6050_RANGE_500_DEG:
Serial.println("+- 500 deg/s");
break;
case MPU6050_RANGE_1000_DEG:
Serial.println("+- 1000 deg/s");
break;
case MPU6050_RANGE_2000_DEG:
Serial.println("+- 2000 deg/s");
break;
}


mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
Serial.print("Filter bandwidth set to: ");
switch (mpu.getFilterBandwidth()) {
case MPU6050_BAND_260_HZ:
Serial.println("260 Hz");
break;
case MPU6050_BAND_184_HZ:
Serial.println("184 Hz");
break;
case MPU6050_BAND_94_HZ:
Serial.println("94 Hz");
break;
case MPU6050_BAND_44_HZ:
Serial.println("44 Hz");
break;
case MPU6050_BAND_21_HZ:
Serial.println("21 Hz");
break;
case MPU6050_BAND_10_HZ:
Serial.println("10 Hz");
break;
case MPU6050_BAND_5_HZ:
Serial.println("5 Hz");
break;
}
Serial.println("");
delay(100);
}


void loop() {

/* Get new sensor events with the readings */
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
/* Print out the values */
Serial.print("ms ");
Serial.print(millis());
Serial.print(" eventTime ");
Serial.print(eventTime);
Serial.print(" Acc X: ");
Serial.print(a.acceleration.x);
Serial.print(", Y: ");
Serial.print(a.acceleration.y);
Serial.print(", Z: ");
Serial.print(a.acceleration.z);
Serial.println(" m/s^2");


//condition for detecting weak accelerations and signalling with the YELLOW LED. Change parameters according to your own sensor values, threshold should be around 0.5 m/s^2 + and - the calm readings
if (a.acceleration.x < -0.8 || a.acceleration.x > 0.5 || a.acceleration.y < -0.5 || a.acceleration.y > 0.5 || a.acceleration.z < 10 || a.acceleration.z > 11) {
digitalWrite(LEDyellow, HIGH);
//condition for detecting strong accelerations and signalling with the RED LED. Change parameters according to your own sensor values, threshold should be around 0.5 m/s^2 + and - the calm readings
if (a.acceleration.x < -1.8 || a.acceleration.x > 1.5 || a.acceleration.y < -1.5 || a.acceleration.y > 1.5 || a.acceleration.z < 9 || a.acceleration.z > 12) {
digitalWrite(LEDred, HIGH);
digitalWrite(LEDwhite, HIGH);
}
eventTime = millis(); //mark the time of the event
}

//function for powering off LED, when calm comes back, adjust the time as you wish
if (millis() - eventTime > 30000) {
digitalWrite(LEDred, LOW);
digitalWrite(LEDyellow, LOW);
digitalWrite(LEDwhite, LOW);
eventTime = 0;
}

}

Use It!

The device is intended to be used as an Earthquake Early warning system that should gift a few seconds to the users for finding a shelter during a seism. All the international guidelines suggest to crawl under a desk to find protection, and the Lifeshell desk (www.lifeshell.net) is an incredibly strong, affordable, open source desk.

Use of the sesimodesk

  1. Power on the device. When the device is powered on, it shall remain undisturbed (no movements) for a few seconds on startup, since the accelerometer calibrates itself.
  2. Live your life. On daily life, just keep an eye at the green LED that shall be ON when the device is running.
  3. In case of an earthquake. In that case the device other LEDs will turn ON (orange for medium and red for severe seisms), alerting the user to use the shelter under the desk. The white LED will stay ON for a while after the seism.

Seismodesk tuning

You may want to change the threshold for detecting seism. In the code, there are two IF functions that are checking if the XYZ accelerations are above a certain threshold. You may want to serial monitor (in the Arduino IDE) the XYZ values on a quite moment and change the threshold just above/below that reading.

E.g. if your serial monitor reads X accelerations around -0.4 to +0.1 g, you may want to set the lower threshold to about -0.8 and the upper threshold to +0.5 g, as in the following part of code (the IF controlling the yellow LED, to be repeated for the IF related to the RED led too).


if (a.acceleration.x < -0.8 || a.acceleration.x > 0.5 || a.acceleration.y < -0.5 || a.acceleration.y > 0.5 || a.acceleration.z < 10 || a.acceleration.z > 11) {

digitalWrite(LEDyellow, HIGH);


Feedback

Lifeshell is an open-source bottom up research project, we'll love to hear from you and ameliorate the project with your hints!

Feel free to use this form or reach us by email marco.fellin (at) cnr.it

License

image.jpg
EmbeddedImage.png

The whole Lifeshell project is licensed under the Creative Commons CC BY 4.0 licence allows to share (copy and redistribute) the material in any medium or format, adapt, remix, transform, and build upon the material, for any purpose, even commercially. You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

Credits

The current Lifeshell project development is funded by the European Union - Next Generation EU via piano nazionale di ripresa e resilienza (PNRR), missione 4 “istruzione e ricerca” - componente c2, investimento 1.1, “fondo per il programma nazionale di ricerca e progetti di rilevante interesse nazionale (prin)”. Project code 2022HBXLTR, CUP B53D23006020006.

Principal Investigator: Marco Fellin, CNR-IBE

Work group @ CNR IBE: Edoardo Giacobbo, Andrea Polastri, Jarno Bontadi, Ignazia Cuccui

Project partners:

Emanuele Sartori, Roberto Scotta, UNIPD - Università degli Studi di Padova

Gianluca Lopez, MUSE Museo delle Scienze di Trento