本文介绍如何通过 AT
指令对接亚马逊云(AWS IoT
).
AT+MQTT
指令说明参考 AT+MQTT 介绍
读者需根据 AWS IoT 开发指南, 获取:
xxx.cert.pem
(事物证书)xxx.private.key
(事物私钥)AmazonRootCA1.pem
(根证书)xxx-ats.iot.us-east-2.amazonaws.com
(endpoint
)建议:
AWS IoT
需要所有设备必须有事物证书, 事物私钥, 和根证书, 具体参考 AWS 文档Ohio
)AWS
文档, 加深印象MQTT
基于双向认证对接 AWS IoTAmazonRootCA1.pem
替换 components/customized_partitions/raw_data/mqtt_ca/mqtt_ca.crt
xxx.cert.pem
替换 components/customized_partitions/raw_data/mqtt_cert/mqtt_client.crt
xxx.private.key
替换 components/customized_partitions/raw_data/mqtt_key/mqtt_client.key
按照 AT
README.md 重新编译烧写 AT
固件
AT+CWMODE=1
AT+CWJAP="ssid","password"
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
AT+CIPSNTPTIME?
AT+MQTTUSERCFG=0,4,"esp32-at","espressif","1234567890",0,0,""
AT+MQTTCONN=0,"xxx-ats.iot.us-east-2.amazonaws.com",8883,1
AT+MQTTSUB=0,"esp32/at",1
AT+MQTTPUB=0,"esp32/at","hello aws!",1,0
注意:
AT+MQTTUSERCFG
中第二参数为 4
, 即双向认证, 不可更改AT+MQTTCONN=0,"",8883,1
中, endpoint
为准备阶段的 endpoint
, 端口 8883
不可更改AT+MQTT
参数, 由用户自定义正常交互 LOG
如下: