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