AT+MQTT Integration into AWS IoT
This article explains how to connect devices to AWS IoT
using AT
commands.
AT+MQTT
command description AT+MQTT Command Set
Preparation
Please refer to AWS IoT Developer Guide and obtain:
xxx.cert.pem
(device certificate)xxx.private.key
(private key)AmazonRootCA1.pem
(root CA certificate)xxx-ats.iot.us-east-2.amazonaws.com
(endpoint
)
Suggestion:
- All devices must have a device certificate, private key, and root CA certificate installed in order to communicate with
AWS IoT
. For details, please refer to AWS IoT Developer Guide - Select
Ohio
as your region - Note how to activate certificates described in the developer guide
- Read
AWS
IoT Developer Guide repeatedly to deeper understanding
MQTT
Integration into AWS IoT based on Two-Way Authentication
Replace Certificate
AmazonRootCA1.pem
replacescomponents/customized_partitions/raw_data/mqtt_ca/mqtt_ca.crt
xxx.cert.pem
replacescomponents/customized_partitions/raw_data/mqtt_cert/mqtt_client.crt
xxx.private.key
replacescomponents/customized_partitions/raw_data/mqtt_key/mqtt_client.key
Compile Flashing AT Firmware
Re-compile flashing AT
firmware as described in AT
README.md
Integrate AT+MQTT into AWS IoT Commands
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
Notes:
- If the second parameter of
AT+MQTTUSERCFG
is4
, it is authenticated by both sides and cannot be changed. - In
AT+MQTTCONN=0,"<endpoint>",8883,1
,endpoint
is theendpoint
in preparation phase, and port8883
cannot be changed - Other
AT+MQTT
parameters are user-definable
Example LOG
LOG
for normal interaction is as follows:
LOG
onESP32
side
LOG
onAWS
side