AT指令连接阿里云平台

1.复位 

AT+RST

2.设置为sta模式
AT+CWMODE=1

3. 开启SNTP服务器,8时域,SNTP服务器为阿里云域名

AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"

4. 连接wifi。"WIFI名称,"WIFI密码"

AT+CWJAP="AccessPoint","QsXf152130"

5. 配置 MQTT "username","passwd",注意最后两个""

AT+MQTTUSERCFG=0,1,"NULL","ESP8266TEST&hk4yOhar51x","ea87bcd36157636d950122fdac52a5111770e7f0c25d78f65ba3b353da6ee12e",0,0,""   

6. 配置MQTT"clientId"。注意每个逗号前面的\不能少,少了会返回error

AT+MQTTCLIENTID=0,"hk4yOhar51x.ESP8266TEST|securemode=2\,signmethod=hmacsha256\,timestamp=1663342093355|" 

7. 连接/查询 MQTT Broker,"mqttHostUrl

AT+MQTTCONN=0,"iot-06z00gv6z39bwjz.mqtt.iothub.aliyuncs.com",1883,1

至此,模块已经成功连接阿里云平台


**************************************************************************************************************

8.订阅主题,"格式"(产品-Topic类列表中复制粘贴)

AT+MQTTSUB=0,"/sys/gavk88e3djY/C6T6/thing/service/property/set",1
9.发布主题,"格式"(产品-Topic类列表中复制粘贴),"发布的文本"

AT+MQTTPUB=0,"/sys/gavk88e3djY/C6T6/thing/event/property/post",“test”,1,0

MQTT的连接参数可以在阿里云平台里面直接复制粘贴,不需要再使用配置软件去配置

10.发布物模型,"复制产品-Topic类列表-物模型通信Topic-属性上报发布一栏","物模型标识符"

AT+MQTTPUB=0,"/sys/hk4yOhar51x/ESP8266TEST/thing/event/property/post","{\"method\":\"thing.service.property.set\"\,\"id\":\"2012934115\"\,\"params\":{\"temperature\":16.6}\,\"version\":\"1.0.0\"}",1,0 

AT指令连接阿里云平台_第1张图片

  1. 下图为串口助手的发送记录: 
AT+RST

OK
WIFI DISCONNECT
s$ l溸| 刲鄚??l??c|幟??抺抍??#捏o'焏gn溿??c8淝d{l{lp??????dcg銃那
AT+MQTTPUB=0,"/sys/hk4yOhar51x/ESP8266TEST/thing/event/property/post","{\"method\":\"thing.service.property.set\"\,\"id\":\"2012934115\"\,\"params\":{\"temperature\":16.6}\,\"version\":\"1.0.0\"}",1,0

busy p...
+MQTTSUBRECV:0,"/sys/hk4yOhar51x/ESP8266TEST/thing/event/property/post_reply",113,{"code":200,"data":{},"id":"2012934115","message":"success","method":"thing.event.property.post","version":"1.0"}

OK

AT+MQTTPUB=0,"/sys/hk4yOhar51x/ESP8266TEST/thing/event/property/post","{\"method\":\"thing.service.property.set\"\,\"id\":\"2012934115\"\,\"params\":{\"temperature\":62.5\,\"humi\":66}\,\"version\":\"1.0.0\"}",1,0

busy p...
+MQTTSUBRECV:0,"/sys/hk4yOhar51x/ESP8266TEST/thing/event/property/post_reply",113,{"code":200,"data":{},"id":"2012934115","message":"success","method":"thing.event.property.post","version":"1.0"}

OK

你可能感兴趣的:(物联网,esp8266,mqtt,阿里云,云计算)