连接wolkabout物联网平台的python 3库
wolk-connect的Python项目详细描述
██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ██╗███╗ ██╗███████╗ ██████╗████████╗ ██║ ██║██╔═══██╗██║ ██║ ██╔╝██╔════╝██╔═══██╗████╗ ██║████╗ ██║██╔════╝██╔════╝╚══██╔══╝ ██║ █╗ ██║██║ ██║██║ █████╔╝ ██║ ██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ██║ ██║ ██║███╗██║██║ ██║██║ ██╔═██╗ ██║ ██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██║ ██║ ╚███╔███╔╝╚██████╔╝███████╗██║ ██╗╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗╚██████╗ ██║ ╚══╝╚══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ██████╗ ██╗ ██╗████████╗██╗ ██╗ ██████╗ ███╗ ██╗ ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║ ██║██╔═══██╗████╗ ██║ █████╗██████╔╝ ╚████╔╝ ██║ ███████║██║ ██║██╔██╗ ██║ ╚════╝██╔═══╝ ╚██╔╝ ██║ ██╔══██║██║ ██║██║╚██╗██║ ██║ ██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
wolkabout python连接器库,用于将设备连接到WolkAbout IoT Platform。
支持的设备通信协议:
- json_single
- JSON协议
注意:固件更新当前不可用于json协议
先决条件
- Python3
安装
pip3 install wolk-connect
从源安装
使用以下命令从命令行克隆此存储库:
git clone https://github.com/Wolkabout/WolkConnect-Python.git
通过调用pip3 install -r requirements.txt
运行以下命令安装软件包:
pysetup.pyinstall
示例用法
与Wolkabout物联网平台建立连接
通过导入Simple-example-deviceTemplate.json在wolkabout物联网平台上创建设备。
此模板适合wolk_example.py,并演示发送温度传感器读数。
importwolk# Setup the device credentials which you received# when the device was created on the platformdevice=wolk.Device(key="device_key",password="some_password")# Pass your device and server information# Select formatting protocol: JSON_SINGLE (default) or JSON_PROTOCOL# defaults to secure connection to Demo instance - comment out host, port and ca_certwolk_device=wolk.WolkConnect(device,protocol=wolk.Protocol.JSON_SINGLEhost="api-demo.wolkabout.com",port=8883,ca_cert="path/to/ca.crt")wolk_device.connect()
增加传感器读数
wolk_device.add_sensor_reading("T",26.93)
数据发布策略
存储的传感器读数按需通过呼叫:
wolk_device.publish()
与平台断开连接
wolk_device.disconnect()
附加功能
wolkconnect python库集成了其他功能,可以充分发挥wolkabout物联网平台的潜力。阅读有关完整功能集示例HERE的更多信息。