Created
May 12, 2016 09:32
-
-
Save tomconte/eef8c9bfb4434787672c303153eee500 to your computer and use it in GitHub Desktop.
This is a simple example showing how to use the [Paho MQTT Python client](https://eclipse.org/paho/clients/python/) to send data to Azure IoT Hub. You need to assemble the rights credentials and configure TLS and the MQTT protocol version appropriately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import paho.mqtt.publish as publish | |
import paho.mqtt.client as mqtt | |
import ssl | |
auth = { | |
'username':"ciscohackhub.azure-devices.net/lora1", | |
'password':"SharedAccessSignature sr=ciscohackhub.azure-devices.net%2Fdevices%2Flora1&sig=xxxx&se=1463048772" | |
} | |
tls = { | |
'ca_certs':"/etc/ssl/certs/ca-certificates.crt", | |
'tls_version':ssl.PROTOCOL_TLSv1 | |
} | |
publish.single("devices/lora1/messages/events/", | |
payload="hello world", | |
hostname="ciscohackhub.azure-devices.net", | |
client_id="lora1", | |
auth=auth, | |
tls=tls, | |
port=8883, | |
protocol=mqtt.MQTTv311) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment