A DIY Earthquake Alert System built with the ESP8266 NodeMCU ESP12E and an MPU6050 6-axis accelerometer + gyroscope module.
The system continuously monitors vibrations, filters noise, and activates both an audible and visual alarm (buzzer + LED) when shaking is detected.
Watch the live demo here:
Video Demonstration
This project is a DIY Earthquake Alert System created for learning, experimentation, and hobby use. It is not a certified earthquake detection or early warning system and should not be relied upon for safety-critical applications. Professional, industrial, and government systems are far more advanced and undergo rigorous testing.
Use this project as a hands-on learning tool to explore sensors, IoT, and electronics, not as a substitute for real-world disaster prevention systems.
The author is not responsible for any damage, injury, or loss caused by using this project. Always handle electronics safely.
- ESP8266 development board NodeMCU ESP12E
- MPU6050 accelerometer + gyroscope sensor
- Passive buzzer
- Jumper wires
- breadboard
| NodeMCU Pin | Function / Signal | Destination |
|---|---|---|
| 3V3 | Power VCC | MPU6050 VCC |
| GND | Ground | MPU6050 GND |
| D1 (GPIO5) | I²C SCL | MPU6050 SCL |
| D2 (GPIO4) | I²C SDA | MPU6050 SDA |
| D5 (GPIO14) | Buzzer + | Passive Buzzer (+) |
| GND | Buzzer − | Passive Buzzer (−) |
| D4 (GPIO2) | Onboard LED | LED indicator |
-
The HW-085 Boost Converter Module allows you to adjust the output voltage using solder pads labeled A and B on the front side of the PCB.
-
Use a soldering iron to bridge (connect) or remove (disconnect) the pads set it to 5V
| A | B | Output Voltage |
|---|---|---|
| 0 | 0 | 5V |
| 0 | 1 | 8V |
| 1 | 0 | 9V |
| 1 | 1 | 12V |
Note:
0= Pad disconnected1= Pad connected
- Download and install the latest Arduino IDE.
- Open Arduino IDE
- Go to File → Preferences
- In Additional Board Manager URLs, add:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Go to Tools → Board → Board Manager, search for ESP8266, and install.
In Arduino IDE, go to Sketch → Include Library → Manage Libraries... and install:
- Wire (usually pre-installed)
- MPU6050 by Electronic Cats / Jeff Rowberg (I²Cdevlib)
- Go to Tools → Board, select your ESP8266 NodeMCU ESP12E 1.0.
- Select the correct COM Port under Tools → Port.
- Open the provided
.inocode file in Arduino IDE. - Click the Upload button (right arrow icon).
- Wait until the code compiles and uploads successfully.
- Once uploaded, open the Serial Monitor at 115200 baud.
- The system will calibrate automatically, then start monitoring vibrations.
- Shake the sensor slightly to trigger the buzzer + LED.
You can adjust these parameters based on your desired behavior for the system (e.g., sensitivity, alert duration, or stability).
#define BUZZER_PIN 14 // D5 = GPIO14
#define LED_PIN 2 // D4 = GPIO2
#define THRESHOLD 450 // Higher = less sensitive
#define CONFIRM_COUNT 2 // Require consecutive strong shakes
#define FILTER_SIZE 15 // Moving average filter size
#define SAMPLE_COUNT 100 // Baseline calibration samples
#define STABLE_COUNT 10 // Quake ends after 10 stable readings
#define ALERT_DURATION 4000 // Total alert duration (ms)
#define PULSE_INTERVAL 40 // Pulse on/off interval (ms)
#define NOISE_FLOOR 60 // Ignore tiny raw vibrations
#define RETRY_INTERVAL 5000 // Retry reconnect every 5s
#define COOLDOWN_TIME 1000 // Cooldown after alert (ms)
#define RESET_TIMEOUT 60000 // 60s no valid data = auto reset
#define DAILY_RESET 86400000UL // 24h auto reset (ms)
#define MIN_DURATION 1200 // Anti-knock feature- Created with passion ❤ by Roy Cuadra
- Updated Date: 10-18-2025
Thank you for checking out this project! You are welcome to fork, improve, or use it for learning purposes.

