ESP8266使用AT命令上传数据到ONE NET(HTTP方式)

一、流程

  1. 设置STA模式
    AT+CWMODE=1

  2. 链接WIFI
    AT+CWJAP="xxx","xxx"

  3. 通过TCP链接ONE NET 平台
    AT+CIPSTART="TCP","183.230.40.33",80

  4. 进入透传模式
    AT+CIPMODE=1
    AT+CIPSEND

  5. 发送数据

    POST  /devices/xxxxx(你的device id)/datapoints?type=5 HTTP/1.1
    api-key:xxxxxx(你的api key)
    Host:api.heclouds.com
    Content-Length:10(注意这里的长度是下面body的长度)
    (注意两个\r\n)
    ,;data,25
    
  6. 收到回复的数据

    [14:17:17.434]收←◆HTTP/1.1 200 OK
    Date: Sat, 07 M
    [14:17:17.466]收←◆ay 2022 06:17:16 GMT
    Content-Ty
    [14:17:17.497]收←◆pe: application/json
    Content-Le
    [14:17:17.535]收←◆ngth: 26
    Connection: keep-alive
    [14:17:17.566]收←◆
    Server: Apache-Coyote/1.1
    Pra
    [14:17:17.598]收←◆gma: no-cache
    
    {"errno":0,"error":"succ"}
    

你可能感兴趣的:(ESP8266,ESP8266,ONENET)