0% found this document useful (0 votes)
493 views

Earthquake Detector Alarm Using Arduino

This document describes an Arduino-based earthquake detector that uses an accelerometer to detect vibrations. It consists of the following: - An Arduino board, accelerometer, LCD display, buzzer, and other components to build the detector circuit. - The accelerometer senses vibrations along three axes and provides analog outputs to the Arduino. - The Arduino reads the accelerometer values, compares them to thresholds, and triggers an alert by activating the buzzer and LCD if thresholds are exceeded, indicating an earthquake. - Processing software graphs the real-time accelerometer readings to visualize vibrations. The Arduino sends axis data to Processing via serial communication.

Uploaded by

Mxolisi Mtn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
493 views

Earthquake Detector Alarm Using Arduino

This document describes an Arduino-based earthquake detector that uses an accelerometer to detect vibrations. It consists of the following: - An Arduino board, accelerometer, LCD display, buzzer, and other components to build the detector circuit. - The accelerometer senses vibrations along three axes and provides analog outputs to the Arduino. - The Arduino reads the accelerometer values, compares them to thresholds, and triggers an alert by activating the buzzer and LCD if thresholds are exceeded, indicating an earthquake. - Processing software graphs the real-time accelerometer readings to visualize vibrations. The Arduino sends axis data to Processing via serial communication.

Uploaded by

Mxolisi Mtn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Earthquake Detector Alarm using Arduino

Earthquake Detector Arduino Shield using


Accelerometer
An earthquake is an unpredictable natural disaster that causes damage to lives and property. It
happens suddenly and we cannot stop it but we can be alerted from it. In today’s time, there are
many technologies which can be used to detect the small shakes and knocks, so that we can take
precautions prior to some major vibrations in earth. Here we are using Accelerometer ADXL335 to
detect the pre-earthquake vibrations. Accelerometer ADXL335 is highly sensitive to shakes and
vibrations along with all the three axes. Here we are building an Arduino based Arduino based
Earthquake Detector using Earthquake Detector using Accelerometer. We are here building this
Earthquake detector as a Arduino Shield on PCB detector as a Arduino Shield on PCB and will also
show the Vibrations Graph on computer using Processing.

Components Required for Arduino


Earthquake Detector Shield
Arduino UNO
Accelerometer ADXL335
16x2 LCD
Buzzer BC547 transistor
1k Resistors
10K POT
LED
Power Supply 9v/12v
Berg sticks male/female

Accelerometer:
Pin Description of accelerometer:
1. Vcc 5 volt supply should connect at
this pin.
2. X-OUT This pin gives an Analog
output in x direction
3. Y-OUT This pin give an Analog Output
in y direction
4. Z-OUT This pin gives an Analog
Output in z direction
5. GND Ground
6. ST This pin used for set sensitivity
of sensor
Working Explanation:
Working of this Arduino Earthquake Detector is quite simple. As we mentioned earlier that we have
used Accelerometer for detecting earthquake vibrations along any of the three axes so that
whenever vibrations occur accelerometer senses that vibrations and convert them into equivalent
ADC value. Then these ADC values are read by Arduino and shown over the 16x2 LCD.
We have also shown these values on Graphs using Processing. First we need to calibrate the
Accelerometer by taking the samples of surrounding vibrations whenever Arduino
Powers up. Then we need to subtract those sample values from the actual readings to get the real
readings. This calibration is needed so that it will not show alerts with respect to its normal
surounding vibrations. After finding real readings, Arduino compares these values with predefined
max and min values. If Arduino finds any changes values are more then or less then the predefined
values of any axis in both direction (negative and positive) then Arduino trigger the buzzer and
shows the status of alert over the 16x2 LCD and a LED also turned on as well. We can adjust the
sensitivity of Earthquake detector by changing the Predefined values in Arduino code.
Circuit Explanation:
Circuit for this Earthquake detector Arduino Shield PCB is also simple. In this project, we have used
Arduino that reads accelerometer’s analogy voltage and convert them into the digital values.
Arduino also drives the buzzer, LED, 16x2 LCD and calculate and compare values and take
appropriate action. Next part is Accelerometer which detects vibration of earth and generates
analogy voltages in 3 axes (X, Y, and Z). LCD is used for showing X, Y and Z axis’s change in values and
also showing alert message over it. This LCD is attached to Arduino in 4-bit mode. RS,
GND, and EN pins are directly connected to 9, GND and 8 pins of Arduino and rest of 4 data pins of
LCD namely D4, D5, D6 and D7 are directly connected to digital pin 7, 6, 5 and 4 of Arduino. The
buzzer is connected to pin 12 of Arduino through an NPN BC547 transistor. A 10k pot is also used for
controlling the brightness of the LCD.
Program

Programming Explanation:
In this Arduino earthquake Detector Project, we have made two codes: one
For Arduino to detect an earthquake and another for Processing IDE to plot the earthquake
vibrations over the graph on Computer. We will learn about both the codes one by one:

Arduino code:
First of all, we calibrate the accelerometer with respect to its placing surface, so that it will not show
alerts with respect to its normal surrounding vibrations. In this calibration, we take some samples
and then take an average of them and stores in a variable.

for(int i=0;i<samples;i++) //
taking samples for calibration
{
xsample+=analogRead(x);
ysample+=analogRead(y);
zsample+=analogRead(z);
}
xsample/=samples; // taking avg f
or x
ysample/=samples; // taking avg f
or y
zsample/=samples; // taking avg f
or z
delay(3000);
lcd.clear();
lcd.print("Calibrated");
delay(1000);
lcd.clear();
lcd.print("Device Ready");
delay(1000);
lcd.clear();
lcd.print(" X Y Z ");

Now whenever Accelerometer takes readings, we will subtract those sample values from the
readings so that it can ignore surroundings vibrations

int value1=analogRead(x); // re
ading x out
int value2=analogRead(y); //rea
ding y out
int value3=analogRead(z); //rea
ding z out
int xValue=xsample-value1; //
finding change in x
int yValue=ysample-value2; //
finding change in y
int zValue=zsample-value3; //
finding change in z
/*displying change in x,y and z axi
s values over lcd*/
lcd.setCursor(0,1);
lcd.print(zValue);
lcd.setCursor(6,1);
lcd.print(yValue);
lcd.setCursor(12,1);
lcd.print(zValue);
delay(100)

Then Arduino compares those calibrated (subtracted) values with predefined limits.
And take action accordingly. If the values are higher than predefined values then it will beep the
buzzer and plot the vibration graph on computer using Processing.

/* comparing change with predef


ined limits*/
if(xValue < minVal || xValue > ma
xVal || yValue < minVal || yValue >
maxVal || zValue < minVal || zValue
> maxVal)
{
if(buz == 0)
start=millis(); // timer star
t
buz=1; // buzzer / led f
lag activated
}
else if(buz == 1) // buzzer
flag activated then alerting earthqu
ake
{
lcd.setCursor(0,0);
lcd.print("Earthquake Alert "
);
if(millis()>= start+buzTime)
buz=0;
}

Processing code:
We have designed a graph using Processing, for earth quake vibrations, in which we defined the size
of the window, units, font size, background, reading and displaying serial ports, open selected serial
port etc.

// set the window size: and Font si


ze
f6 = createFont("Arial",6,true);
f8 = createFont("Arial",8,true);
f10 = createFont("Arial",10,true);
f12 = createFont("Arial",12,true);
f24 = createFont("Arial",24,true);
size(1200, 700);
// List all the available serial por
ts
println(Serial.list());
myPort = new Serial(this, "COM43", 9
600);
println(myPort);
myPort.bufferUntil('\n');
background(80)

In below function, we have received data from serial port and extract required data
and then mapped it with the size of the graph.

// extracting all required values of


all three axis:
int l1=inString.indexOf("x=")+2;
String temp1=inString.substring(l1,l
1+3);
l1=inString.indexOf("y=")+2;
String temp2=inString.substring(l1,l
1+3);
l1=inString.indexOf("z=")+2;
String temp3=inString.substring(l1,l
1+3);
//mapping x, y and z value with grap
h dimensions
float inByte1 = float(temp1+(char)9)
;
inByte1 = map(inByte1, -80,80, 0, he
ight-80);
float inByte2 = float(temp2+(char)9)
;
inByte2 = map(inByte2,-80,80, 0, hei
ght-80);
float inByte3 = float(temp3+(char)9)
;
inByte3 = map(inByte3,-80,80, 0, hei
ght-80);
float x=map(xPos,0,1120,40,width-40);
After

After this, we have plotted unit space, max and min limits, values of x, y and z-axis.

//ploting graph window, unit


strokeWeight(2);
stroke(175);
Line(0,0,0,100);
textFont(f24);
fill(0,00,255);
textAlign(RIGHT);
xmargin("EarthQuake Graph By Circui
t Digest",200,100);
fill(100);
strokeWeight(100);
line(1050,80,1200,80);
.... ....
..........

After this we plot the values over the graph by using 3 different colours as Blue for x-axis value,
green colour for y axis and z is represented by red colour.

stroke(0,0,255);
if(y1 == 0)
y1=height-inByte1-shift;
line(x, y1, x+2, height-inByte1-sh
ift) ;
y1=height-inByte1-shift;
stroke(0,255,0);
if(y2 == 0)
y2=height-inByte2-shift;
line(x, y2, x+2, height-inByte2-sh
ift) ;
y2=height-inByte2-shift;
stroke(255,0,0);
if(y2 == 0)
y3=height-inByte3-shift;
line(x, y3, x+2, height-inByte3-sh
ift) ;
y3=height-inByte3-shift;

You might also like