浏览曲线的地址,
www.yeelink.net/devices/344832
下一步就是周期提交了,同时又参考了xukai871105大神的树莓帖子
http://blog.csdn.net/xukai871105/article/details/38349519
#!/usr/bin/env python # -*- coding: utf-8 -*- import requests import json import time def main(): fileRecord = open("result.txt", "w") fileRecord.write("connect to yeelink\r\n"); fileRecord.close() while True: # 打开文件 file = open("/sys/class/thermal/thermal_zone0/temp") # 读取结果,并转换为浮点数 temp = float(file.read()) # 关闭文件 file.close() # 设备URI apiurl = 'http://api.yeelink.net/v1.0/device/344832/sensor/383501/datapoints' # 用户密码, 指定上传编码为JSON格式 apiheaders = {'U-ApiKey': 'a0ff0c16029821a7b8f7a75e99', 'content-type': 'application/json'} # 字典类型数据,在post过程中被json.dumps转换为JSON格式字符串 {"value": 48.123} payload = {'value': temp} #发送请求 r = requests.post(apiurl, headers=apiheaders, data=json.dumps(payload)) # 向控制台打印结果 fileRecord = open("result.txt", "a") strTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) fileRecord.writelines(strTime + "\r\n") strTemp = "temp : %.1f" %temp + "\r\n" fileRecord.writelines(strTemp) fileRecord.writelines(str(r.status_code) + "\r\n") fileRecord.close() time.sleep(60) if __name__ == '__main__': main()
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
Buck电路工作在CCM模式下电感电流的计算公式是什么?被打赏5分 | |
buck电路工作原理被打赏5分 | |
基于MSPM0L1306的MODBUS-RTU协议通讯实验被打赏50分 | |
每周了解几个硬件知识+485硬件知识分享被打赏10分 | |
【换取手持示波器】树莓派PICOW网页烟花被打赏18分 | |
【换取手持示波器】树莓派PICO逻辑分析仪被打赏16分 | |
【分享评测,赢取加热台】教你五分钟本地部署蒸馏版本的DeepSeekR1-7B被打赏12分 | |
【换取手持示波器】蓝牙音箱更换电池被打赏8分 | |
【换取手持示波器】鼠标更换微动开关被打赏10分 | |
【我要开发板】4.传感器移植被打赏50分 |