Subscribing to device/module to cloud messages in Azure IoTHub

Hello,

Is there any guidance/tutorial on subscribing to device/module to cloud messages in Azure IoTHub?

I went through the Getting Started guide (https://www.losant.com/blog/getting-started-with-azure-iot-and-losant) but that one shows how to monitor cloud to device messages with the Losant side behaving as a device.

Instead, I want to be able to monitor messages coming from a device to Azure IoTHub and visualize them in Losant. I tried changing the subscribed topic to devices/{device id}/messages/events/ but I am not seeing any data in Losant.

Hi @Prince_Samuel,

Welcome to the Losant Forums! In that post you linked to, there is a section called “Receiving A Message From Azure”. That as the first part of this. If you set everything up like the tutorial, the topic is:

/devices/losant/messages/devicebound/#

Now, to actually save the data within Losant ( or we call it reporting state) you need to use the Device State Node in your Workflow.

More on state:

Please don’t hesitate to ask more questions. Happy to help further :slight_smile:

Thanks! That’s not what I want :slight_smile:

/devices/losant/messages/devicebound/# is for monitoring cloud to device messages.

I have my hardware device sending data to Azure IoTHub. I want to visualize this data in Losant. I.e monitor device to cloud messages.

@Prince_Samuel,

My apologies. Sorry about that, I read your message too fast.

So, I did some research to see if you could actually subscribe to the devices/{device_id}/messages/events/ topic. It looks like that’s not the case. Based on this:

https://social.msdn.microsoft.com/Forums/en-US/a0a1bcd4-6f58-4658-adee-0b863e19bdfe/how-do-i-subscribe-to-and-receive-mqtt-messages?forum=azureiothub

Generally, you can get data to Losant via MQTT or HTTP (via webhooks). This is where my Azure knowledge gets muddy and I’ll have to do some research. Here is where I am now:

It looks like you may be able to route device to cloud messages to other places. By default, they route the messages here:

But, it looks like that’s the AMQP. Losant doesn’t support that.

I may need some time to dig in more. But, one approach that I know will work is to trigger an Azure Function from IoTHub that can send the data to Losant via an HTTP Webhook.

Hopefully, this is enough to point you in the right direction. I’m going to ask internally so see if there are some other approaches. I’ll be sure to follow up if a better route is presented.

1 Like