question

SureshAlbin-3891 avatar image
1 Vote"
SureshAlbin-3891 asked rkiss commented

Connect to IoT Central app directly MQTT without SDK

I would like to connect my devices to my IoT Central application directly using MQTT protocol without using any SDK. I found some official instructions on how to connect a device to IoT Hub directly with MQTT here: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support but I can't find anything similar for IoT Central.

I want to strictly avoid the usage of any language SDK and want to get this done directly using MQTT protocol. For testing purposes I'm using a general purpose MQTT toolbox called MQTTBox. I want to connect that tool to a device registered using a Device Capability Model on IoT Central and send test measurements with it. Can someone provide some instructions?

azure-iot-central
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SureshAlbin-3891 Just checking in to see if the below answer(s) helped.
If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.

0 Votes 0 ·

1 Answer

rkiss avatar image
2 Votes"
rkiss answered rkiss commented

Hi,

The MQTT device can be connected directly to the IoT Central App based on its device connection string which is necessary to generate in advance.

This link shows an example how to generate a necessary data for device connectivity to the IoT Central App, such as generating a hostname of the internal IoT Hub and the device sasToken.


The following screen snippet shows an example of the MQTT device11 connectivity using the MQTTBox client, where:

Host = iotc-954aeb54-6bdd-435e-8f71-49d8c712c89a.azure-devices.net:8883
Username = iotc-954aeb54-6bdd-435e-8f71-49d8c712c89a.azure-devices.net/device11/?api-version=2020-09-30&model-id=dtmi:rk2021iotcfree:abba1mg;2
Password = <sasToken>


57653-mqttboxclient.png


The next screen snippet shows a connected device11 to the IoT Central App and its published telemetry data:

57661-capture1.png


Another example of the connectivity MQTT device to the IoT Central App using a direct protocol is the Azure IoT Hub Tester:

57570-tool1.png



and finally, the following screen snippet shows a device11 dashboard on the IoT Central App:

57607-iotc1.png





Thanks
Roman



mqttboxclient.png (127.4 KiB)
capture1.png (109.4 KiB)
tool1.png (409.2 KiB)
iotc1.png (45.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

how to get username

0 Votes 0 ·
rkiss avatar image rkiss ChinmayNatu-5195 ·

have a look at the following docs to obtain an underlying IoT Hub hostname of the IoT Central App:

Using the MQTT protocol directly (as a device)
IoT Hub Device Provisioning Service: Runtime Registration

also my answer here.

Thanks
Roman


0 Votes 0 ·