Python MQTT connection to Azure Iot Hub

后端 未结 4 696
粉色の甜心
粉色の甜心 2020-12-20 06:55

I want to connect to Azure Iot Hub, with Python MQTT.

An username and SAS token is required by Iot Hub. This is my code:

import paho.mqtt.client as m         


        
4条回答
  •  庸人自扰
    2020-12-20 07:45

    As @FarukCelik said, there was no Azure IoT SDK for Python.

    However, per my experience, I think there are four practicable ways using the existing SDK for Azure IoTHub in Python.

    1. Using Azure IoT SDK for C to extending Python, you can try to refer to https://docs.python.org/2/extending/extending.html to implement it.
    2. Using Azure IoT SDK for Java as Jython package imported, you can try to refer to http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html to know how to do it.
    3. The similar to the second way, integrating IronPython with Azure IoT SDK for C#/.Net, please refer to http://ironpython.net/documentation/dotnet/.
    4. The Azure IoT SDK for NodeJS support MQTT via the same Eclipse project Paho for JavaScript Client, so I think you can try to refer to the source code of Azure NodeJS IoT SDK on GitHub to know how to correctly using paho Python client for Azure IoTHub.

    Meanwhile, there is a unoffical Python library for Azure IoTHub Device on GitHub https://github.com/bechynsky/AzureIoTDeviceClientPY. That you can concern about this project repository, but it's still on the deveploment stage by now.

    Hope it helps. Best Regards.

提交回复
热议问题