Skip to content

Latest commit

ย 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ก Smart Sensor Hub

Real-Time IoT Telemetry & Device Control Dashboard

Smart Sensor Hub is a real-time IoT monitoring platform built with ASP.NET Core, MQTT, SignalR, Entity Framework Core, SQLite, and Python.

It ingests sensor telemetry asynchronously, persists readings, evaluates threshold-based alerts, and streams live updates to a reactive command-center dashboard โ€” without page refreshes or polling.

.NET ASP.NET Core MQTT SignalR SQLite Python


โšก What It Does

IoT Device
    โ”‚
    โ”‚ MQTT
    โ–ผ
MQTT Broker
    โ”‚
    โ–ผ
ASP.NET Core
    โ”‚
    โ”œโ”€โ”€ Process
    โ”œโ”€โ”€ Validate
    โ”œโ”€โ”€ Persist
    โ””โ”€โ”€ Evaluate Alerts
    โ”‚
    โ–ผ
SignalR / WebSocket
    โ”‚
    โ–ผ
Live Dashboard

Core capabilities

  • ๐Ÿ“ก Real-time MQTT ingestion
  • โš™๏ธ Asynchronous background processing
  • ๐Ÿ” Automatic sensor discovery
  • ๐Ÿ“Š Live telemetry charts & sparklines
  • ๐Ÿšจ Normal / Warning / Critical alerts
  • ๐ŸŽ›๏ธ Bidirectional device ON/OFF control
  • ๐Ÿ’พ Historical telemetry persistence
  • ๐Ÿ“ CSV data export
  • โšก SignalR-powered live updates
  • ๐ŸŒ™ Responsive dark command-center UI

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Python Simulator    โ”‚
โ”‚     paho-mqtt        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ”‚ MQTT Publish
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    HiveMQ Broker     โ”‚
โ”‚ smarthub/sensors/#   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ”‚ MQTT Subscribe
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        ASP.NET Core            โ”‚
โ”‚                                โ”‚
โ”‚  MqttListenerService           โ”‚
โ”‚          โ”‚                     โ”‚
โ”‚          โ”œโ”€โ”€ JSON Processing    โ”‚
โ”‚          โ”œโ”€โ”€ Threshold Engine  โ”‚
โ”‚          โ””โ”€โ”€ EF Core           โ”‚
โ”‚                โ”‚               โ”‚
โ”‚                โ–ผ               โ”‚
โ”‚             SQLite             โ”‚
โ”‚                                โ”‚
โ”‚          SignalR               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ”‚ WebSocket
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        Web Dashboard            โ”‚
โ”‚                                โ”‚
โ”‚  KPI Cards  โ”‚  Charts          โ”‚
โ”‚  Sparklines โ”‚  Alerts          โ”‚
โ”‚  History    โ”‚  Device Control  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ Real-Time Data Flow

1. Publish

The simulator publishes sensor telemetry through MQTT:

{
  "sensorId": "Machine-A1",
  "temp": 72.5
}

2. Ingest

MqttListenerService runs as an ASP.NET Core BackgroundService and subscribes to:

smarthub/sensors/#

3. Process

The backend:

  • Parses incoming JSON
  • Detects sensors dynamically
  • Calculates sensor status
  • Persists telemetry
  • Broadcasts updates

4. Stream

SignalR pushes the processed telemetry directly to connected browsers.

5. Render

The frontend instantly updates:

KPI โ†’ Sparkline โ†’ Chart โ†’ Status โ†’ Alert

No polling. No refresh.


๐Ÿšจ Smart Threshold Monitoring

Sensor health is determined from configurable temperature thresholds.

const WARN_TEMP = 75;
const CRIT_TEMP = 85;
Temperature Status
< 75ยฐC ๐ŸŸข Normal
75ยฐC โ€“ 84.9ยฐC ๐ŸŸก Warning
โ‰ฅ 85ยฐC ๐Ÿ”ด Critical

Critical events are reflected immediately across the dashboard and global alert ticker.


๐ŸŽ›๏ธ Bidirectional Device Control

Smart Sensor Hub supports both telemetry ingestion and device commands.

Dashboard
    โ”‚
    โ”‚ ON / OFF
    โ–ผ
ASP.NET Core
    โ”‚
    โ”‚ MQTT Publish
    โ–ผ
MQTT Broker
    โ”‚
    โ–ผ
IoT Device

Example command:

{
  "sensorId": "Machine-A1",
  "command": "ON"
}

๐Ÿ“Š Dashboard

The command-center interface provides:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MACHINE-A1                            โ”‚
โ”‚                                       โ”‚
โ”‚ ๐ŸŒก 72.5ยฐC        ๐ŸŸข NORMAL            โ”‚
โ”‚                                       โ”‚
โ”‚ โ–โ–‚โ–ƒโ–„โ–…โ–„โ–†โ–‡โ–†โ–‡                            โ”‚
โ”‚                                       โ”‚
โ”‚ Power              [ ON ]             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Dashboard includes

  • Live sensor KPI cards
  • Temperature trends
  • Animated values
  • Real-time Chart.js graphs
  • Sensor status indicators
  • Global alert ticker
  • Device power controls
  • Historical data modal
  • CSV export

๐Ÿ› ๏ธ Tech Stack

Backend

  • ASP.NET Core MVC
  • .NET 8
  • Entity Framework Core
  • SQLite
  • SignalR
  • MQTTnet
  • BackgroundService

Frontend

  • HTML5
  • CSS3
  • Vanilla JavaScript
  • Chart.js
  • SignalR JavaScript Client
  • JetBrains Mono
  • IBM Plex Sans

Simulator

  • Python 3
  • paho-mqtt

๐Ÿ“ Project Structure

Smart-Sensor-Hub/
โ”‚
โ”œโ”€โ”€ Controllers/
โ”‚   โ””โ”€โ”€ SensorApiController.cs
โ”‚
โ”œโ”€โ”€ Services/
โ”‚   โ””โ”€โ”€ MqttListenerService.cs
โ”‚
โ”œโ”€โ”€ Models/
โ”‚   โ””โ”€โ”€ SensorReading.cs
โ”‚
โ”œโ”€โ”€ Data/
โ”‚   โ””โ”€โ”€ ApplicationDbContext.cs
โ”‚
โ”œโ”€โ”€ Hubs/
โ”‚   โ””โ”€โ”€ SensorHub.cs
โ”‚
โ”œโ”€โ”€ Views/
โ”‚
โ”œโ”€โ”€ wwwroot/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ””โ”€โ”€ js/
โ”‚
โ”œโ”€โ”€ SensorSimulator/
โ”‚   โ””โ”€โ”€ sensor.py
โ”‚
โ”œโ”€โ”€ Program.cs
โ”œโ”€โ”€ appsettings.json
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

Prerequisites

1. Clone

git clone https://github.com/MSSOhan/Smart-Sensor-Hub.git
cd Smart-Sensor-Hub

2. Start the Backend

dotnet restore
dotnet run

Open the URL shown in the terminal, typically:

http://localhost:5010

The SQLite database is created automatically on first run.

3. Start the Simulator

Open another terminal:

pip install paho-mqtt
python fake_sensor.py

The simulator will begin publishing telemetry to the MQTT broker.

4. Open the Dashboard

http://localhost:5010

Sensors should appear automatically as telemetry arrives.


โš™๏ธ Configuration

MQTT

Default broker:

broker.hivemq.com

MQTT configuration is located in:

Services/MqttListenerService.cs
Controllers/SensorApiController.cs

Temperature Thresholds

Configure alert levels in the frontend JavaScript:

const WARN_TEMP = 75;
const CRIT_TEMP = 85;

๐Ÿ” Production Notes

The project currently uses a public MQTT broker for demonstration purposes.

For production deployments, use:

  • MQTT over TLS
  • Authenticated/private MQTT broker
  • Secure application secrets
  • Role-based access control
  • Production database
  • Centralized logging
  • Monitoring & metrics
  • Network isolation

โš ๏ธ Do not send sensitive or production telemetry through a public MQTT broker.


๐Ÿ”ฎ Roadmap

  • ๐Ÿ” Authentication & RBAC
  • ๐Ÿ“ก MQTT TLS & authentication
  • ๐Ÿ“Š Advanced analytics
  • ๐Ÿค– Predictive maintenance
  • ๐Ÿ”” Email / push notifications
  • ๐Ÿ—บ๏ธ Device location mapping
  • ๐Ÿณ Docker support
  • โ˜๏ธ Cloud deployment
  • ๐Ÿ“ˆ Prometheus / Grafana integration
  • ๐Ÿ—„๏ธ PostgreSQL / SQL Server support

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome.

git checkout -b feature/my-feature
git commit -m "Add my feature"
git push origin feature/my-feature

Then open a Pull Request.


๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿ“ก Smart Sensor Hub

Sense. Process. Stream. Control.

Real-time IoT monitoring powered by

ASP.NET Core ยท MQTT ยท SignalR ยท EF Core ยท SQLite

โญ Star the repository if you find it useful.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages