浏览曲线的地址,
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电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 |