22 February 2016

Arduino based EarthQuake detector with coding DIY


Before going into this project i would like to tell you that this is just a school project . Ofcourse I did this during my third year of college and this project may help the Beginners who wants to learn Arduino.

Description
     Here i have used 3-axis Accelerometer Sensor interfaced with Arduino . whenever the Accelerometer is shaken or mover there will be a buzzer sound beeping and i call it a EarthQuake Detector

Components/Software required

1. Arduino UNO
2. Accelerometer Sensor (ADXL3xx)
3. BreadBoard
4. Jumper Wires (Female to male) -6
5. Buzzer / LED (For indication)
6. Arduino IDE Software - https://www.arduino.cc/en/Main/Software




Accelerometer Sensor (ADXL3xx)

Arduino Uno

                                                   
Connections

1. ST - A0
2. Z - A1
3. Y - A2
4. Z - A3
5. GND - A4
6. VDD - A5
7.Buzzer or LED on Digital PIN 12 and Digital Ground the -ve terminal of Buzzer/LED

You could use male to female jumper wires to connect accelerometer to Arduino Analog Pins


Coding :

1.First we have to find the values of accelerometer in its actual position then write actual code for the buzzer indications


TEST CODE :

Before Uploading the sketch make sure you have given the Hardware connection correctly and place Accelerometer in a narrow surface.

Here is the test code Copy paste in Arduino IDE


const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models)

void setup()
{
  // initialize the serial communications:
  Serial.begin(9600);

}

void loop()
{
  // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(500);
}



2.Now compile the code  .

3.Connect the Arduino to PC and Upload the code . If you get any error regarding ports  then go to
   Tools--> Ports and change the port . This will work .

4 . Open Serial monitor . Tools --> Serial Monitor . Now you will be seeing X,Y,Z values of Accelerometer in its surface position . When you move the Accelerometer the value will be changed

5. Note the optimu value . I got 300   280   300 . If you get a different value note it and change in the Following code

Now lets check the final code...


Final Code:

Note: If you get any other value than 300   280   300 , make change in code at xmin,ymin and                zmin


int buzzerop = 12;
int xpin = A3;                   // x-axis of the accelerometer
int ypin = A2;                   // y-axis
int zpin = A1;
long xmin=300;   //     If you get different value while running the TEST.ino code
long ymin=280;   //     Put that here
long zmin=300;   //      300    280    300 are the value taken from my TEST.ino output
long x=0;
long y=0;
long z=0;

void setup()
{
  Serial.begin(9600);

  pinMode(12,OUTPUT);

}

void loop()
{
   x = analogRead(xpin);
   y = analogRead(ypin);
   z = analogRead(zpin);

 
   if(y<ymin || x<xmin || z<zmin)               // the buzzer will be beeped only if they cross this condition
   {
     digitalWrite(12,HIGH);
     delay(500);
   }
   else
   {
     digitalWrite(12,LOW);
          delay(250);
   }
}





Thats all folks , whenever you shake or tilt the Accelerometer there will be a Buzzer sound.

If you want the Device to be more sensitive then alter the values of  X , Y , Z



If you cannot get the output contact me :-

lkkarthikeya@gmail.com




#DIY
#Arduino
#Project
#Earthquake
#detector
#Accelerometer



No comments:

Post a Comment