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!