Group Members
Group Members
Group Members
P.PRABHAS
RITESH KUMAR
LOKESH
CHANDU
Arduino Earthquake Detector Alarm
with Seismic Graph using Accelerometer
s
SHARE
Introduction:
In this project, we will learn how to design Arduino Earthquake Detector Alarm with
Seismic Graph. We have used ADXL335 3 axis Accelerometer as a sensor for
detecting tilting, trembling, or any shaking movement of an earthquake. We have an
interfaced ADXL335 Accelerometer with Arduino and LCD display for designing
Arduino Earthquake Detector Alarm with Seismic Graph.
To learn detail about Accelerometer Working and Tutorial you can visit:
1. Accelerometer Basics and Tutorial Explanation
2. Acceleration Measurement with Accelerometer ADXL335 & Arduino
The Arduino code, as well as processing IDE code both, are given below. The
processing IDE code helps in drawing the graph of the tilting state. The buzzer or
LED is used as an alarm whenever the shaking threshold goes higher.
Features:
1. 3V-6V DC Supply Voltage
2. Onboard LDO Voltage regulator
3. It can be interface with 3V3 or 5V Microcontroller.
4. All necessary Components are populated.
5. Ultra-Low Power: 40uA in measurement mode, 0.1uA in standby@ 2.5V
6. Tap/Double Tap Detection
7. Free-Fall Detection
8. Analog output
Due to the special self-generating property, the crystal produces a voltage that is
proportional to the accelerative force. The working and the basic arrangement is
shown in the figure below.
First, upload the Arduino Code/program to the Arduino UNO board. After that open
processing IDE. Copy the code from below and paste it on IDE. Then the next step is
hit on the run. As soon as you hit run the graph starts running. So shake the
accelerometer and observe the graph.
Arduino Source Code/Program:
1#include<LiquidCrystal.h> // lcd Header
2LiquidCrystal lcd(7,6,5,4,3,2); // pins for LCD Connection
3
4#define buzzer 12 // buzzer pin
5#define led 13 //led pin
6
7#define x A0 // x_out pin of Accelerometer
8#define y A1 // y_out pin of Accelerometer
9#define z A2 // z_out pin of Accelerometer
10
11/*variables*/
12int xsample=0;
13int ysample=0;
14int zsample=0;
15long start;
16int buz=0;
17
18/*Macros*/
19#define samples 50
20#define maxVal 20 // max change limit
21#define minVal -20 // min change limit
22#define buzTime 5000 // buzzer on time
23
24void setup()
25{
26lcd.begin(16,2); //initializing lcd
27Serial.begin(9600); // initializing serial
28delay(1000);
29lcd.print("EarthQuake ");
30lcd.setCursor(0,1);
31lcd.print("Detector ");
32delay(2000);
33lcd.clear();
34lcd.print("Calibrating.....");
35lcd.setCursor(0,1);
36lcd.print("Please wait...");
37pinMode(buzzer, OUTPUT);
38pinMode(led, OUTPUT);
39buz=0;
40digitalWrite(buzzer, buz);
41digitalWrite(led, buz);
42for(int i=0;i<samples;i++) // taking samples for calibration
43{
44xsample+=analogRead(x);
45ysample+=analogRead(y);
46zsample+=analogRead(z);
47}
48
49xsample/=samples; // taking avg for x
50ysample/=samples; // taking avg for y
51zsample/=samples; // taking avg for z
52
53delay(3000);
54lcd.clear();
55lcd.print("Calibrated");
56delay(1000);
57lcd.clear();
58lcd.print("Device Ready");
59delay(1000);
60lcd.clear();
61lcd.print(" X Y Z ");
62}
63
64void loop()
65{
66int value1=analogRead(x); // reading x out
67int value2=analogRead(y); //reading y out
68int value3=analogRead(z); //reading z out
69
70int xValue=xsample-value1; // finding change in x
71int yValue=ysample-value2; // finding change in y
72int zValue=zsample-value3; // finding change in z
73
74/*displying change in x,y and z axis values over lcd*/
75lcd.setCursor(0,1);
76lcd.print(xValue);
77lcd.setCursor(6,1);
78lcd.print(yValue);
79lcd.setCursor(12,1);
80lcd.print(zValue);
81delay(100);
82
83/* comparing change with predefined limits*/
84if(xValue < minVal || xValue > maxVal || yValue < minVal || yValue > maxVal || zValue < minVal ||
85zValue > maxVal)
86{
87if(buz == 0)
88start=millis(); // timer start
89buz=1; // buzzer / led flag activated
90}
91
92else if(buz == 1) // buzzer flag activated then alerting earthquake
93{
94lcd.setCursor(0,0);
95lcd.print("Earthquake Alert ");
96if(millis()>= start+buzTime)
97buz=0;
98}
99
100else
101{
102lcd.clear();
103lcd.print(" X Y Z ");
104}
105
106digitalWrite(buzzer, buz); // buzzer on and off command
107digitalWrite(led, buz); // led on and off command
108
109/*sending values to processing for plot over the graph*/
110Serial.print("x=");
111Serial.println(xValue);
112Serial.print("y=");
113Serial.println(yValue);
114Serial.print("z=");
115Serial.println(zValue);
116Serial.println(" $");
}