How antonsarg/iot-sensor-data-simulator works
Project Type and Purpose
• This project is a simulator for IoT sensor data, developed as a Bachelor’s thesis. It was designed to generate synthetic sensor data for testing IoT systems.
• It simulates not only sensor data but also various error states, and is capable of sending data to external endpoints like an Azure IoT Hub or MQTT broker.
• The user interface is built with NiceGUI, providing a web-based GUI for interaction.
Analysis of the File Structure
– pages: Houses the definition of various full-page views, for example, containers_page, devices_page, and sensors_page. This implies a page-based UI layout.
– model: Contains business logic and data abstraction classes (e.g., container, device, sensor, option, and related models). These classes represent the core entities of a simulated IoT environment.
– utils: Provides helper utilities for tasks like threading, data export, connection helpers for IoT Hub and MQTT, response formatting, and the simulator core logic.
– constants: Holds application-wide constant definitions for sensor errors and units.
• At the top-level, files such as “main.py” initialize the application and set up the system.
• The “requirements.txt” file indicates the project’s dependencies, ensuring you know the technical stack (Python with libraries for NiceGUI, MQTT client libraries, Azure IoT Hub SDK, etc.).
a. Main Components to Represent:
– User Interface Layer: Represent the NiceGUI-driven web interface that includes pages and components.
– Simulation Engine: Central module (located in app/utils/simulator.py) that generates synthetic sensor data.
– Business/Model Layer: Represent the models housed in app/model (device, sensor, container, etc.). These encapsulate the domain logic.
– External Integration Modules:
• Azure IoT Hub Connector (app/utils/iot_hub_helper.py),
• MQTT Broker Connector (app/utils/mqtt_helper.py).
– Data Export Mechanism: The module in app/utils/export_helper.py is responsible for exporting data in various file formats.
– Utility Components: Include helper utilities like thread management, response formatting, etc.
b. Relationships and Interactions:
– Show how the UI components (from app/components and app/pages) interact with the simulation engine and model layer. For example, user actions on the interface trigger data generation and error simulation.
– Include interactions where the models feed into UI components (for instance, sensor models updating sensor cards in the UI).
c. Architectural Patterns and Design Principles:
– Separation of Concerns: Notice the clear division between presentation (UI components and pages), business logic (models and simulation engine), and external integrations.
– Modular Design: Each folder (components, pages, model, and utils) encapsulates a defined purpose, indicating a well-modularized approach.
– Extensibility: With distinct modules for each external service (Azure IoT Hub and MQTT), it’s easy to extend or replace these as needed.
d. Technologies/Frameworks:
– Python as the main programming language.
– NiceGUI for the web-based graphical interface.
– Azure IoT Hub SDK and MQTT libraries for external connectivity.