Edge-resilient IoT telemetry pipeline — buffers sensor data locally during connectivity loss, syncs to AWS IoT Core on reconnect, uses Claude Sonnet for anomaly detection.
Built by Skipper as a portfolio project.
Stack: Python · MQTT (Mosquitto) · AWS IoT Core · Claude Sonnet · Terraform · SQLite · Grafana
Edge Device
├── Mosquitto (local MQTT broker)
├── collector.py — normalizes sensor payloads from MQTT topics
├── buffer.py — SQLite-backed offline buffer (survives power/connectivity loss)
├── sync.py — probes connectivity; drains buffer → AWS IoT Core
└── anomaly.py — batches readings → Claude Sonnet for anomaly detection
Cloud (AWS)
├── AWS IoT Core — ingests telemetry over MQTT/TLS
├── Timestream — time-series storage
└── Grafana — dashboards
See docs/case-study.md for a full technical write-up.
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txtcp .env.example .env
# Edit .env — fill in AWS_IOT_ENDPOINT, ANTHROPIC_API_KEY, cert pathsmosquitto -c mosquitto/mosquitto.confpython -m agent.mainpytest tests/ -vTests are fully offline — no AWS or Anthropic credentials needed.
IMPORTANT: Never run
terraform applywithout explicit approval. Always reviewterraform planoutput first.
cd infra
terraform init
terraform plan
# terraform apply ← only after reviewing the planRequired AWS resources: IoT Core Thing + cert, Timestream DB/table, IAM role, IoT topic rule.
See infra/variables.tf for configurable inputs and create a terraform.tfvars to override defaults (gitignored).
Import dashboard/grafana-dashboard.json via Dashboards → Import in the Grafana UI. The dashboard expects an Amazon Timestream data source configured with read access to the watershed_telemetry database.
watershed/
├── agent/
│ ├── main.py # entry point and event loop
│ ├── collector.py # MQTT subscriber + payload normalizer
│ ├── buffer.py # SQLite offline buffer
│ ├── sync.py # connectivity probe + AWS IoT sync
│ ├── anomaly.py # Claude Sonnet anomaly detection
│ └── config.py # configuration from env vars
├── infra/ # Terraform (AWS IoT Core, Timestream)
├── mosquitto/ # local Mosquitto broker config
├── dashboard/ # Grafana dashboard JSON
├── docs/ # case study and portfolio post
├── tests/ # pytest unit tests
├── .env.example # required environment variables
├── requirements.txt
└── CLAUDE.md # project context for Claude Code
MIT