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+RST
OK
WIFI DISCONNECT
s$ l溸| 刲鄚??l??c|幟??抺抍??#捏o'焏gn溿??c8淝d{l{lp??????dcg銃那?b岥go??l剣d`??ngl`'{嚊抧踕`p騨??s寽溿??#'????莄匊'o??l`??o'd`';菦搉鞗`p髈??{寽溿????#'銃??l那c岥'o??l`??ng??d'{嚊??儧揱;撣'冔揱
################################################
arch:ESP8266, 1
compile_time:Ai-Thinker|B&T
wifi_mac:e098068a38E7
sdk_version:v3.4-22-g967752e2
firmware_version:2.2.0
compile_time:Jun 30 2021 11:28:20
ready
################################################WIFI CONNECTED
WIFI GOT IP
AT+CWMODE=1
OK
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
OK
AT+CWJAP="AccessPoint","QsXf152130"
WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP
OK
AT+MQTTUSERCFG=0,1,“NULL”,“ESP8266TEST&hk4yOhar51x”,“ea87bcd36157636d950122fdac52a5111770e7f0c25d78f65ba3b353da6ee12e”,0,0,""
ERROR
AT+MQTTUSERCFG=0,1,"NULL","ESP8266TEST&hk4yOhar51x","ea87bcd36157636d950122fdac52a5111770e7f0c25d78f65ba3b353da6ee12e",0,0,""
OK
AT+MQTTCLIENTID=0,"hk4yOhar51x\.ESP8266TEST|securemode=2\,signmethod=hmacsha256\,timestamp=1663342093355|"
OK
AT+MQTTCONN=0,"iot-06z00gv6z39bwjz.mqtt.iothub.aliyuncs.com",1883,1
+MQTTCONNECTED:0,1,"iot-06z00gv6z39bwjz.mqtt.iothub.aliyuncs.com","1883","",1
OK
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