Reputation: 217
I have Python code running on a Raspberry Pi. I need to connect to Azure Iot Hub from my Python code by using plain MQTT protocol.
I cannot use the libraries for connecting to Iot Hub. I am looking for a way to do this in Python and plain MQTT.
Does anyone know how this can be done?
Upvotes: 1
Views: 4264
Reputation: 662
The Python SDK for Azure IoT Hub is now here: https://github.com/azure/azure-iot-sdk-python and natively supports MQTT
Upvotes: 0
Reputation: 183
The Python SDK for Azure IoT Hub has been released and should work to connect a Raspberry Pi to Azure IoT Hub.
See here:
https://github.com/Azure/azure-iot-sdks/tree/master/python/device
Upvotes: -1
Reputation: 24148
You can refer to my post for the other thread Python MQTT connection to Azure Iot Hub.
As a RaspberryPi fan, I suggest that you can try to extend Python with Azure IoT SDK for C, please see https://azure.microsoft.com/en-us/documentation/articles/iot-hub-device-sdk-c-intro/ and https://docs.python.org/2/extending/extending.html.
The other choice is that using the Azure IoT SDK for NodeJS to create a server as proxy for listening Python push messages and forwarding to Azure IoTHub, please see https://github.com/Azure/azure-iot-sdks/tree/master/node/device. And according to the version of your Respberry Pi, you need to download the suitable nodejs runtime as below from the nodejs offical website https://nodejs.org/en/download/ or via using sudo apt-get install nodejs
on the Raspbian OS.
Otherwise, the simple way for sending messages from device to Azure IoTHub on Respberry PI is that using the Device Messaging REST APIs in Python.
Hope it helps. Best Regards.
Upvotes: 2
Reputation: 812
I am not sure what you mean by plain MQTT protocol.
The main implementation of MQTT is Python is the Paho one: https://eclipse.org/paho/clients/python/
Have you tried that?
I have not used the Azure Iot Hub, but I would presume that it is possible to get a MQTT hostname, port, username and password, which would then be used to connect to it?
nick.
Upvotes: 0