3 Star 13 Fork 3

朗少 / ESP32_LED_Serverless

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

输入图片说明

ESP32_LED_Serverless

介绍

用户通过小程序,远程给 ESP32 开发的 LED 屏幕下发轮播文本、广播的音频。初步设想用于面向一些商铺门面的 LED 广告,商户可以定时更改 LED 轮播的内容和播放的音频,实现门前语音播报,远程调整。在商铺打样时段,关闭 LED 低功耗待机。

软件架构

  1. 小程序开发采用 Taro 3.0 React 版本, 主要开发语言 TypeScript
  2. MCU 开发采用乐鑫 ESP32 模块,ESP-IDF v4.2 版本, 主要开发语言 C
  3. 设备通讯采用 腾讯云物联网 平台。
  4. 消息协议为 MQTT,数据结构采用 JSON 格式。
  5. 客户端向腾讯云物联网 API 请求的消息均通过 云开发中的云函数 实现。
  6. 客户端及设备数据全部储存在 云开发中的数据库 中。

安装教程

  1. # 小程序开发
    git clone https://gitee.com/junlan2013/esp32_led_serverless.git # 克隆工程
    cd esp32_led_serverless/WeChatMiniProgram/app                   # 进入Taro工程目录
    npm i
    npm run dev:weapp                                               # 开发 Go...
  2. # ESP32 开发
    # 部署 esp-idf
    # 参考 https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/get-started/index.html#id2

Topic 权限

序号 Topic 操作权限 说明
1 ${产品ID}/${deviceName}/text 订阅 下发轮播信息
2 ${产品ID}/${deviceName}/speak 订阅 下发音频信息

数据库设计

序号 集合名 说明 权限设置
1 DeviceGroup 设备分组 自定义
2 DeviceList 设备列表 自定义
3 DeviceMode 设备 Mode 所有用户可读
4 LedLogs LED 信息下方日志 仅创建者可读写
5 LedTask LED 任务列表 自定义
6 WeappConfig 配置信息 所有用户不可读写

数据库自定义安全规则

  • DeviceGroup
{
  "read": "doc._openid == auth.openid || auth.openid in get(`database.DeviceGroup.${doc._id}`).members",
  "write": "doc._openid == auth.openid"
}
  • DeviceList 和 LedLogs
{
  "read": "auth.openid in get(`database.DeviceGroup.${doc.groupId}`).members || auth.openid == get(`database.DeviceGroup.${doc.groupId}`)._openid",
  "write": "auth.openid in get(`database.DeviceGroup.${doc.groupId}`).members || auth.openid == get(`database.DeviceGroup.${doc.groupId}`)._openid"
}

关于 WeappConfig 集合

_id:SecretId
        value: "${腾讯云SecretId}"
_id:SecretKey
        value: "${腾讯云SecretKey}"
_id:ProductId
        value: "${腾讯云-物联网-ProductId}"

云函数API

  • 编译 TS 的 WeMqttApi 云函数
cd WeChatMiniProgram/app/cloud/TaroCloudSrc/WeMqttApi
npm i
gulp
  • 然后可以到 WeChatMiniProgram/app/cloud/functions 上传

小程序相关图片

主页-以及设备列表 设备分组 设备信息 添加设备前 添加设备时 设备文本下发 设备文本定时下发 小程序介绍

Empty file

About

腾讯《小程序云开发挑战赛》参赛作品。 expand collapse
TypeScript
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
TypeScript
1
https://gitee.com/chenqinglang/esp32_led_serverless.git
git@gitee.com:chenqinglang/esp32_led_serverless.git
chenqinglang
esp32_led_serverless
ESP32_LED_Serverless
master

Search