Earthquake alarm using Arduino and ADXL335. a DIY Guide

In today’s world of smart safety devices, building an Earthquake Detector Alarm with an ADXL335 3-axis Accelerometer and Arduino Nano can be a rewarding DIY project. In this detailed guide, we will walk you through the entire process, from required components, wiring, working principle, Arduino sketch coding and real-world testing. Whether you’re a hobbyist, engineer, or educator, this Earthquake alarm using Arduino project provides hands-on experience with vibration sensing, microcontroller programming, and real-time monitoring.


Why Make an Earthquake Detector?

Earthquakes are sudden and unpredictable. A basic earthquake alarm system can detect abnormal ground vibrations early and issue a warning, giving people precious seconds to react. Using the highly sensitive ADXL335 accelerometer, combined with a buzzer, LED, and a 16×2 I2C LCD display, you can create a reliable, cost-effective solution at home.

This project uses popular, affordable components and requires only basic knowledge of Arduino programming.


Components Needed

For building this Earthquake Detector Alarm, you’ll need the following:

ComponentSpecification/Details
Arduino NanoMicrocontroller board (ATmega328P)
ADXL335 Accelerometer3-axis analog output accelerometer
16×2 I2C LCD DisplayFor live readings and status
Buzzer5V active buzzer
LEDAny color (indicator light)
Resistor330-ohm (for LED current limiting)
BreadboardFor prototyping the circuit
Jumper wiresFor connections
USB CableTo upload code to Arduino

🛒 To purchase the required parts, simply click on them.

 


How the ADXL335 earthquake detector Works

The ADXL335 accelerometer detects vibrations along the X, Y, and Z axes.

  • If the vibrations cross a certain threshold (indicating unusual seismic activity), the Arduino triggers a buzzer and LED alarm.

  • The 16×2 LCD display shows live acceleration readings and the system status (“Normal” or “Earthquake Detected”).

The threshold level can be adjusted based on sensitivity needs.

Earthquake Alarm Using Arduino. Diagram

Earthquake alarm using Arduino Circuit Diagram

Here’s a simple connection guide:

  • ADXL335 to Arduino Nano:

    • VCC → 3.3V

    • GND → GND

    • X → A0

    • Y → A1

    • Z → A2

  • LCD I2C Display to Arduino Nano:

    • VCC → 5V

    • GND → GND

    • SDA → A4

    • SCL → A5

  • Buzzer:

    • Positive → D8

    • Negative → GND

  • LED + Resistor:

    • LED anode (+) → One side of 330-ohm resistor

    • Other side of resistor → D7

    • LED cathode (−) → GND

Use a breadboard to prototype your connections neatly and avoid shorts.

Arduino Sketch Code for ADXL335 earthquake detector

This Arduino-based program implements an earthquake detection system using the ADXL335 3-axis accelerometer, a 16×2 I2C LCD module, an active buzzer, and an LED indicator. The code begins by calibrating the accelerometer to establish baseline axis readings under normal conditions. Following calibration, the Arduino continuously samples analog input values from the X, Y, and Z axes.

If the calculated deviation from the baseline exceeds a defined threshold, the system identifies a potential seismic event. Upon detection, the buzzer and LED are activated to signal an alert, while the LCD displays a warning message along with real-time accelerometer data. When vibration levels remain within safe limits, normal readings are presented on the LCD.

To deploy the ADXL335 earthquake detector system, upload the provided sketch directly into the Arduino IDE and flash it onto the microcontroller.

 

Here’s a simple and functional Arduino sketch you can use:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define Pins
const int buzzer = 8;
const int led = 7;
const int xPin = A0;
const int yPin = A1;
const int zPin = A2;

// Threshold values
const int threshold = 50; // Adjust based on testing

void setup() {
lcd.begin();
lcd.backlight();
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
int xVal = analogRead(xPin);
int yVal = analogRead(yPin);
int zVal = analogRead(zPin);

// Calculate vibration intensity
int vibration = abs(xVal – 512) + abs(yVal – 512) + abs(zVal – 512);

lcd.setCursor(0, 0);
lcd.print(“Vib:”);
lcd.print(vibration);
lcd.print(” “); // Clear extra chars

if (vibration > threshold) {
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);
lcd.setCursor(0, 1);
lcd.print(“Earthquake!”);
} else {
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
lcd.setCursor(0, 1);
lcd.print(“Status: Normal “);
}

delay(200); // Adjust refresh rate
}

You can start testing the Arduino Nano seismic sensor project. On the Serial Monitor, the following messages will be displayed.

Earthquake Alarm Using Arduino

 

Upon powering the system, an initialization sequence is executed, followed by the calibration process. After a brief period, calibration completes, and the Arduino Nano seismic sensor project outputs the baseline accelerometer values, which serve as reference points for subsequent magnitude calculations and comparative analysis.

Earthquake alarm using Arduino

Thereafter, the real-time accelerometer readings are continuously displayed. Under stable conditions, the X, Y, and Z-axis outputs converge near zero, indicating minimal or no motion. Conversely, when the sensor experiences external perturbations such as shaking or trembling, significant deviations in the X, Y, and Z readings are observed, reflecting dynamic changes in the sensor’s orientation or position.

Calibrating the Threshold

The “threshold” value is crucial:

  • Too low, and normal movement may trigger a false alarm.

  • Too high, and minor tremors may go undetected.

Testing Tip:
  1. Start with 50 as shown above.

  2. Shake the breadboard lightly and observe values via Serial Monitor or LCD.

  3. Adjust threshold value accordingly.

 

When the acceleration threshold is exceeded, the Serial Monitor outputs the log message: “Earthquake Detected.” Simultaneously, the LCD screen displays “Calibration Mode.” During this phase, the ADXL335 accelerometer must remain stationary to ensure accurate calibration. Upon successful calibration, the system enters a ready state, indicated by the LCD message “Device Ready.”

The LCD then begins streaming real-time acceleration data (X, Y, Z axes). To simulate seismic activity, apply controlled perturbations—tilting, shaking, or abrupt movements—to the accelerometer module. If the resultant acceleration exceeds the predefined threshold:

  1. The LED and buzzer trigger as active alerts.

  2. The LCD updates to “Earthquake !!!” while continuing to display the instantaneous X, Y, and Z values.
    Cross-validate the logged values on the Serial Monitor against the applied motion to verify system responsiveness and threshold accuracy.

ADXL335 earthquake detector

 


Real-World Testing Tips

  1. Place the sensor module firmly on a table.

  2. Simulate an earthquake by tapping the table.

  3. Watch the LCD display and check if the buzzer and LED trigger appropriately.

  4. Fine-tune the sensitivity based on local environmental noise.


Expanding the Low-cost earthquake alarm system

For advanced users, you can further expand this project by:

  • Adding a GSM module to send SMS alerts during a tremor.

  • Adding a data logger using an SD card module to record vibration data.

  • Using Wi-Fi (ESP32/ESP8266) to upload data to a cloud service for remote monitoring.


Pros and Cons of This Arduino Nano seismic sensor project

ProsCons
Simple and affordable designNot a substitute for industrial seismic sensors
Good educational tool for vibration detectionMay give false alarms without proper calibration
Expandable with wireless communication modulesSensitivity limited by sensor quality
Portable and battery-compatibleNeeds stable placement for accuracy

 

The embedded C++ firmware running on the Arduino microcontroller continuously samples analog acceleration data from the ADXL335 triple-axis accelerometer and outputs the processed values to an LCD display in real time. For enhanced data analysis, a complementary Python-based visualization tool is implemented. This script utilizes the Matplotlib library to generate time-domain plots of the acceleration waveforms, enabling quantitative assessment of tilt angles and vibration signatures.

The system incorporates a hardware alert mechanism—triggering either an audible buzzer or visual LED indicator—when the measured acceleration magnitude surpasses a configurable threshold. This threshold is empirically defined during the calibration phase and can be adjusted in the firmware to accommodate different sensitivity requirements.

by following this complete Arduino Nano seismic sensor project, you can successfully design your first vibration monitoring device.


Conclusion:

Building an Earthquake Detector Alarm with ADXL335 and Arduino Nano is a fantastic way to learn about accelerometer sensing and embedded programming. This project demonstrates core principles of vibration detection and real-time alerting. It also highlights how the 16×2 I2C LCD display, buzzer, LED, and breadboard work together with microcontrollers. With a solid understanding of this guide, you’ll not only have a functional earthquake detector but also a strong foundation for more complex safety devices.

FAQ:
  1. Can the ADXL335 detect earthquakes accurately?
    Yes, the ADXL335 is a sensitive accelerometer that can detect seismic vibrations, making it suitable for basic earthquake alarms.

  2. How to build an earthquake alarm with Arduino?
    Connect the ADXL335 sensor to Arduino, program it to monitor vibrations, and trigger an alarm (buzzer/LED) when thresholds are exceeded.

 

See Also: