A robust end-to-end telemetry solution featuring a Python-based daemon with dynamic event detection, MQTT transport with offline buffering, and a real-time Angular dashboard with interactive analytics.
This project simulates a high-reliability embedded telemetry device. It collects sensor data (temperature and accelerometer), processes it through a dynamic event detection engine, and transmits it to a central broker. The system is engineered for resilience, featuring local persistence for offline periods and automatic recovery.
- Simulated Sensors: Periodic generation of high-fidelity temperature and accelerometer data.
- Dynamic Event Detection: A modular, class-based detection system. Adding new events is as simple as defining a new class in the model—the detector picks it up automatically.
- Offline Buffering: Automatic fallback to local JSONL storage when the MQTT broker is down.
- Reliable Transport: Features exponential backoff, automatic reconnection, and prioritized buffer flushing on recovery.
- Real-time Analytics Dashboard:
- Interactive Charts: Responsive line graphs (Chart.js) for live sensor monitoring.
- Notifications Feed: A dedicated events page with color-coded alerts and precise timestamps.
- Connection Status: Live feedback on broker connectivity.
- Logging: Log rotation with size limits and backups to prevent disk overflow.
- Dockerized: Fully orchestrated with Docker Compose for seamless deployment.
embedded-telemetry-app/
├── .github/ # CI/CD Pipeline (GitHub Actions)
├── app/ # Python Telemetry Daemon
│ ├── ingestion/ # Sensor simulation
│ ├── processing/ # Dynamic threshold & event logic
│ ├── buffer/ # Offline storage (JSONL) management
│ ├── transport/ # Reliable MQTT client logic
│ ├── models/ # Data schemas & Event hierarchy
│ │ ├── events/ # Modular event definitions (Base, Temp, Tilt)
│ │ └── message.py # Telemetry packet structure
│ ├── utils/ # Shared utilities (Log rotation, etc.)
│ └── daemon.py # Main orchestrator class
├── telemetry-dashboard/ # Angular Web Interface
│ ├── src/app/
│ │ ├── components/ # Modular UI (Dashboard, Events, Charts)
│ │ ├── services/ # Telemetry state & MQTT management
│ │ └── app.routes.ts # Router configuration
│ └── Dockerfile # Multi-stage build (Node + Nginx)
├── config/ # Configuration (YAML, Mosquitto)
├── scripts/ # Automation & helper scripts
│ └── setup_service.sh # Automated systemd service installer
├── systemd/ # Linux service configuration
│ └── telemetry.service # Systemd unit file
├── tests/ # Python unit tests & verification scripts
├── .flake8 # Flake8 linting configuration
├── docker-compose.yml # Container orchestration
└── requirements.txt # Python dependencies
The easiest way to run the entire stack is using Docker Compose.
-
Start the system:
docker compose up -d --build
-
Access the Dashboard: Open http://localhost:4200 in your browser.
-
Monitor Logs:
docker compose logs -f telemetry
- Python 3.12+
- Node.js & npm
- Mosquitto Broker (with WebSocket support)
# Install Python dependencies
pip install -r requirements.txt
# Install Angular dependencies
cd telemetry-dashboard && npm install- Broker:
mosquitto -c config/mosquitto.conf - Daemon:
python app/main.py - Dashboard:
cd telemetry-dashboard && npm start
Edit config/config.yaml to customize:
- MQTT: Broker address, ports, and topics.
- Sensors: Device ID and sampling interval.
- Thresholds: Limits for temperature (
temperature) and tilt (accelerometer) events. - Buffer: Local storage path and file size limits.
Verify the system logic with the built-in test suites:
# Set PYTHONPATH and run all tests
$env:PYTHONPATH="."; pytestThe project uses flake8 for code quality and style enforcement (80-character line limit).
# Run the linter
flake8 .A GitHub Actions pipeline is configured in .github/workflows/ci.yml. On every push or pull request to the main branch, the following steps are performed:
- Linting: Verifies code style with
flake8. - Testing: Runs the
pytestsuite. - Integration: Builds the Docker images and starts the services using
docker-compose. - Health Check: Waits for services to initialize and verifies that the
telemetry-daemonsuccessfully connects to the MQTT broker by checking the container logs.
For production-like environments on Linux, you can run the telemetry daemon as a systemd service. This ensures it starts automatically on boot and restarts if it crashes.
The project includes a setup script that automates the installation to /opt/telemetry-daemon, creates a dedicated telemetry user, sets up a virtual environment, and installs the service.
# Make the script executable and run with sudo
chmod +x scripts/setup_service.sh
sudo ./scripts/setup_service.sh# Check status
sudo systemctl status telemetry
# Monitor logs in real-time
journalctl -u telemetry -f
# Restart the service
sudo systemctl restart telemetryIf you see Error: Invalid protocol value (websockets), your version of Mosquitto might be compiled without WebSocket support. On Linux, ensure you have the necessary plugins:
sudo apt install mosquitto mosquitto-clientsIn Docker, this is handled automatically by the eclipse-mosquitto:2 image.