Skip to main content

aliyun iot client sdk

Project description


This is the iot module of Aliyun Python SDK.

Aliyun Python SDK is the official software development kit. It makes things easy to integrate your Python application, library, or script with Aliyun services.

This module works on Python versions:

2.6.5 and greater

Please visit

**python demo**

``` python
# -*- coding: utf-8 -*-
import aliyunsdkiotclient.AliyunIotMqttClient as iot
import ConfigParser
import json

config = ConfigParser.ConfigParser()'mqtt.cfg')

productKey = config.get('device', 'productKey')
deviceName = config.get('device', 'deviceName')
deviceSecret = config.get('device', 'deviceSecret')
clientId = config.get('device', 'clientId')

certPath = config.get('server', 'tslCertPath')
host = productKey + '.' + config.get('server', 'host')
port = config.getint('server', 'port')

def on_connect(client, userdata, flags_dict, rc):
print("Connected with result code " + str(rc))
# Subscribing in on_connect() means that if we lose the connection
topic = '/' + productKey + '/' + deviceName + '/data'
client.subscribe(topic, 0)

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
topic = '/' + productKey + '/' + deviceName + '/update'
data = {'pm25': 10, 'pm10': 30, 'deviceName': deviceName}
client.publish(topic, payload=json.dumps(data))

if __name__ == '__main__':
client = iot.getAliyunIotMqttClient(productKey, deviceName, deviceSecret, secure_mode=3)

client.on_connect = on_connect
client.on_message = on_message
client.connect(host=host, port=port, keepalive=60)


.. :changelog:

Release History

0.0.1 (2018-02-13)

0.0.5 (2018-02-23)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aliyun-python-sdk-iot-client, version 0.0.14
Filename, size File type Python version Upload date Hashes
Filename, size aliyun_python_sdk_iot_client-0.0.14-py2.py3-none-any.whl (7.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size aliyun-python-sdk-iot-client-0.0.14.tar.gz (6.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page