IoT Telemetry Simulators & Twin Sync
Engineered an event-driven device-to-twin pipeline: Node.js simulators stream MQTT telemetry into Azure IoT Hub, and an Event Grid-triggered Azure Function patches DTDL v2 digital twins via managed identity while persisting readings to Cosmos DB.
- Role
- Primary engineer · IoT, serverless & data
- Year
- 2022–2023
- Type
- IoT & digital twins
- Stack
- Azure IoT Hub · Azure Digital Twins (DTDL v2) · Azure Functions · Azure Event Grid · Azure Cosmos DB · Node.js · MQTT · Azure Stream Analytics · Managed identity
- simulated device types
- 7
- to replay a full day of hourly telemetry
- ~24 s
- DTDL v2 twin models
- 6
The problem
A remote-monitoring and digital-twin product needed realistic, repeatable telemetry before real equipment was connected. Dashboards, 3D twin scenes and alert rules all depended on twins and storage reflecting each device's latest state, end to end from device to cloud.
Architecture
- 01
Simulation
Node.js device clients for pumps, chillers, AHU, compressor, energy meter, oxygen plant and RTLS tags generate random-walk, bounded or CSV-replayed telemetry.
- 02
Ingestion
Messages published to Azure IoT Hub over MQTT, stamped with creation time and a message-schema property naming the device type.
- 03
Routing
IoT Hub routes device messages to Event Grid, triggering a Node.js Azure Function per event.
- 04
Twin sync
The function decodes the payload, maps fields to DTDL PascalCase paths and applies JSON Patch updates via DigitalTwinsClient with managed identity.
- 05
Persistence and rules
Readings land in a Cosmos DB telemetry container; Stream Analytics tumbling-window aggregates evaluate threshold rules.
Engineering highlights
01
Event-driven twin sync
Built an Event Grid-triggered Azure Function that base64-decodes IoT Hub payloads, coerces numeric types, maps properties to DTDL PascalCase paths and issues JSON Patch replaces to Azure Digital Twins using DefaultAzureCredential and managed identity.
02
Time-compressed day replay
Simulators stamp readings from local midnight and advance one hour per tick, filling a full day of hourly data in about 24 seconds for repeatable chart, trend and alert testing against known values.
03
Physically plausible signals
Telemetry comes from random walks, per-field realistic ranges (grid frequency, phase voltage, power factor, oxygen purity) and CSV replay of recorded pump operating points, so pump curves and fault analysis look credible.
04
Device twins and direct methods
Simulated device management: reported properties plus Reboot, FirmwareUpdate and valve-control direct methods, with a staged firmware update that patches reported state at each step and suppresses telemetry while offline.
05
DTDL v2 twin models
Authored DTDL v2 interface models for pump, chiller, oxygen pump, AHU, air compressor and energy meter, aligning simulator payloads with the twin properties used by 3D scene visual rules.