3286 views|0 replies

96

Posts

0

Resources
The OP
 

Micropython for esp8266 upload temperature to OneNet platform [Copy link]

 
This post was last edited by youxinweizhi on 2018-3-27 15:32 OneNet: An IoT open platform under China Mobile (you will know it by searching Baidu) Here is a rendering: Set threshold alarm Step 1: Register an account (there are relevant posts in the forum) Step 2: Get DeviceID and Api_Key after adding the application Step 3: Import modules (import urequests (download it yourself), import Http_Put_Onenet (see below)) Create a new py file and name it Http_Put_Onenet.py import network import json import urequests class Http_Put_Onenet(object): def __init__(self,device,api_key): self.device = device self.api_key=api_key def put(self, put_data,put_name): url='http://api.heclouds.com/devices/' + self.device + '/datapoints' values={'datastreams':[{"id":put_name,"datapoints":[{"value": put_data}]}]} jdata = json.dumps(values) r=urequests.post(url,data=jdata,headers={"api-key": self.api_key}) return r.json()['error'] Step 4: Edit the main file import Http_Put_Onenet import utime DeviceID='xxxxxx' Api_Key='xxxxxxxxxxxx' data = Http_Put_Onenet.Http_Put_Onenet(DeviceID,Api_Key) while 1: one.put(get the temperature value,'the name displayed on the page') utime.sleep(60) This content is originally created by EEWORLD forum user youxinweizhi. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list