Arduino Earthquake Detector Alarm Circuit Using Accelerometer
Arduino Earthquake Detector Alarm Circuit Using Accelerometer
Saddam (/users/saddam)
S
Author
We are here building this Earthquake detector as a Arduino Shield on PCB and will
also show the Vibrations Graph on computer using Processing
(https://processing.org/).
1 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Accelerometer:
2 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
3 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Working Explanation:
4 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
5 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Demonstration Video and Arduino Code are given at the end of the article.
Circuit Explanation:
Circuit for this Earthquake detector Arduino Shield PCB is also simple. In this
project, we have used Arduino that reads accelerometer’s analog voltage and convert
them into the digital values. Arduino also drives the buzzer, LED, 16x2 LCD
(https://circuitdigest.com/article/16x2-lcd-display-module-pinout-datasheet) and
calculate and compare values and take appropriate action. Next part is Accelerometer
which detects vibration of earth and generates analog 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.
6 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
(/fullimage?i=circuitdiagram_mic/Earthquake-indicator-arduino-shield-using-
accelerometer-circuit-diagram.gif)
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
(https://processing.org/) 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.
7 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
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.
Then Arduino compares those calibrated (subtracted) values with prede�ned limits.
And take action accordingly. If the values are higher than prede�ned values then it will
beep the buzzer and plot the vibration graph on computer using Processing.
8 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Processing code:
Below is the Processing Code attached, you can download the code from below link:
We have designed a graph using Processing, for earth quake vibrations, in which we
de�ned the size of the window, units, font size, background, reading and displaying
serial ports, open selected serial port etc.
In below function, we have received data from serial port and extract required data
and then mapped it with the size of the graph.
9 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
After this, we have plotted unit space, max and min limits, values of x, y and z-axis.
fill(100);
strokeWeight(100);
line(1050,80,1200,80);
.... ....
..........
After this we plot the values over the graph by using 3 different colors as Blue for
x-axis value, green color for y axis and z is represented by red color.
10 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
stroke(0,0,255);
if(y1 == 0)
y1=height-inByte1-shift;
line(x, y1, x+2, height-inByte1-shift) ;
y1=height-inByte1-shift;
stroke(0,255,0);
if(y2 == 0)
y2=height-inByte2-shift;
line(x, y2, x+2, height-inByte2-shift) ;
y2=height-inByte2-shift;
stroke(255,0,0);
if(y2 == 0)
y3=height-inByte3-shift;
line(x, y3, x+2, height-inByte3-shift) ;
y3=height-inByte3-shift;
Also learn more about processing by going through our other Processing projects
(https://circuitdigest.com/tags/processing).
While designing your circuits and PCBs, you can also make your circuit and PCB
designs public so that other users can copy or edit them and can take bene�t from
there, we have also made our whole Circuit and PCB layouts public for
this Earthquake Indicator Shield for Arduino UNO, check the below link:
https://easyeda.com/circuitdigest/EarthQuake_Detector-
380c29e583b14de8b407d06ab0bbf70f (https://easyeda.com/circuitdigest
/EarthQuake_Detector-380c29e583b14de8b407d06ab0bbf70f)
Below is the Snapshot of Top layer of PCB layout from EasyEDA, you can view any
Layer (Top, Bottom, Topsilk, bottomsilk etc) of the PCB by selecting the layer form the
11 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
‘Layers’ Window.
12 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
13 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
order 10 pcs 2-layer PCB with 10cm x 10cm size just for $2.
14 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Below are the pictures of �nal Shield after soldering the components on PCB:
Code
15 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
/*variables*/
int xsample=0;
int ysample=0;
int zsample=0;
long start;
int buz=0;
/*Macros*/
#define samples 50
void setup()
delay(1000);
lcd.print("EarthQuake ");
lcd.setCursor(0,1);
lcd.print("Detector ");
Vi deo
Tags
16 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
H a v e a ny q u e s t i o n r e a l a t e d t o t h i s A r t i c l e ?
(Https://Chat.Whatsapp.Com/JR4e0Fc0V20H6jTMDd1daT)
TELEGRAM DISCORD
(Https://T.Me/Circuitdigest) (Https://Discord.Com/Invite/UXJrFJSWpz)
FORUM
(Https://Circuitdigest.Com/Forums)
Comments
Submitted by MATHANA VENKATESH on Sat, 09/09/2017 - 10:57
Permalink (/comment/17888#comment-17888)
Permalink (/comment/20708#comment-20708)
17 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
Permalink (/comment/24298#comment-24298)
Permalink (/comment/25411#comment-25411)
Permalink (/comment/25476#comment-25476)
Permalink (/comment/28188#comment-28188)
J8 (/comment/28188#comment-28188)
Is it necessary to put those header pins there? Can i avoid that?
Permalink (/comment/27203#comment-27203)
Programming (/comment/27203#comment-27203)
How sensitive is this? And is the programming codes working as is it? Thank you for the
18 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
reply!
Permalink (/comment/28694#comment-28694)
good (/comment/28694#comment-28694)
amazing...........................................:)
Permalink (/comment/33643#comment-33643)
Could someone help me with this? Why am I getting this error and how do I resolve it
and simulate the circuit?
Thank you!
Permalink (/comment/33646#comment-33646)
19 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
What is J5?
Permalink (/comment/36258#comment-36258)
Log in (/user/login?destination=/microcontroller-projects/arduino-earthquake-
detector-alarm-circuit%23comment-form) or register (/user/register?destination=
/microcontroller-projects/arduino-earthquake-detector-alarm-circuit%23comment-
form) to post comments
(https://bit.ly/48v2Jrq
)
(https://bit.ly/3IXzC60
)
20 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
(https://bit.ly/3UUJjcl )
(https://bit.ly/4bNoPIx
)
(https://bit.ly/3VUjEkP
)
(https://bit.ly/3PJS99t
)
(https://bit.ly/3IbP7qe
)
21 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
(https://bit.ly/3IU6r3o
)
22 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
(https://www.facebook.com/circuitdigest/) (https://twitter.com
/CircuitDigest) (https://www.youtube.com/channel
/UCy3CUAIYgZdAOG9k3IPdLmw) (https://www.linkedin.com/company
/circuit-digest/)
COMPANY
Advertise (/advertise)
23 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
P RO J E C T
(/microcontroller-projects)
OUR NETWORK
(https://circuitdigest.com)
(https://components101.com)
24 of 25 28/04/2024, 17:53
Arduino Earthquake Detector Alarm Circuit using Accelerometer https://circuitdigest.com/microcontroller-projects/arduino-earthquake-...
(https://iotdesignpro.com)
25 of 25 28/04/2024, 17:53