How to connect non-programmable (no SDK) devices to IoT Hub - azure-iot-hub

I am building an IoT solution based on devices that are not programmable (3rd party devices).
I can just configure the server they must connect to and I have the messaging (sending messages and receiving commands).
What is the best way to integrate them in an Azure IoT Solution (IoT Hub) ?
It looks like we can use Azure IoT Edge as Gateway (https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-edge/iot-edge-as-gateway.md) in a "Identity translation" pattern, but I still not figure out how to do it.
I also find Azure IoT Protocol Gateway (https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-protocol-gateway) that seems to do the job but it is not sufficiently clear for me what to do.
Thanks in advance for your help.

The question is which protocols your devices support and how configurable your devices are. For instance you might be able to talk MQTT directly to the IoT Hub without using the SDK: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly-as-a-device
Same is possible for HTTP using the REST API directly: https://learn.microsoft.com/en-us/rest/api/iothub/device
If neither is an option then yes, you need some kind of gateway - like in the examples which you linked.

Related

Send and receive iot-hub messages

I am working on a project based on the azure sphere kit where I want to control a motor from a web application. I managed to send the command to the iot hub and the build in monitor shows that the message is received by the iot hub. Now, my question is: How can I forward this message to the board? I have to mention that this is my first experience with the iot-hub so please dont judge me if it is a stupid question.:) Here is the confirmation that the message is received by the iothub
If you want to communicate with your Azure Sphere from Azure IoT Hub, you're talking about Cloud-to-device communication. There are three different ways to do this communication:
Direct Methods
Device Twin Desired Properties
Cloud-to-device (C2D) messages
Microsoft documented them here. This document also lists the different considerations for each of the three methods.
To forward the IoT Hub message that you mentioned in your question, a good start would be to write an Azure Function that listens to the IoT Hub output and send that to the device using one of the three methods above. You can find an example for the Azure Function IoT Hub trigger here
Adding few more detailed options in this scenario to the above responses.
Scenario 1: You may be interested in configuring your devices from your back-end service(s) as your web application. To synchronize state information between a device and an IoT hub, you use device twins. A desired property is set by a back-end application and read by a device. A reported property is set by a device and read by a back-end application. A tag is set by a back-end application and is never sent to a device. You use tags to organize your devices. Long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes. This completes your E2E state synchronization scenario : Web-Application<=>IoT Device, Ref Link
Question: How can I forward this message to the board?
Scenario 2: You may be interested in direct method to control a device connected to your IoT hub. You can use direct methods to remotely change the behavior of devices connected to your IoT hub. Commands that require immediate confirmation, such as turning on a fan.
Requirements:
-->IoT Device: To receive the direct method calls, the applications running on IoT Device connect to a device-specific endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;DeviceId=MyNodeDevice;SharedAccessKey={YourSharedAccessKey}
-->Web-Application: To call a direct method on a device, your Web application connects to service-side endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey={YourSharedAccessKey}
Direct Method calls: Points to be noted. Please visit the link: detailed comparison of the various cloud-to-device communication options.
The maximum direct method payload size is 128 KB.
Disconnected devices are not contacted. The solution back end is notified that the device is not connected.
Ref Link
If you need further help in this matter, please comment in the below section and we will be happy to help you on this forum.

Azure IoT Edge as a translation gateway for TCP/IP based OBD-II device [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
We want to use Azure IoT Edge as an identity translation gateway with the protocol translation gateway. Because we are working with an OBD-II device that strictly uses TCP/IP as communication protocol. We can only add IP, PORT, and APN in the device nothing else.
We want to use these devices with the Azure IoT Hub. As we know Azure IoT hub works only with MQTT, AMQP, and HTTPS.
We want to use Identity translation for:
Creating IDs for these lots of devices from the IoT edge and register them in IoT Hub.
If possible, we want to automatically make the device to Azure IoT Hub communication via IoT Edge.
We want to use protocol translation for:
Acting as a medium to communicate between the Devices working on the TCP/IP and the Azure IoT Hub, which supports MQTT, AMQP, and HTTPS communication protocol.
We want to have a Bi-directional communication with the Azure IoT cloud. So we can send messages back to the devices when needed and do FOTA.
My Questions:
Is there a module available for the TCP/IP implementation in this sample?
Can this repository be used for production-level implementation for the above?
Is there any full detailed documentation like this sample for implementing the actual asked for production level?
Does this Implementation way provide two-way communication? Device to edge to cloud and then Cloud to edge to the device?
Is this identity translation gateway in development and is actually not fully blown for the production purpose?
Is there any working example or a full developer guide for Implementing Azure IoT Edge gateway as an Identity translation gateway with protocol translation gateway?
IoT Edge as a translation gateway (protocol translation and identity translation) is only supported by third-party modules. That custom or third-party module will be responsible for pre-processing the incoming messages and turn them into a format that can be understood by IoT Hub.
The IoT Edge runtime does not include protocol or identity translation
capabilities. These patterns requires custom or third-party modules
that are often specific to the hardware and protocol used. Azure
Marketplace contains several protocol translation modules to choose
from. For a sample that uses the identity translation pattern, see
Azure IoT Edge LoRaWAN Starter Kit.
Ref: Device capabilities behind translation gateways
There is a full developer guide and best practices for implementing Azure IoT Edge as a transparent gateway in the following doc: Connect a downstream IoT Edge device to an Azure IoT Edge gateway
Like mentioned in the github repo you are referring to Azure IoT Edge Identity Translation Lite: Sample on implementing Identity Translation at the edge , that is a:
'lite' implementation of the Identity Translation pattern as it only
supports the basic identity translation flows based on symmetric keys
Leverage github issues section and suggest pull requests there with your implementation - that sample started being implemented by Microsoft Engineers though it is not officially supported by IoT Edge runtime.

Azure webhook triggers a IoT Hub

I want to make a webhook that can be triggered by either get/post and triggers connected IoT devices to a WebSocket.
So, I thought Azure might help to automize this process, instead of writing everything from scratch and run it on a webserver.
I am very new in the Azure world, I found it very complicated to make it working on Azure.
Can you point me to any simple to make it work?
The first thing to do is to decide where you want to connect your devices to. Generally, you'll either use Azure IoT Hub or IoT Central (which uses an IoT Hub anyway). Your question doesn't include any details about your devices, or whether you're developing them yourself, but I'll assume you can connect to either.
If you go for Azure IoT Central, the easiest way to get a webhook going is to create a Logic App and link nodes together to trigger a Command to your device. You can use an HTTP request as the trigger, and use the built-in IoT Central node to trigger your command, example:
If you end up connecting your devices to IoT Hub, you can use Direct Methods, Cloud to Device messages or even Device Twins to communicate with your devices. You can leverage these by creating an Azure Function with an HTTP trigger, and you program the logic to call IoT Hub, which will communicate with your devices. There are a lot of samples on the web that show how to create Functions, or control your device remotely.
There are a lot of ways to go about your scenario, if you need some help from the Microsoft community, you can get a lot of help on Microsoft Q&A.
Update based on the comments:
In this case, the devices are connected to IoT Hub. You can use the Service SDK to run a job that fires a Direct Method to all currently connected devices. This doc describes the process.

Azure IoT Hub Device Identity requirements

I need to connect some sensors to an Azure IoT Edge Runtime via MQTT.
I read here:How an IoT Edge device can be used as a gateway , that in the "Transparent" Pattern, devices who hold their own IoT Hub device identity can communicate directly with Azure IoT Edge via MQTT.
I am still in the planning phase and don't have the sensors (or Iot Hub devices) at the moment so I couldn't really start testing directly. I wanted to know if all devices/sensors can hold their IoT Hub device identity and if there are any hardware requirements in order to do so?
Thank you very much in advance!
In the transparent gateway case, the requirements for devices / sensors are the same as if the device would connect directly to an IOTHub using its identity. That is, if the device or sensor supports to Azure IOTHub via MQTT, it should work through the transparent gateway. When configuring the device, instead of using a connection string for the Azure IOTHub itself, you'd use a connection string that references the local Edge gateway.
There are 3 basic steps to take in the transparent gateway scenario - the article you linked steps into them, but I'll add in some color for 2 and 3.
Set up the gateway for connectivity from the downstream devices & routing to the upstream IOTHub. This article has good details.
For each device, create an identity in Azure IOTHub, using the device's unique ID (for example, device EUI for a lorawan sensor) as the IOTHub DeviceId, and set up auth per this article. This step is where you determine the Edge gateway connection string.
Connect the downstream device to the gateway device and start sending messages. That's this article. This is obviously dependent on the device itself and the operating code/configs (whether a 3rd party black box type device or something running your own code).

Is it possible to subscribe to Azure IOT Edge Device

Hopefully a simple question, but with all the reading I have done about IOT Edge Devices, I still cannot find an answer.
For my application, I would like to have a local offline view of all the data going into the edge device and an online view from a website. Is it possible to subscribe to all the events in the Edge Device, just like how I am able to subscribe to all the events in the IOT Hub?
Hopefully something like this
Device->IOTEdge->IOTHub->Website
_______________->Local View (offline)
From what I have seen I can use the components to create a website and do this.
If you need a local Azure IoT Edge webpage dashboard then look at Sander van de Velde blog for details and ideas. Sander has also a lot of other very good examples.
https://sandervandevelde.wordpress.com/2018/12/07/create-your-own-local-azure-iot-edge-dashboard/
https://sandervandevelde.wordpress.com/2018/04/20/visualizing-azure-iot-edge-using-local-dashboard/
You just need one nodejs module listening messages from edgeHub and sending messages using websocket connection. Then you can use same or another module to serve static webpage aka your dashboard. You can access this local dashboard from the same local network without any connection to internet. And you can also send your messages to upstream (IoTHub in cloud) and do the same there. I have used nodejs websocket locally in the edge and SignalR to stream data to cloud dashboards.