Git Product home page Git Product logo

esp32-aws-iot's Introduction

ESP32 AWS IOT 发布/订阅 示例

这是一个适用于 ESP-IDF 中AWS IoT C SDK 的 “subscribe_publish”示例。

AWS IOT 配置

在运行工程前,我们需要正确配置 AWS IOT :

  • 正确配置 esp-iot-solution 和 示例工程
    • 拉取最新的 esp-iot-solution
    • 保证能够正确编译一个工程
  • 正确配置 AWS 事物模块:事物、证书、策略
    • 我们可以根据AWS IoT Developer Guide,从登录 AWS IOT 控制台 这一步,一直配置到 配置您的设备这步,之后再进行下面的配置

    • 安装私钥和证书

      添加 *.pem.key*.pem.crt 文件到 main/cert 目录中,并重命名为private.pem.keycertificate.pem.crt

    • 设置 AWS 端点主机名

      您的 AWS IOT 帐户具有唯一终端主机名。要找到它,请打开 AWS IOT 控制台,然后单击左下方的“设置”按钮。端点主机名显示在此页面的“自定义端点”标题下。

      之后我们在电脑终端运行make menuconfig并进入component config->Amazon Web Service IoT Config->AWS IoT MQTT Hostname,在这里我们输入上一步找到的主机名。

    • 设置客户端 ID

      在电脑终端中运行make menuconfig,在example configuration下,设置 AWS IOT Client ID的值

    • 本地验证证书是否配置正确

      运行openssl s_client -showcerts -connect hostname:8883 < /dev/null命令去验证证书是否正确

监视来自设备的数据

下载完这个工程之后,程序会自动连接 AWS 并开始订阅/发布数据。

这个工程会发布数据到test_topic/node1主题,在 AWS 中提供了一个用于测试订阅/发布数据的接口:

  • 在 AWS IOT 控制里,点击右上角的“MQTT Client”。
  • 点击“Generate Client ID去生成一个随机 ID。
  • 点击”Connect”

在连接成功后,我们可以订阅 ESP32 发布的数据:

  • 点击"Subscribe to Topic"
  • 在"Subscription Topic"中输入test_topic/node1
  • 点击"Subscribe"

我们可以看到正在运行的示例中发布的 MQTT 数据。

发布数据返回到设备:

  • 点击"Publish to Topic"
  • 在"Publish Topic"中输入test_topic/node2
  • 在有效负载字段中输入消息
  • 点击“Publish”

esp32-aws-iot's People

Contributors

infiniteyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

eingbol qqhengg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.