esp-at application: AT+MQTT docking with Amazon cloud

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:

  1. 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
  2. Select Ohio as your region
  3. Note how to activate certificates described in the developer guide
  4. Read AWS IoT Developer Guide repeatedly to deeper understanding

MQTT Integration into AWS IoT based on Two-Way Authentication

Replace Certificate
  • AmazonRootCA1.pem replaces components/customized_partitions/raw_data/mqtt_ca/mqtt_ca.crt
  • xxx.cert.pem replaces components/customized_partitions/raw_data/mqtt_cert/mqtt_client.crt
  • xxx.private.key replaces components/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:

  1. If the second parameter of AT+MQTTUSERCFG is 4, it is authenticated by both sides and cannot be changed.
  2. In AT+MQTTCONN=0,"<endpoint>",8883,1, endpoint is the endpoint in preparation phase, and port 8883 cannot be changed
  3. Other AT+MQTT parameters are user-definable

Example LOG

LOG for normal interaction is as follows:

  • LOG on ESP32 side
    Add description here
  • LOG on AWS side
    Add description here
发布了60 篇原创文章 · 获赞 79 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/espressif/article/details/105045610
今日推荐