Skip to content

meruto187/Seismic-Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SismoNetwork β€” Phone-Based Earthquake Early Warning System

MIT License CI Release

An open-source distributed earthquake detection network that analyzes real-time accelerometer data from Android phones, cross-references it with global seismic data (USGS, EMSC, KOERI, AFAD), and sends early warnings before official confirmation.

πŸ“± Android app: Testable via Expo Go β€” standalone APK coming soon
πŸ–₯️ Windows app: Planned (Electron + Fluent UI)


Features

Backend

  • βœ… Real-time sensor ingestion β€” multi-device WebSocket support
  • βœ… Two-layer earthquake detection β€” simple threshold + STA/LTA algorithm
  • βœ… Geofencing β€” 50 km radius clustering + region ID grouping
  • βœ… Global data sources β€” USGS, EMSC, KOERI, AFAD integration
  • βœ… Smart matching β€” correlates local sensor triggers with official data
  • βœ… Early warning β€” alerts sent before official confirmation
  • βœ… REST API + WebSocket β€” devices, events, alerts, live sensor summary
  • βœ… Web dashboard β€” Leaflet map, live device list, earthquake feed
  • βœ… Chat β€” real-time messaging over WebSocket (flood protection included)
  • βœ… Manual reports β€” /report endpoint for felt-earthquake reports (MMI scale)

Android App

  • βœ… Material You theme β€” adapts to system color palette (Android 12+)
  • βœ… 4 tabs: Alerts / Earthquake List / Report / Settings + Chat
  • βœ… Live sensor monitoring β€” accelerometer data streamed to server
  • βœ… GPS region detection β€” automatic region_id from location
  • βœ… Earthquake list β€” source filter, magnitude color scale, distance from user
  • βœ… MMI felt report β€” Mercalli scale II–VII manual report submission
  • βœ… Alert customization β€” minimum magnitude threshold, distance filter, notification types
  • βœ… Chat β€” real-time messaging, profanity filter, flood protection (3 msg/10s)

Architecture

seismic-network/
β”œβ”€β”€ main.py                    # FastAPI server, WebSocket manager, REST API
β”œβ”€β”€ analysis.py                # STA/LTA signal processing, geofencing
β”œβ”€β”€ models.py                  # SQLAlchemy database models
β”œβ”€β”€ global_sync.py             # USGS + EMSC sync
β”œβ”€β”€ koeri_sync.py              # KOERI (Kandilli Observatory) sync
β”œβ”€β”€ afad_sync.py               # AFAD sync
β”œβ”€β”€ config.py                  # Configuration
└── android-app/
    β”œβ”€β”€ App.tsx                # Tab navigation + Material You theme
    β”œβ”€β”€ context/
    β”‚   └── SeismicContext.tsx # WebSocket, sensor, chat, settings state
    └── screens/
        β”œβ”€β”€ AlertsScreen.tsx   # Alerts + network status + live sensor
        β”œβ”€β”€ QuakeListScreen.tsx# Global earthquake list
        β”œβ”€β”€ ReportScreen.tsx   # MMI felt report
        └── SettingsScreen.tsx # Settings + chat

Requirements

Backend

  • Python 3.9+
  • Ubuntu 22.04+ (VPS recommended)

Android App

  • Node.js 18+
  • Expo Go app (for testing)

Setup

Backend

pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000

Android App

cd android-app
npm install
npx expo start --lan

Scan the QR code with Expo Go.


API Reference

WebSocket

wss://YOUR_SERVER/ws/sensor/{device_id}

Send sensor data:

{
  "type": "sensor_data",
  "x": 0.05, "y": 0.03, "z": 9.81,
  "latitude": 41.0082, "longitude": 28.9784,
  "region_id": "turkey_istanbul",
  "timestamp": "2024-03-19T20:00:00Z"
}

Send chat message:

{ "type": "chat", "text": "Hello!", "timestamp": "..." }

REST Endpoints

Method Endpoint Description
GET /status Network status, device count
GET /devices Registered devices
GET /events Local + global earthquake events
GET /alerts Generated alerts
POST /report Submit a felt-earthquake report

Detection Logic

Two-Layer Detection

Layer Method Threshold
1 Simple threshold vector magnitude > 0.1g
2 STA/LTA ratio > 3.0 (STA: 1s, LTA: 30s)

Geofencing Rules

  • Time window: 5 seconds
  • Minimum devices: 3+
  • Radius: 50 km (Haversine)

Alert Decision Matrix

Local Sensors Official Data Result
βœ… Triggered ❌ No data yet EARLY WARNING (orange)
βœ… Triggered βœ… Matched CONFIRMED EARTHQUAKE (red)
❌ Silent βœ… Official data DISTANT EARTHQUAKE (blue)

Configuration

Edit config.py:

THRESHOLD_SIMPLE_G = 0.1          # Simple threshold (g)
STA_LTA_TRIGGER_RATIO = 3.0       # STA/LTA trigger ratio
GEOFENCING_RADIUS_KM = 50.0       # Clustering radius
TIME_WINDOW_SECONDS = 5           # Detection time window
MIN_DEVICES_FOR_TRIGGER = 3       # Minimum devices to confirm event

Roadmap

  • Standalone APK / EAS Build
  • Windows desktop app (Electron + Fluent UI)
  • Multi-device management panel
  • Country-based chat rooms
  • Additional data sources (INGV, GFZ)
  • iOS support

Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes
  4. Push and open a Pull Request

⚠️ This system is not a replacement for official earthquake warning services. It is intended for early alerting and community awareness only.