A distributed system for the control and monitoring of HVAC (Heating, Ventilation, Air Conditioning) plants based on IoT and microservices architecture. The system integrates smart objects, CoAP gateways, MQTT broker, web dashboard, and telemetry system for intelligent management of rooms and cooling racks.
- Overview
- Architecture
- Main Components
- Smart Objects
- Requirements
- Installation
- Configuration
- Usage
- API Endpoints
- Dashboard
- Monitoring
- Development
- Contributing
The HVAC system manages the automatic control of temperature, humidity, air pressure, and energy consumption through:
- IoT Smart Objects: Virtual devices simulating sensors and actuators
- CoAP Gateway: Proxy for device communication
- Policy System: Automation based on configurable rules
- Web Dashboard: Modern user interface for control and monitoring
- Telemetry: Data collection and storage with InfluxDB and visualization with Grafana
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Dashboard β β Data Collectorβ β Cloud Simulatorβ
β (Next.js) β β (Flask API) β β (Flask API) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ β βββββββββββββββββββ
β Gateway CoAP βββββββΌββββββ MQTT Broker β
β β β β β
βββββββββββββββββββ β βββββββββββββββββββ
β
βββββββββββββββββββ β βββββββββββββββββββ
β Smart Objects βββββββΌββββββ Monitoring β
β (IoT Devices) β β β (Grafana) β
βββββββββββββββββββ β βββββββββββββββββββ
β
βββββββββββββββββββ
β InfluxDB β
β (Time Series) β
βββββββββββββββββββ
- Function: CoAP proxy for discovery and communication with smart objects
- Technologies: aiocoap, asyncio
- Port: 5683 (CoAP standard)
- Function: REST API for managing rooms, racks, and devices
- Technologies: Flask, Flask-RESTful, Flask-CORS
- Port: 5000
- Endpoints:
/hvac/api/rooms
,/hvac/api/room/{id}
,/hvac/api/rack/{id}
- Function: Cloud simulation for telemetry collection
- Technologies: Flask, InfluxDB Client
- Port: 5002
- Storage: InfluxDB + JSONL files
- Function: Responsive web interface for control and monitoring
- Technologies: Next.js 15, React 19, TypeScript, Tailwind CSS
- Port: 3000
- Features: Real-time MQTT, charts, actuator control
- Function: IoT device simulation with sensors and actuators
- Technologies: Python, paho-mqtt, aiocoap
- Protocols: MQTT (telemetry), CoAP (control)
- Sensors: Temperature Sensor
- Actuators: Fan Actuator
- Purpose: Server rack cooling control
- Sensors: Pressure Sensor
- Actuators: Pump Actuator
- Purpose: Water cooling circuit management
- Sensors: Airspeed Sensor
- Actuators: Cooling Level Actuator
- Purpose: Airflow and cooling level control
- Sensors: Temperature Sensor, Humidity Sensor
- Purpose: Room environmental monitoring
- Sensors: Energy Sensor
- Purpose: Energy consumption monitoring
- Actuators: Cooling Level Actuator
- Purpose: Central hub for cooling control
- Temperature: 0-60Β°C, accuracy 0.01Β°C
- Humidity: 0-70%, accuracy 0.01%
- Pressure: 950-1050 hPa, accuracy 0.01 hPa
- Airspeed: 0.1-15 m/s, accuracy 0.01 m/s
- Energy: 0-1000 kWh, accuracy 0.001 kWh
- Fan: ON/OFF + speed (0-100%)
- Pump: ON/OFF
- Cooling Level: Levels 0-5
- Python: 3.11+
- Node.js: 18+
- Docker: 20.0+
- Docker Compose: 2.0+
- RAM: 4GB+
- Storage: 2GB+ free
- CPU: 2+ cores
git clone <repository-url>
cd HVAC-System
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
cd dashboard
npm install
npm run build
cd ..
# Start InfluxDB, Grafana, and Cloud API
docker compose up -d
# Or rebuild everything
chmod +x rebuild.sh
./rebuild.sh
BROKER_ADDRESS = "127.0.0.1"
BROKER_PORT = 1883
BASE_TOPIC = "hvac/system"
COAP_SERVER_ADDRESS = "127.0.0.1"
COAP_GATEWAY_PORT = 5683
GATEWAY_URI = "coap://127.0.0.1:5683"
{
"rooms": [
{
"room_id": "room_A1",
"location": "Building A, Floor 1",
"racks": [
{
"rack_id": "rack_A1",
"type": "air_cooled"
}
]
}
]
}
Defines automatic rules for control based on sensor values.
python gateway.py
python run_app.py
cd dashboard
npm run dev
python tests_scripts/process.py
python tests_scripts/coap_test.py
python tests_scripts/monitor_control_events.py
- Dashboard: http://localhost:3000
- API: http://localhost:5000/hvac/api
- Grafana: http://localhost:3000/grafana (admin/admin)
- Cloud API: http://localhost:5002/api
GET /hvac/api/rooms # List rooms
GET /hvac/api/room/{room_id} # Room details
GET /hvac/api/rack/{rack_id} # Rack details
POST /hvac/api/device/control # Device control
POST /hvac/api/policy/update # Update policies
GET /hvac/api/policy/room/{id} # Room policies
GET /hvac/api/policy/rack/{id} # Rack policies
POST /api/telemetry/{room_id} # Send telemetry
GET /api/telemetry/{room_id} # Retrieve telemetry
- Room View: Overview and controls per room
- Rack View: Rack details with smart objects
- Real-time Charts: Sensor data visualization
- Actuator Control: Toggles and controls for actuators
- Policy Management: Create and edit automation rules
- Responsive Design: Optimized for desktop and mobile
- Sensor Cards: Sensor status display
- Actuator Cards: Actuator controls
- Telemetry Tables: Historical data tables
- Policy Dialogs: Modals for policy management
- Organization: hvac-org
- Bucket: hvac_data
- Token: my-secret-token
- Retention: Configurable
- Dashboards: Pre-configured for HVAC
- Panels: Temperature, Humidity, Energy, Airflow
- Alerts: Configurable for critical thresholds
- Telemetry:
/telemetry_logs/
(JSONL format) - Application: Console output with configurable levels
- Gateway:
/gateway/logs/
HVAC-System/
βββ config/ # System configurations
βββ data_collector/ # Main Flask API
βββ dashboard/ # Next.js frontend
βββ gateway/ # CoAP Gateway
βββ smart_objects/ # Simulated IoT devices
βββ cloud_simulator/ # Cloud simulator
βββ mqtt_broker/ # MQTT configuration
βββ docker-compose.yml # Service orchestration
- Create the device in
/smart_objects/devices/
- Implement sensors/actuators in
/smart_objects/sensors/
or/actuators/
- Update the factory in
/data_collector/factories/smart_object_factory.py
- Configure policies in
/data_collector/conf/policy.json
- Update UI in
/dashboard/components/
# Test individual smart objects
python process.py
# CoAP test
python coap_test.py
# Event monitoring
python monitor_control_events.py
# Docker logs
docker compose logs -f
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Follow existing code style
- Add tests for new features
- Update documentation
- Test across all components
This project is developed for academic purposes - UNIMORE.
Note: This is a simulation system for educational purposes. For production use, implement additional security measures and real hardware validation.