Use Cases

The IoTHub provides a scripting engine executing scripts developed in the programming language JavaScript. This allows the user to run several processes inside the IoTHub server. More can be found at Writing Scripts.

The IoTHub as known from the User Guide provides functionalities to see and manipulate things and properties in a generic way. For a better usability or faster and secure processing of data it is more comfortable to use external applications or the built-in script engine.

Use Case Scripts

Data at the IoTHub are property values and representing raw data of the devices (or things). Scripts allowing to manipulate values immediately when the properties are changed. It can be a good handling of data too, if some properties of different devices are combined to a virtual thing.

In this example two devices are combined to a virtual device. The first device sends the current temperature if it changed by 0.1 degrees, the second one is a real time clock and sends every second the timestamp. The script subscribes to both values. The timestamp may be in Unix seconds, which means it is just a very big number (seconds since Jan. 1. 1970). The script will format this into a readable date time string and every time a temperature value arrives it will be stored with the current date time string into the virtual thing. If the historical data are enabled, then a graph tool like Grafanaopen in new window can show a diagram with the temperature profile. Of course, it is also possible to write the temperature / date pair every second, if the timestamps arrives. In this case the data amount will be increased, but the diagram tool has a finely granulated database.

sequenceDiagram participant s as Temperature Sensor participant i as IoTHub/Scripting participant r as Realtime Clock participant t as Temperature Thing activate i r->>i: timestamp i->>i: format activate s s->>i: Temperature i->>t: Formatted Time: Temperature deactivate s r->>i: timestamp i->>i: format activate s s->>i: Temperature i->>t: Formatted Time: Temperature deactivate s r->>i: timestamp i->>i: format deactivate i

Use Case App

Another use case demonstrating the power of the IoTHub for development purpose. These are applications on top of the IoTHub. This can be a desktop application, a web application or a mobile app.

A typical use case is an emergency maintenance app. In this scenario a sensor value leaves the noncritical range or a variable at a PLC is changed to a failure value (in the simplest way is switches from false to true). This is called the notification trigger. A script or another application take notice of this change and sends out a notification. This active part is named alarm observer. The client device, in this case a mobile device owned by the maintainer, receives this push notification and a popup occurs. The user (maintainer) opens the maintaining app by clicking on the push notification and is able to receive more details about this failure. The app connects for this to the IoTHub and requests detailed information. Depending on the usage of the IoTHub it is possible to trigger some maintaining or safety actions like power off an area to prevent people getting hurt by devices or parts of them.

sequenceDiagram participant d as Machine with Failure participant i as IoTHub participant a as Mobile App participant m as Maintainer activate d activate i d->>i: trigger deactivate d activate m i->>m: receives notification activate a m->>a: starts app a->>i: request data i->>a: response data a->>m: show information deactivate a m->>m: react activate a m->>a: power off machine a->>i: set power property to false deactivate a deactivate m activate d i->>d: power off machine deactivate d deactivate i
Last Updated: