2

I would like to change the frequency of the simulated tempSensor module so that it sends telemetry to the IoT Hub every 60 seconds, not every 5 seconds. I cannot find the code in order to create my own C# module or to modify the one that Azure has as a sample. How do I change the frequency of the telemetry of this simulated temperature sensor module used in the IoT Edge walkthrough?

https://hub.docker.com/r/microsoft/azureiotedge-simulated-temperature-sensor/

I have an Azure Iot Hub with 8000 messages per day and Iot Edge device simulated and a tempSensor and filterModule through Docker setup etc... All is working well.

I could write another C# module similar to the filterModule which would function like a time filter and averages 12 readings together and sends a message every 60 seconds and then the filterModule does it's job after. So the route would go from tempSensor to timeFilter to filterModule. Along this line of thinking.

SIMULATED TEMPERATURE SENSOR in Docker

https://azure.microsoft.com/en-us/resources/samples/?service=iot-hub&sort=0&term=simulated

Where do I find the code for that example? I looked here:

https://github.com/Azure-Samples

I am trying to learn how the simulated temperature sensor module works in the code in order to build off that to create my own IoT modules.

I found something close but am not sure how to go between this code and the modules used in IoT Edge.

https://learn.microsoft.com/en-us/dotnet/api/overview/azure/iot?view=azure-dotnet

I don't see API reference here:

https://learn.microsoft.com/en-us/azure/iot-edge/

Here are some other places I looked:

https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge

https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit

1 Answers1

2

The source code is not currently open source.

Update:

Currently (April 2018) the code is open-sourced under the MIT licence and can be found on GitHub here:link

To solve your immediate need, there is an undocumented setting for adjusting the delay. All the available settings for the Simulated Temperature sensor module (and default values):

"MessageDelay": "00:00:05",

"machineTempMin": 21,

"machineTempMax": 100,

"machinePressureMin": 1,

"machinePressureMax": 10,

"ambientTemp": 21,

"ambientHumidity": 25

This may be set as environment variables in the "createOptions" section, like this:

      "tempSensor": {
        "version": "1.0",
        "type": "docker",
        "status": "running",
        "restartPolicy": "always",
        "settings": {
          "image": "microsoft/azureiotedge-simulated-temperature-sensor:1.0-preview",
          "createOptions": "{\"Env\":[\"MessageDelay=00:01:00\"]}"
        }
      }
Mike Wise
  • 22,131
  • 8
  • 81
  • 104
darobs
  • 106
  • 4
  • Thanks for this very helpful information. SInce I had already created the module I used the "Set Module" method to modify the tempSensor and in the "Container Create Options" section I placed the following line: { "Env":["MessageDelay=00:01:00"] } – Daniel Maxwell Feb 06 '18 at 03:44
  • One more comment or question: Is the code sample provided for a C# filterModule similar in any way to a simulated module such as the tempSensor? I would like to write code to study my own simulated modules and am not sure where an example is. I was thinking this tempSensor example would have code to study but I see it is not yet open source. Where to find sample code for simulating sensors for use in an Iot Edge scenario? – Daniel Maxwell Feb 06 '18 at 03:50
  • You can use Visual Studio Code to develop a C# module with Azure IoT Edge,please see here: https://learn.microsoft.com/en-us/azure/iot-edge/how-to-vscode-develop-csharp-module – Michael Xu Feb 09 '18 at 02:57
  • 2
    Actually the code is posted here with the MIT license. https://github.com/Azure/iot-edge/tree/master/v2/samples/azureiotedge-simulated-temperature-sensor - could be this was posted right around your answer though. – Mike Wise Apr 14 '18 at 12:14
  • i'm trying to replace simulated temp image with my own python one, which sends telemetry to IOT Central... is there any python version to simulated temp sensor sample?. – mohamed tarek Nov 22 '21 at 10:09