Python 和 Azure 物联网中心

标签 python azure mqtt azure-iot-hub

我有在 Raspberry Pi 上运行的 Python 代码。我需要使用普通 MQTT 协议(protocol)从我的 Python 代码连接到 Azure Iot Hub。

我无法使用库来连接到 IoT Hub。我正在寻找一种在 Python 和普通 MQTT 中执行此操作的方法。

有人知道如何做到这一点吗?

最佳答案

你可以引用我的另一个帖子Python MQTT connection to Azure Iot Hub .

作为RaspberryPi爱好者,我建议您可以尝试使用Azure IoT SDK for C来扩展Python,请参阅https://azure.microsoft.com/en-us/documentation/articles/iot-hub-device-sdk-c-intro/https://docs.python.org/2/extending/extending.html .

另一种选择是使用 Azure IoT SDK for NodeJS 创建服务器作为代理,用于监听 Python 推送消息并转发到 Azure IoTHub,请参阅 https://github.com/Azure/azure-iot-sdks/tree/master/node/device 。根据您的Respberry Pi版本,您需要从nodejs官网https://nodejs.org/en/download/下载合适的nodejs运行时,如下所示或通过在 Raspbian 操作系统上使用 sudo apt-get install nodejs

  1. Respberry Pi:ARMv6
  2. Respberry Pi 2:ARMv7

否则,将消息从设备发送到 Respberry PI 上的 Azure IoTHub 的简单方法是使用 Device Messaging REST APIs在Python中。

希望有帮助。谨致问候。

关于Python 和 Azure 物联网中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35479783/

相关文章:

Python pip安装cvxopt错误: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

python - 在 python 列表中找到前两个最大值的更多 pythonic 方法

python - 通过访问 token 连接到 Microsoft Graph

Android 持久的 MQTT 连接

python - 在 spark 版本 2.2.0 中使用 python(pyspark) 从 mqtt 获取数据流

mqtt - 为什么 HAProxy 在 TLS 握手结束时关闭与 HiveMQ MQTT 客户端的连接?

python - 将 BeautifulSoup 与多处理池映射一起使用时的递归深度错误

python - 将 FedEx express 网络服务与 python 集成

powershell - 检查 BlobStorage 中以 Powershell 中的字符串开头的文件名

python - 如何从 Azure blob 数据存储获取 Python pathlib 路径?