littlebot
Published on 2025-04-11 / 1 Visits
0

【源码】基于物联网和AWS的任务提醒系统

项目简介

本项目构建了一个借助 Amazon Web Service 和 IOT 设备的任务提醒系统,当用户错过任务或任务临近时,会通过邮件或短信的形式向用户发送提醒。系统的独特之处在于具备学习算法,可根据用户使用习惯学习激活日程。

项目的主要特性和功能

  1. 自动提醒:在任务临近或错过时,自动向用户发送邮件或短信提醒。
  2. 自学习功能:设备和服务器均有算法,能基于用户使用模式学习事件日程。
  3. 低功耗运行:采用超低功耗设计,可实现多年电池续航。
  4. 安全通信:使用 MQTT 进行通信,并通过 SSL 双向认证保障通信安全。
  5. 事件记录与存储:设备记录用户事件并将时间戳发送到服务器,事件存储在时间序列数据库中。

安装使用步骤

硬件准备

购买使用 ESP32 C3 微控制器的产品,准备好 ESP32 devkit M1 作为原型开发板。

软件配置

  1. AWS 账户:确保拥有 AWS 账户,用于连接微控制器。
  2. MQTT 客户端服务器设置:
    • 使用 ESP32 sdk 文件夹中的 station 示例连接到家庭网络,在 station_example_main.c 中修改 Wi - Fi 的 SSID 和密码。
    • 参考 SSL_mutual_auth 进行 MQTT 安全认证。
  3. TLS 证书设置:
    • 参考以下链接创建证书:
    • http://www.steves-internet-guide.com/install-mosquitto-linux/
    • http://www.steves-internet-guide.com/creating-and-using-client-certificates-with-mqtt-and-mosquitto/
    • 按照以下步骤生成 CA 密钥、服务器证书和客户端证书,并进行相应配置:
    • 生成 CA 密钥:openssl genrsa -des3 -out ca.key 2048
    • 生成 CA 证书:openssl req -new -x509 -days 1826 -key ca.key -out ca.crt
    • 生成服务器密钥:openssl genrsa -out server.key 2048
    • 生成服务器 CSR:openssl req -new -out server.csr -key server.key
    • 创建服务器证书:openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 10000
    • 复制服务器证书到 Ubuntu 服务器:
      • sudo cp server.crt /etc/mosquitto/certs/
      • sudo cp server.key /etc/mosquitto/certs/
      • sudo cp ca.crt /etc/mosquitto/certs/
    • 编辑 /etc/mosquitto/mosquitto.conf 确保证书路径正确。
    • 生成客户端密钥:openssl genrsa -out client.key 2048
    • 生成客户端 CSR:openssl req -new -out client.csr -key client.key
    • 创建客户端证书:openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 800
    • 复制 CA.crt、Client.crt 和 Client.key 到 ESP32 项目主文件夹。
    • 编辑 CMAKELists.txt 包含证书文件。
  4. 启动 Mosquitto 代理:sudo mosquitto -c /etc/mosquitto/mosquitto.conf
  5. 测试 Mosquitto 代理:
    • 订阅消息:mosquitto_sub -C 1 -v --cafile ca.crt --cert client.crt --key client.key -d -h xxx.xxx.xxx.xxx -p 8883 -t /test_topic --insecure
    • 发布消息:mosquitto_pub --cafile ca.crt --cert client.crt --key client.key -d -h xxx.xxx.xxx.xxx -p 8883 -t /test_topic -m "alert d" --insecure
  6. 编译并运行 MQTT 示例代码:连接串口终端,设置波特率为 15200,查看 MQTT 连接日志。

下载地址

点击下载 【提取码: 4003】【解压密码: www.makuang.net】