Skip to content

kn13programmer/IOT-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RND-Process - IoT Telemetry Integration for Business Central

Organization: Cetas Information Technology Pvt Ltd
Project Version: 1.0.0.0
Status: Research and Development (RND)


πŸ“‹ Project Overview

This project is a comprehensive Business Central extension that integrates IoT (Internet of Things) telemetry data with Microsoft Dynamics 365 Business Central. It enables real-time monitoring, collection, and management of IoT sensor data (specifically DHT11 temperature and humidity sensors) and presents this data through interactive dashboards and reporting pages within Business Central.


🎯 Project Purpose

The primary purpose of this RND project is to:

  1. Bridge IoT Devices with Business Central: Connect physical IoT devices (Raspberry Pi with DHT11 sensors) to Business Central using Azure IoT Hub.
  2. Real-time Data Collection: Capture sensor telemetry data (temperature, humidity, timestamps) and store it securely.
  3. Business Intelligence: Provide interactive dashboards and reports for analyzing IoT telemetry patterns.
  4. Scalable Architecture: Design a cloud-native solution using Azure services (IoT Hub, Functions, Azure Cosmos DB).
  5. Demonstrate Modern Integration Patterns: Showcase best practices for IoT-to-ERP integration.

πŸ—οΈ Architecture & Concept

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  IoT Devices    β”‚
β”‚ (Raspberry Pi   β”‚
β”‚  + DHT11)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€ MQTT/HTTPS
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Azure IoT Hub             β”‚
β”‚ (Central message broker)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€ Event stream
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Azure Functions            β”‚
β”‚ (Data processing & routing) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€ Process & transform
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Azure Cosmos DB            β”‚
β”‚ (NoSQL data storage)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€ Query API
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Business Central            β”‚
β”‚ (Pages, Tables, Reports)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Data Flow Concept

1. Data Collection Phase

  • Source: DHT11 sensors on Raspberry Pi devices
  • Action: Reads temperature and humidity values every 5-10 seconds
  • Transport: Python script (az_iot_dht11.py) sends data to Azure IoT Hub via MQTT
  • Output: JSON payload with sensor readings and timestamps

2. Cloud Processing Phase

  • Trigger: Azure IoT Hub receives telemetry message
  • Processing: Azure Function (AzureFuntion.csx) processes incoming data
  • Tasks:
    • Validates sensor data
    • Transforms data format
    • Enriches with metadata (device ID, location)
    • Applies business rules
  • Output: Structured data ready for storage

3. Data Storage Phase

  • Database: Azure Cosmos DB (NoSQL, globally distributed)
  • Partition Strategy: Hierarchical partition keys for optimal performance
  • Storage Structure:
    {
      "id": "unique-document-id",
      "deviceId": "device-001",
      "temperature": 25.5,
      "humidity": 60.2,
      "timestamp": "2025-12-05T10:30:45Z",
      "location": "Office-Room-1",
      "organizationId": "cetas-001"
    }
    

4. Business Central Integration Phase

  • API Layer: REST API endpoint to query Cosmos DB
  • Business Central Tables:
    • TelemetryIoT (Main table storing core telemetry data)
  • Data Retrieval: Scheduled job or on-demand query to fetch latest telemetry

5. Presentation & Analysis Phase

  • Pages:
    • TelemetryIoTCard.Page.al: Detailed view of individual telemetry records
    • TelemetryIoTAPI.Page.al: API configuration and management
    • TelemetryCuePage.Page.al: Cube/analytical view for data analysis
    • TelemetryListPart.Page.al: List view showing multiple records
  • Features:
    • Real-time dashboard display
    • Historical trend analysis
    • Alert configuration (temperature/humidity thresholds)
    • Export capabilities

πŸ”‘ Key Components Explained

Python Source (Python src/)

  • az_iot_dht11.py: Main IoT device script

    • Reads DHT11 sensor data
    • Connects to Azure IoT Hub
    • Sends telemetry at regular intervals
    • Handles connection retry logic
  • az-dht11.service: System service definition

    • Ensures script runs as a background service on Raspberry Pi
    • Auto-restart on failure
    • System integration
  • AzureFuntion.csx: Azure Function code

    • Processes incoming IoT Hub messages
    • Routes data to Cosmos DB
    • Implements business logic

Business Central Components (src/)

Tables (src/table/)

  • TelemetryIoT.Table.al: Stores telemetry data
    • Fields: Device ID, Temperature, Humidity, Timestamp, Status
    • Primary Key: Unique identifier for each reading
    • Used for reporting and analytics

Pages (src/page/)

  • TelemetryIoTCard.Page.al: Single record detail view
  • TelemetryListPart.Page.al: List of records (used as subpage)
  • TelemetryCuePage.Page.al: Analytical data cube
  • TelemetryIoTAPI.Page.al: API configuration interface

Code Units (src/codeunit/)

  • Business logic and utility functions
  • Data validation and transformation
  • Integration with external services

πŸ”„ Complete End-to-End Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 1: DEVICE LAYER                                         β”‚
β”‚ IoT Device (Raspberry Pi + DHT11) measures environment data  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 2: AZURE IOT HUB INGESTION                              β”‚
β”‚ Device sends data via MQTT protocol to Azure IoT Hub         β”‚
β”‚ Hub acts as central message broker                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 3: SERVERLESS PROCESSING                                β”‚
β”‚ Azure Function triggers on new message                        β”‚
β”‚ Validates, transforms, and enriches data                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 4: DATA PERSISTENCE                                     β”‚
β”‚ Processed data stored in Azure Cosmos DB                     β”‚
β”‚ NoSQL database optimized for scale and global reach          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 5: BUSINESS CENTRAL RETRIEVAL                           β”‚
β”‚ Scheduled job or API call fetches data from Cosmos DB        β”‚
β”‚ Data synced to TelemetryIoT table                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ STEP 6: PRESENTATION & ANALYTICS                             β”‚
β”‚ Users view dashboards in Business Central                    β”‚
β”‚ Analyze trends, set alerts, generate reports                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’‘ Key Concepts

Why Azure IoT Hub?

  • Central management point for all IoT devices
  • Security: Device-to-cloud authentication and authorization
  • Scalability: Handles millions of messages per day
  • Message routing to different backends (Azure Functions, Cosmos DB, etc.)

Why Azure Functions?

  • Serverless architecture: Pay only for processing time
  • Event-driven: Automatically triggered by IoT Hub messages
  • Cost-effective for batch processing
  • Easy integration with other Azure services

Why Azure Cosmos DB?

  • Global distribution: Low-latency access worldwide
  • Elastic scalability: Handles variable workloads
  • Multi-model support: JSON documents, graphs, key-value
  • Built-in analytics with change feeds
  • Excellent for IoT data retention and historical analysis

Why Business Central?

  • Single source of truth for business operations
  • Integrated dashboards and reporting
  • User-friendly interface for non-technical users
  • Extensibility through add-ins and APIs
  • Compliance and audit trails

πŸ“¦ Project Structure

RND-Project/
β”œβ”€β”€ app.json                      # Extension metadata and configuration
β”œβ”€β”€ README.md                     # Documentation
β”œβ”€β”€ IOTWebService.xml             # Web service definition
β”œβ”€β”€ LICENSE                       # License information
β”‚
β”œβ”€β”€ Python src/                   # IoT device code
β”‚   β”œβ”€β”€ az_iot_dht11.py          # DHT11 sensor reading & IoT Hub communication
β”‚   β”œβ”€β”€ az-dht11.service         # Systemd service file for Linux
β”‚   └── AzureFuntion.csx         # Azure Function for data processing
β”‚
β”œβ”€β”€ src/                          # Business Central extension code
β”‚   β”œβ”€β”€ table/
β”‚   β”‚   └── TelemetryIoT.Table.al # Main telemetry data table
β”‚   β”œβ”€β”€ page/
β”‚   β”‚   β”œβ”€β”€ TelemetryIoTCard.Page.al     # Single record view
β”‚   β”‚   β”œβ”€β”€ TelemetryIoTAPI.Page.al      # API management
β”‚   β”‚   β”œβ”€β”€ TelemetryCuePage.Page.al     # Analytical view
β”‚   β”‚   └── TelemetryListPart.Page.al    # List subpage
β”‚   └── codeunit/                # Business logic and utilities
β”‚
β”œβ”€β”€ Translations/
β”‚   └── RND-Project.g.xlf        # Multi-language support file
β”‚
└── Resources/                    # Static assets
    β”œβ”€β”€ Applogo/                 # Application branding
    β”œβ”€β”€ Data/                    # Sample/reference data
    └── Images/                  # UI images and icons

πŸš€ Deployment & Usage

Prerequisites

  • Azure Subscription (IoT Hub, Functions, Cosmos DB)
  • Raspberry Pi with DHT11 sensor
  • Business Central environment
  • AL language extension for VS Code

Development Workflow

  1. Device Development: Modify Python scripts on Raspberry Pi
  2. Cloud Processing: Update Azure Function logic in AzureFuntion.csx
  3. Business Central: Develop tables and pages in AL language
  4. Testing: Validate end-to-end data flow
  5. Deployment: Package extension and deploy to Business Central

πŸ” Security Considerations

  • Device Authentication: IoT Hub enforces device-level authentication
  • Data Encryption: TLS/SSL for data in transit
  • Access Control: RBAC in Business Central for data access
  • Secrets Management: Azure Key Vault for storing connection strings
  • Audit Logging: Track all data access and modifications

πŸ“ˆ Performance & Scalability

  • Message Throughput: Azure IoT Hub: Millions of messages/day
  • Data Storage: Cosmos DB with auto-scaling based on demand
  • Query Performance: Optimized partition keys for fast lookups
  • Business Central: Indexed tables for responsive UI

πŸ› οΈ Future Enhancements

  • Machine learning for anomaly detection
  • Predictive maintenance alerts
  • Mobile app for field monitoring
  • Multi-site dashboard aggregation
  • Advanced analytics with Power BI integration
  • Automated remediation actions

πŸ“ž Support & Contact

Organization: Open Source
Project Lead: Mir Kasim Ali Naqvi
LinkedIn: https://www.linkedin.com/in/mir-kasim-ali-naqvi-04971a236


πŸ“„ License

See LICENSE file for details.


Last Updated: December 5, 2025

About

Working on RND for Cetas Information Technology

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published