How to connect LoRaWAN gateway to Azure IoT (Edge) Hub? - azure

I'm trying to build a LoRaWAN Infrastructure using the Azure IoT Hub. For that I have set up an Azure IoT Edge on a virtual machine.
I want to connect gateways to that IoT Edge. How can I achieve this?
The infrastructure would look like something like this:
I don't want to run the IoT Edge Gateway on the gateways directly, as I would need to install docker on a gateway which is performance wise not ideal. Is this even the way it's intended to be used?

If I understood your question correctly, the LoRaWAN gateway needs to communicate with the IoT hub.
Now if you are referring to sending of telemetry data only as in LoRa node -> LoRa gateway -> Azure IoT hub, then there are options available to send it out directly from the gateway itself using IoT hub bindings. Have a look here for some examples.
Send telemetry data to Azure IoT hub
Here you need to write some code in the gateway that will accept data from LoRa node and relay it to the IoT hub.
However, if we aren't able to make much changes in the LoRaWAN gateway, the easiest solution is to send all data to a locally hosted webserver using Wi-Fi or something else and then in the webserver, we can have bindings to the IoT hub.
I have used the first option multiple times when using my LoRaWAN gateway as it had that flexibility to support message passthrough to Azure IoT hub based on some business logic.
Note: It was just a configuration change.

This might be useful to you: https://github.com/Azure/iotedge-lorawan-starterkit. It is a demo that uses IoT Edge with Lorawan though it might use specific hardware. You might be able to adapt it to your needs though.

Related

Azure IoT Edge Integration with Lora devices

I plan to purchase a Lora sensor and a Lora smart valve. I want to integrate those devices with my existing Azure IoT Edge device. I'd like to access the data from the sensor, run it through and IoT Edge ASA Module, and output a command to the smart valve.
Is that possible?
Is there a Lora Module i could deploy via IoT Hub that would give me access to Lora at the edge?
Any recommendations on hardware that will be required, assuming my Edge Device is Azure IoT running Windows IoT?
Yes, it's possible.
This module is an edge LoraWAN implementation to facilitate communication between Lora devices and IoT Hub. It comes with samples and hardware recommendations. With module routing you should be able to route messages to your own ASA module.
As for hardware recommendations, I think that question isn't really something for StackOverflow, but the GitHub page does come with some recommendations for your gateway.

How communicate between sensors and IoT Hub through Field Gateway? [duplicate]

In our scenario, we have a bunch of devices that communicate locally with a gateway. The gateway is responsible to aggregate events from the devices and send it to the cloud. It should also receive device configuration changes from the the cloud and transport it to the specific device.
Based on my reading I would think that this is actually a typical IoT Hub scenario. And we would very much like to use the device management, messaging and maybe even twins that IoT Hub provides.
However, the way the devices communicate is already implemented and shall not be changed. That means the devices themselves cannot create connections and provide IoT Hub credentials. This rules out using the azure-iot-protocol-gateway or similar.
We would rather need the gateway to act as a device that can act on behalf of other devices. The gateway would detect which devices are in his local network and subscribe to their topics (via MQTT or AMQP).
Is this even possible? Can devices send events or listen to Cloud-To-Device messages in place of other devices?
Your scenario is a perfect fit for Azure IoT Edge:
https://learn.microsoft.com/en-us/azure/iot-edge/
"Azure IoT Edge is an Internet of Things (IoT) service that builds on top of IoT Hub. This service is meant for customers who want to analyze data on devices, a.k.a. "at the edge", instead of in the cloud. By moving parts of your workload to the edge, your devices can spend less time sending messages to the cloud and react more quickly to changes in status."
And I would suggest that you use IoT Edge as an identity or protocol translation Gateway:
https://learn.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway
"Gateways in IoT solutions provide device connectivity and edge analytics to IoT devices that otherwise wouldn't have those capabilities. Azure IoT Edge can be used to satisfy all needs for an IoT gateway regardless of whether they are related to connectivity, identity, or edge analytics. "

Hosting an Azure IoT-HuB device client in the cloud

I'm working on a IoT-solution that includes some physical devices where we don't control the hardware, and all communication is done via API:s. I would still like to utilize Azure IoT-hub for the messaging and management of these devices.
My idea is to create I device client and that runs in the cloud and integrates with the IoT-hub and the API:s. Is this a feasible strategy or am I on the wrong path? If, not what is the appropriate resource in azure for spinning up the clients?
If your devices are not capable of directly connecting to your Azure IoT hub then you have some alternatives. Yes theoretically you could create a device in the cloud that talks to the real device and forwards that data to your IoT hub. There are a couple of other alternatives. You could use an Azure IoT Edge Gateway. This will connect to the IoT hub and can represent multiple devices. You create an Edge Gateway module that can talk to your devices which will allow you to pass on the data for transmission to the IoT hub. It has a plug in module type of architecture. A product called the Protocol Gateway performs a similar function which might also meet your needs.

Act for other devices on Azure IoT Hub

In our scenario, we have a bunch of devices that communicate locally with a gateway. The gateway is responsible to aggregate events from the devices and send it to the cloud. It should also receive device configuration changes from the the cloud and transport it to the specific device.
Based on my reading I would think that this is actually a typical IoT Hub scenario. And we would very much like to use the device management, messaging and maybe even twins that IoT Hub provides.
However, the way the devices communicate is already implemented and shall not be changed. That means the devices themselves cannot create connections and provide IoT Hub credentials. This rules out using the azure-iot-protocol-gateway or similar.
We would rather need the gateway to act as a device that can act on behalf of other devices. The gateway would detect which devices are in his local network and subscribe to their topics (via MQTT or AMQP).
Is this even possible? Can devices send events or listen to Cloud-To-Device messages in place of other devices?
Your scenario is a perfect fit for Azure IoT Edge:
https://learn.microsoft.com/en-us/azure/iot-edge/
"Azure IoT Edge is an Internet of Things (IoT) service that builds on top of IoT Hub. This service is meant for customers who want to analyze data on devices, a.k.a. "at the edge", instead of in the cloud. By moving parts of your workload to the edge, your devices can spend less time sending messages to the cloud and react more quickly to changes in status."
And I would suggest that you use IoT Edge as an identity or protocol translation Gateway:
https://learn.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway
"Gateways in IoT solutions provide device connectivity and edge analytics to IoT devices that otherwise wouldn't have those capabilities. Azure IoT Edge can be used to satisfy all needs for an IoT gateway regardless of whether they are related to connectivity, identity, or edge analytics. "

Azure IoT hub simple publish-subcribe communication

I’m new to Microsoft’s Azure IoT Hub and MQTT/AMQP communication in general and I am trying to establish simple communication between my raspberry pi and a Ubunutu VM running on my computer. I intended on using my pi by as a client to publish messages to a service running on my VM that simply echoes the message contents to std out. After reading all the literature on the Azure website/github page I’m having trouble figuring out the best way to do this. Is it possible to host a service on your local network? Are the iotHub service client samples on the SDK meant to be used as services or as clients intended to communicate with existing services on Azure (SQL databases, webserver, etc)? I was able to send messages to my IoT Hub portal with azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_mqtt.c sample but couldn’t figure out where to include the topic my message was getting published to. I would really appreciate any help/input.
Thanks
The Azure IoT device SDKs are meant to build device applications that will connect and communicate with the Azure IoT Hub service which lives in the Azure Cloud.
The Azure IoT service SDKs are meant to build applications that will be used to configure, monitor and interact with an instance of the Azure IoT Hub service running in the Azure Cloud.
If you are looking for a simple solution for establishing a local device to device or device to server communication leveraging MQTT, you can look into MQTT broker solutions out there.
Now if you want to leverage an IoT Cloud to manage devices, easily secure and authenticate them, upload telemetry to the Cloud at a high throughput and take advantage of advanced analytics services in the Cloud (Big Data, Machine Learning,...), then Azure IoT Hub is for you.
Azure IoT Hub is just a message channel, and it does not handle messages.
For device side (raspberry pi), you use a device SDK to send D2C messages with MQTT, and it works. For service side (Ubuntu VM), you need Event Hub SDK to receive D2C messages sent by raspberry pi (Why Event Hub? https://blogs.msdn.microsoft.com/zhqqitest/2017/03/18/do-not-make-it-a-mess-why-therere-so-many-endpoints-in-iot-hub/).
Also, IoT Hub supports MQTT on device side ONLY, that is to say, you cannot connect to IoT Hub with MQTT on service side (Ubuntu VM), but you need AMQP.
You may have another question, then what is the AMQP topic to listen for D2C messages on service side? It's /<compatibleName>/ConsumerGroups/<ConsumerGroups>/Partitions/<PartitionID>.
compatibleName: IoT Hub Event Hub-compatible name (what a mess :-S), you can find it from Azure portal (Endpoints – Built-in endpoints – Events)
ConsumerGroups: You can find it from Azure portal, $Default by default
PartitionID: Partition ID, you can get it when you connect to the Event Hub with AMQP, it's a number, ususally start from 0
If you don't want to call AMQP directly, you can simply use Event Hub SDK on Ubuntu VM with IoT Hub connection string (NOT Event Hub-compatible endpoint or Event Hub-compatible name, the Event Hub SDK will do that for you).

Resources