Skip to content

Prototype to connect Microtronics rapidM2M Backend service to Azure IoT Hub

License

Notifications You must be signed in to change notification settings

JMayrbaeurl/MicrotronicsAzureIoTHubConnector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microtronics Azure IoT Hub Connector

This is a sample showing how to connect and integrate Microtronics rapidM2M Backend service to Azure IoT Hub. Warning: Not production ready code. Check constraints section below.

alt text

How it works

Using a time triggered Azure Function App (Azure's serverless implementation) the Microtronics m2m Backend middleware is called regularly (default setting is once a minute) via its REST API by using the 'Site's time series data' method to retrieve the newest available telemetry data. Polling requests and their results get stored in an Azure DocumentDB collection and are finally forwarded to Azure IoT Hub.

Installation

You will need the following components to use or run this sample:

  1. Azure subscription (You can get one for free here) with Azure DocumentDB account and Azure IoT Hub instance deployed
  2. Visual Studio 2015 (at least Community edition) with Git support
  3. Access to a Microtronics M2M Backend instance (playground works too)

Configuration

  • Scheduling for the Function App time trigger can be found in the file located at .\rapidM2MPoller\rapidM2MForwarding\function.json. For more details on configuring Time triggered Azure functions see the documentation on the Azure website.
  • Application configuration can be found in the file .\rapidM2MPoller\appsettings.json.
    • M2MBackendURL: URL of the Microtronics m2m Backend service installation
    • Base64encodedUsernamePassword: Base64 encoded username and password (see Microtronics API documentation)
    • Customer_ID: customer identifier from Microtronics installation
    • Site_ID: Comma separated list of site identifiers from Microtronics installation
    • Channelnames: Comma separated list of channel names for site. If not specified, defaults to 'ch0,ch3,ch1'
    • EmulationMode: True or False. On True no data from m2m Backend will be polled
    • M2MDocumentsDBUri: Azure DocumentDB database Uri. Database and collection will be created if not existing
    • M2MDocumentsDBPrimaryKey: Primary key from the Azure DocumentDB account
    • IoTHubURL: Hostname of the Azure IoT Hub instance like [yourname].azure-devices.net
    • IoTHubDeviceId: Device Id for the Azure IoT Hub (must be registered on IoT Hub)
    • IoTHubSharedAccessSignature: Shared access signature for the IoT Hub device, e.g. generated by Device Explorer App

Constraints

  • Function must not be called multiple times. No concurrent support yet
  • No extensive failure handling implemented and no retry logic

Sample output message

{
    "customer_id": "Your customer Id",
    "site_id": "Energy meter 1",
    "Timerange": {
      "begin": "0001-01-01T00:00:00",
      "end": "2017-02-16T13:09:24.7744931-08:00"
    },
    "Timeseries": [
      {
        "Timestamp": "2017-01-26T13:30:00",
        "Channels": {
          "ch0": 51000
        }
      }
    ]
  }

About

Prototype to connect Microtronics rapidM2M Backend service to Azure IoT Hub

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published