Multi-Layer Security Framework for Advanced Metering Infrastructure (AMI)
GridShield is a production-grade security solution designed to protect smart electricity meters from physical tampering, network attacks, and consumption fraud. Built for resource-constrained embedded systems, it implements a defense-in-depth strategy across three security layers.
Why GridShield? Traditional meter security relies on single-point defenses. GridShield correlates physical, network, and behavioral signals to detect sophisticated attacks that bypass conventional safeguards.
- ISR-driven tamper detection with debouncing logic
- Backup power (UPS) — Li-ion 2500mAh via TP4056 + MT3608
- Buzzer alarm — 4 alert patterns (tamper, temp, PZEM fail, boot)
- Priority flagging for emergency transmission
- Lightweight ECC (secp256r1) via micro-ecc
- ECDSA packet signing + SHA256 integrity checks
- Replay protection with sequence numbering
- Real-time consumption anomaly detection
- Profile-based behavioral analysis (24-hour baseline)
- Cross-layer validation engine
- Zero heap allocation design (embedded-friendly)
- Type-safe error handling via
Result<T>monad (no exceptions) - Platform abstraction layer (HAL) for portability
- Mock implementations for simulation testing
- FastAPI REST backend with 12 API endpoints
- SQLite database with SQLAlchemy ORM
- Vite + Chart.js real-time web dashboard
- 5 dashboards: Live Monitor (hero cards), Alerts, Anomalies, Fleet, Notifications
- Bilingual UI (Bahasa Indonesia + English)
- 2-second live polling with threshold coloring
- 186 unit tests across 20 test suites
- 7-job GitHub Actions pipeline (build, test, backend-test, backend-lint, frontend-build, clang-tidy, coverage)
- LibFuzzer + ASan/UBSan fuzzing for packet parser
- Code coverage reports via gcov/lcov
- Hardware tested on ESP32-D0WD rev1.1 (Dual Core 240MHz)
- ESP-IDF v5.5+ — Installation Guide
- QEMU (for simulation, optional)
# Clone repository
git clone https://github.com/zuudevs/gridshield.git
cd gridshield
# Build firmware
.\scripts\script.ps1 --build
# Run in QEMU simulator
.\scripts\script.ps1 --runOr manually with ESP-IDF:
cd firmware
idf.py set-target esp32
idf.py build
idf.py -p COM3 flash # flash to physical ESP32
idf.py -p COM3 monitor # serial monitor
idf.py qemu monitor # or run in QEMU simulatorSee BUILD.md for full instructions.
| Platform | MCU | Flash | RAM | Status |
|---|---|---|---|---|
| ESP32 DevKit V1 | Xtensa LX6 | 4 MB | 520 KB | ✅ Active |
| QEMU (Simulation) | Emulated Xtensa | — | — | ✅ Active |
- Build Instructions — Build & simulate with ESP-IDF + QEMU
- Architecture — System design with diagrams
- IoT Hardware Design — Component catalog, wiring schematic, assembly guide
- API Reference — Firmware & backend API documentation
- Quick Start Guide — Getting started tutorial
- Wiring Guide — Pin mapping, wiring diagrams, UPS power system
- Tech Stack — Technology choices
- Roadmap — Future development plans
- Changelog — Version history
gridshield/
├── firmware/ # ESP-IDF firmware project
│ ├── CMakeLists.txt # Root build config
│ ├── include/ # Header files
│ │ ├── common/ # Platform-agnostic headers
│ │ └── platform/ # HAL interfaces + mock impls
│ ├── main/ # Implementation files
│ ├── test_app/ # Unity test suites (186 tests)
│ ├── fuzz/ # LibFuzzer harness
│ ├── coverage/ # gcov/lcov coverage scripts
│ └── lib/micro-ecc/ # ECC library (secp256r1)
├── backend/ # FastAPI REST backend
│ ├── app/ # Python application
│ │ ├── main.py # FastAPI app entry
│ │ ├── routes.py # API endpoints
│ │ ├── models.py # SQLAlchemy models
│ │ └── schemas.py # Pydantic schemas
│ └── requirements.txt # Python dependencies
├── frontend/ # Vite + Chart.js dashboard
│ ├── src/
│ │ ├── pages/ # Dashboard, Alerts, Anomalies, Fleet
│ │ ├── components/ # Navbar, Chart components
│ │ └── api.js # Backend API client
│ └── package.json
├── .github/workflows/ # CI/CD (7-job pipeline)
├── scripts/script.ps1 # Build/run automation
└── docs/ # Documentation
└── design/ # IoT hardware design (HTML/CSS)
We welcome contributions! Please read CONTRIBUTING.md for code style guidelines and PR process.
Found a vulnerability? Do not open a public issue. See SECURITY.md for responsible disclosure.
This project is licensed under the MIT License - see LICENSE file for details.
- Muhammad Ichwan Fauzi — Team Leader
- Rafi Indra Pramudhito Zuhayr — Firmware, Backend, Frontend, CI/CD, Dokumentasi, Testing, System Architecture, Project Manager
- Cesar Ardika Bhayangkara — Hardware Integration
Catatan: Seluruh implementasi teknis yang ada di repository ini (firmware, backend, frontend, CI/CD, dokumentasi, testing, dan seluruh konfigurasi project) merupakan hasil pekerjaan Rafi Indra Pramudhito Zuhayr.
Institut Teknologi PLN — 2026
- Inspired by NIST SP 800-53 security controls
- Built with lessons from IoT security research
- Cryptography: micro-ecc (secp256r1)
⭐ Star this repo if GridShield helps your project!