Earthquake Alarm System

  • admin
  • admin's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
1 month 1 week ago - 1 month 1 week ago #78 by admin
Earthquake Alarm System was created by admin
Earthquake Alarm System

Specifications
  1. Microcontroller ATmega328
  2. 3-AXIS Digital Accelerometer ADXL335
  3. Lipo Battery with Charging Board Module
  4. 433MHz Wireless Remote Control Transmitter
  5. Compact Power Module - voltage input (AC: 90 ~ 264V)

the system is based on the ADXL335 accelerometer that has a detection range of ±3 g. It can measure the static acceleration due to gravity , as well as dynamic acceleration resulting from motion, shock, or vibration.

A metal ring mounted on the sensor ADXL335 contains perimeter loose steel spheres and magnifies the weak vibrations of the building creating a more intense shock to the sensor

the appliance must be plugged in in standby mode in a room outlet the LED will be green (standby mode) Ability to enable / disable device with Power switch

the vibration of the building will turn on the device and it will sound alarm the LED will turn red

will also activate wireless receivers alarms in other rooms at frequency 433Mhz when the building stops vibrating the audible alarm will stop the LED will turn yellow and the device will return to standby mode

the LED will remain yellow (as a memory) reminding that there has been a vibration

if we want to restore the entire system to its original state we ,press the reset button






#include <EEPROM.h>
#include "EEPROMAnything.h"
#include <LiquidCrystal.h>

const int alarmPin = 5;
const int ledyelow = 10;
int Xacc, Yacc, Zacc, threshold = 0, thresholdSET = 6;
long debouncing_time = 15; 
volatile unsigned long last_micros;
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);
struct sensorValue

{
 int X;
 int Y;
 int Z;
};

sensorValue acceleration;

void debounceInterrupt_Increment()

{
  if ((long)(micros() - last_micros) >= debouncing_time * 1000) {
      IncrementThreshold();
      last_micros = micros();
  }
}

void debounceInterrupt_Decrement()
{
  if ((long)(micros() - last_micros) >= debouncing_time * 1000) {
    DecrementThreshold();
    last_micros = micros();
  }
}

void IncrementThreshold() {
  thresholdSET = EEPROM.read(500);
  thresholdSET++;
  EEPROM.write(500, thresholdSET);
}

void DecrementThreshold() {
  thresholdSET = EEPROM.read(500);
  thresholdSET--;
  EEPROM.write(500, thresholdSET);
}

void setup() {
  lcd.begin(8, 2);
  attachInterrupt(0, debounceInterrupt_Increment, RISING);
  attachInterrupt(1, debounceInterrupt_Decrement, RISING);
  pinMode(alarmPin, OUTPUT);
  pinMode(ledyelow, OUTPUT);
  digitalWrite(ledyelow, LOW);
  EEPROM.write(500, thresholdSET);
  digitalWrite(alarmPin, LOW);
  lcd.setCursor(0, 0);
  lcd.print("  START ");
  lcd.setCursor(0,1);
  lcd.print("  SETUP ");
  delay(2000);
  sensorValue acceleration = { analogRead(A0) , analogRead(A1) , analogRead(A2) };
  EEPROM_writeAnything(0, acceleration);
  EEPROM_readAnything(0, acceleration);
  lcd.clear();
}

void loop() {
  EEPROM_readAnything(0, acceleration);
  threshold = EEPROM.read(500);
  lcd.setCursor(0, 0);
  lcd.print("READINESS");
  lcd.setCursor(0,1);
  lcd.print("LEVEL ");
  lcd.print(threshold);
  Xacc = analogRead(A0);
  Yacc = analogRead(A1);
  Zacc = analogRead(A2);

  if ((Xacc >= (acceleration.X + threshold)) || (Xacc <= (acceleration.X - threshold))||(Yacc >= (acceleration.Y + threshold)) || (Yacc <= (acceleration.Y - threshold))||(Zacc >= (acceleration.Z + threshold)) || (Zacc <= (acceleration.Z - threshold))) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" SEISMIC ");
    lcd.setCursor(0,1);
    lcd.print(" ACTIVITY ");
    digitalWrite(ledyelow, LOW);
    digitalWrite(alarmPin, HIGH);
    delay(500);
    digitalWrite(alarmPin, LOW);
    delay(500);
    digitalWrite(alarmPin, HIGH);
    delay(500);
    digitalWrite(alarmPin, LOW);
    delay(500);
    digitalWrite(alarmPin, HIGH);
    delay(500);
    digitalWrite(ledyelow, HIGH);
    digitalWrite(alarmPin, LOW);
    delay(500);
    lcd.clear();
  }

}
#include <EEPROM.h>
#include <Arduino.h>  // for type definitions
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value)

{
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          *p++ = EEPROM.read(ee++);
    return i;

}

Source: Earthquake Alarm System
Attachments:
Last edit: 1 month 1 week ago by admin.

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum