DEV Community

Md Toriqul Islam
Md Toriqul Islam

Posted on

Building an Automated Heat Stress Monitoring System with Microsoft Power Platform and Telegram

Building an Automated Heat Stress Monitoring System with Microsoft Power Platform and Telegram

In today's industrial environments, worker safety is paramount, particularly when it comes to heat stress management. The Wet Bulb Globe Temperature (WBGT) Alert System presents an innovative approach to automating heat stress monitoring using readily available tools like Microsoft Forms, Power Automate, and Telegram. In this technical deep dive, we'll explore how this system works and how you can implement it in your organization.

Understanding WBGT and Its Importance

Before diving into the technical implementation, it's crucial to understand what WBGT is. The Wet Bulb Globe Temperature is a composite temperature used to estimate the effect of temperature, humidity, wind speed, and solar radiation on humans. It's particularly important in industrial settings where workers may be exposed to harsh environmental conditions.

System Architecture Overview

The WBGT Alert System employs a three-tier architecture:

  1. Data Collection Layer: Microsoft Forms serves as the frontend interface where safety officers input WBGT readings and related data.
  2. Processing Layer: Power Automate handles the business logic, data processing, and decision-making based on temperature thresholds.
  3. Notification Layer: Telegram Bot API manages the real-time distribution of alerts and safety guidelines.

Technical Implementation Details

Setting Up the Data Collection Interface

The Microsoft Forms implementation requires careful consideration of data validation and field types:

// Form Field Structure
{
  "fields": [
    {
      "type": "choice",
      "name": "weatherCondition",
      "required": true,
      "options": ["Sunny", "Cloudy", "Rainy"]
    },
    {
      "type": "number",
      "name": "wbgtReading",
      "required": true,
      "validation": {
        "min": 0,
        "max": 50,
        "decimals": 1
      }
    },
    {
      "type": "text",
      "name": "testedBy",
      "required": true
    }
  ]
}

Power Automate Flow Logic

The heart of the system lies in its Power Automate flow implementation. Here's a pseudo-code representation of the core logic:

def process_wbgt_reading(reading):
    if reading >= 33:
        alert_level = "HIGH"
        guidelines = [
            "Minimize outdoor activities",
            "15-minute breaks hourly",
            "Mandatory hydration"
        ]
        emoji = "β˜€οΈβ˜€οΈ"
    elif reading >= 31:
        alert_level = "MODERATE"
        guidelines = [
            "Reduce outdoor activities",
            "10-minute breaks hourly",
            "Regular hydration"
        ]
        emoji = "🌀️"
    else:
        alert_level = "LOW"
        guidelines = [
            "Normal activities",
            "Regular breaks",
            "Standard hydration"
        ]
        emoji = "πŸŒ₯️"

    return format_alert_message(alert_level, reading, guidelines, emoji)

Telegram Integration

The system leverages Telegram's Bot API for real-time notifications. Here's how the integration works:

  1. Bot Setup:

    • Create a bot through BotFather
    • Configure webhook endpoints
    • Set up appropriate permissions
  2. Message Formatting:

{
  "message_template": {
    "parse_mode": "HTML",
    "text": "<b>🌑️ WBGT Alert</b>\n\nLevel: {alert_level}\nReading: {temperature}°C\n\n<b>Required Actions:</b>\n{guidelines}",
    "disable_notification": false
  }
}

Security Considerations

The system implements several security measures:

  1. Authentication: Microsoft Forms access is restricted to authorized personnel through Microsoft 365 authentication.
  2. Data Validation: All inputs are validated at both the form level and within Power Automate.
  3. Secure Communication: Telegram Bot API communications are encrypted and use secure tokens.
  4. Access Control: Channel memberships are strictly managed to ensure only authorized personnel receive alerts.

System Scalability and Maintenance

The architecture is designed for scalability and easy maintenance:

  1. Modular Design: Each component (Forms, Power Automate, Telegram) can be updated independently.
  2. Backup Systems: The project structure includes backup flows and contingency plans.
  3. Documentation: Comprehensive maintenance guides ensure system longevity.

Project Structure and Organization

The system follows a well-organized structure:

WBGT-Alert-System/
β”œβ”€β”€ docs/               # System documentation
β”œβ”€β”€ flows/             # Power Automate flows
β”‚   β”œβ”€β”€ production/
β”‚   └── backup/
β”œβ”€β”€ forms/             # Form templates
β”œβ”€β”€ templates/         # Message templates
└── images/           # System screenshots

Implementation Challenges and Solutions

During implementation, several challenges typically arise:

  1. Real-time Processing: Power Automate's concurrent processing capabilities ensure timely alert delivery.
  2. Data Accuracy: Double-validation at form and flow levels maintains data integrity.
  3. User Adoption: Intuitive interface and clear documentation facilitate easy adoption.

Future Enhancements

Potential improvements for the system include:

  1. Machine Learning Integration: Predictive analytics for temperature trends
  2. Mobile App Development: Dedicated mobile interface for data collection
  3. API Integration: Connection with weather services for automated readings
  4. Advanced Analytics: Historical data analysis and reporting features

Conclusion

The WBGT Alert System demonstrates how modern tools can be combined to create an effective safety monitoring solution. By leveraging Microsoft's Power Platform and Telegram's messaging capabilities, organizations can implement robust heat stress monitoring with minimal development overhead.

The system's success lies in its simplicity, reliability, and effectiveness in maintaining worker safety. As industrial environments continue to evolve, such automated monitoring systems will become increasingly crucial in ensuring workplace safety.


For detailed implementation guides and code samples, visit the GitHub repository.

Top comments (0)