Code Monkey home page Code Monkey logo

simulatedtemperaturesensor's Introduction

Simulated Temperature IoT Edge Module

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.

Creating the images

  1. 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
    
  2. Set the desired architecture at the bottom of Visual Studio Code
  3. Right click on the deployment.template.json in the root directory and hit Build and push IoT Edge solution
  4. Right click config\deployment.yourarch.json and select Create deployment for...

Available Endpoints

You can interact with the Temperature Simulator in several ways

Output Queue Endpoints

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"
}

Direct Method Invocation

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);
...

Input Queue Endpoints

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"
}

Desired Properties Support

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

simulatedtemperaturesensor's People

Contributors

renehezser avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.