This repository contains a tweaked Simulated Temperature Module for Azure IoT Edge. It is based on the Simulated Temperature Sensor for Azure IoT Edge.
This module is an example of a temperature sensor simulation Azure IoT Edge module. You can see its usage in the Azure IoT Edge documentation. It continuously creates simulated temperature data and sends the message to the temperatureOutput
endpoint.
- Create an
.env
file in root directory, which contains credentials for the Azure Container Registry you want to use to upload the images.CONTAINER_REGISTRY_URI=youracr.azurecr.io CONTAINER_REGISTRY_USERNAME=youracr CONTAINER_REGISTRY_PASSWORD=YourSecretPasswordFromACR
- Set the desired architecture at the bottom of Visual Studio Code
- Right click on the
deployment.template.json
in the root directory and hit Build and push IoT Edge solution - Right click
config\deployment.yourarch.json
and select Create deployment for...
You can interact with the Temperature Simulator in several ways
The temperature simulator is producing a simulation on machine temperature / pressure and environmental parameters like temperature and humidity. The endpoint is temperatureOutput
with the following payload
{
"InstanceId": 1,
"machine": {
"temperature": 55.651076260675254,
"pressure": 4.9475909664060413
},
"ambient": {
"temperature": 21.195752660602217,
"humidity": 26
},
"timeCreated": "2018-02-09T10:53:32.2731850+00:00"
}
The module provides a direct method handler which will reset the data to its initial values. To invoke this method you just create from another module or service a CloudToDeviceMethod
Here is sample code to showcase how such a method invocation would look like through the ServiceClient
...
var resetMethod = new CloudToDeviceMethod("reset");
var response = await serviceClient.InvokeDeviceMethodAsync(deviceId, moduleId, resetMethod);
...
You can also reset the data to its initial values via a message going through the EdgeHub routing system to the temperature simulation module. You have to send the payload to the input endpoint control
.
{
"command": "reset"
}
The sending behavior can be configured using desired properties for the module via the module twin.
{
"properties": {
"desired": {
"SendData": true,
"SendInterval": 5000,
"InstanceCount": 1
}
}
}
Properties can be set during the set module process in the Azure Portal or via the Azure CLI with the Azure IoT Extension for Azure CLI 2.0.
SendData = true | false
- Start or stops pushing messages to the
temperatureOutput
endpoint.
SendInterval = int value
- The interval in milliseconds between messages being pushed into the endpoint.
InstanceCount = int value
- The amount of simulated instances