EARTHQUAKE ALARM ADXL355

Earthquake detection is very important for our safety. At this time we will demonstrate how to use the ADXL-335 sensor as an earthquake detector. In principle, this device is a detection of movement / acceleration. When there is a shock that exceeds the limit that we set, Arduino will send a radio signal to the receiver, where the receiver will activate the alarm. The advantage of using a radio signal is that the vibration from the alarm will not interfere with the ADXL-335 sensor, another advantage is that the number of receiver can  more than one.

similar thing you can see on https://arduinoproyek.wordpress.com/earthquake-alarm-mpu6050/

or without radio transmission see https://arduinoproyek.wordpress.com/2018/10/14/alarm-gempa-bumi-earthquake-alarm/

The code can be downloaded at:

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/EARTHQUAKE%20ALARM.zip

Transmitter sensor

gempa adxl355 trans

const int groundpin = 18; // analog input pin 4 — ground

const int powerpin = 19; // analog input pin 5 — voltage

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)

float cx=0;

float cy=0;

float cz=0;

float a;

float b;

float c;

float d;

float x;

float y;

float z;

#include <SPI.h>

#include “nRF24L01.h”

#include “RF24.h”

int DataMsg[1];

RF24 radio(8,7);

const uint64_t pipe = 0xE14BC8F482LL;

void setup()

{

//pinMode(13, OUTPUT);

// initialize the serial communications:

Serial.begin(9600);

//=======================radio

radio.begin();

radio.openWritingPipe(pipe);

//===================================

pinMode(groundpin, OUTPUT);

pinMode(powerpin, OUTPUT);

digitalWrite(groundpin, LOW);

digitalWrite(powerpin, HIGH);

delay(6000);

x=analogRead(xpin);

y=analogRead(ypin);

z=analogRead(zpin);

if ((x >= cx)||(x < cx)) {

cx = x;

}

if ((y >= cy)||(y < cy)) {

cy = y;

}

if ((z >= cz)||(z < cz)) {

cz = z;

}

delay(2000);

}

void loop()

{

a=analogRead(xpin)-cx;

b=analogRead(ypin)-cy;

c=analogRead(zpin)-cz;

d=sqrt(sq(a)+sq(b)+sq(c));

// print the sensor values:

if (d > 2.5){

DataMsg[0] = 1;

radio.write(DataMsg, 1);

//delay(2000);

}

else {

DataMsg[0] = 2;

radio.write(DataMsg, 1);

Serial.print(a);

// print a tab between values:

Serial.print(“\t”);

Serial.print(b);

// print a tab between values:

Serial.print(“\t”);

Serial.print(c);

Serial.print(“\t”);

Serial.print(d);

Serial.println();

}

}

Receiver Alarm

gempa adxl355 recv

#include <SPI.h>

#include “nRF24L01.h”

#include “RF24.h”

int DataMgs[1];

RF24 radio(8,7);

const uint64_t pipe = 0xE14BC8F482LL;

int Relay1 = 5;

void setup()

{

pinMode(Relay1, OUTPUT);

Serial.begin(9600);

radio.begin();

radio.openReadingPipe(1,pipe);

radio.startListening();

}

void loop()

{

if (radio.available())

{

bool done = false;

while (!done)

{

done = radio.read(DataMgs, 1);

Serial.print(“NRF24L01 Receiver: “);

Serial.println(DataMgs[0]);

if (DataMgs[0] == 1)

{

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(2000); //#1

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(2000); //#2

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(2000); //#3

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(2000); //#4

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(30);

digitalWrite(Relay1, HIGH);

delay(30);

digitalWrite(Relay1, LOW);

delay(2000); //#5

}

if (DataMgs[0] == 2)

{

digitalWrite(Relay1, LOW);

}

delay(100);

}

}

else

{

Serial.println(“Waiting for signal…”);

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s