基于 M5Stack StickCPlus 的多设备示例
| 技术方案 | Classic |
|---|---|
| 应用场景 | 家电与控制 |
本示例将 ESP RainMaker 与 M5StickCPlus 集成,帮助开发者和终端用户借助 M5Stack 的现成硬件轻松评估 RainMaker 功能,无需额外搭建电路或添加元器件。
概览
| 处理器 | ESP32 |
|---|---|
| 连接方式 | Wi-Fi + BLE |
| 供电电压 | 3.3V |
| IDF 版本 | ESP-IDF v5.1.4 |
可体验的功能
- 系统服务: ESP RainMaker 的系统服务支持远程执行设备的基本操作,如重启、重置 Wi-Fi 设置和恢复出厂设置。
- 时间服务: 时间对任何物联网设备都至关重要,尤其是在实现设备定时等功能时。
- 场景: 在 ESP RainMaker 中,场景可以为一个或多个设备预设特定的参数值,这些设备可以分布在不同节点上。触发场景后,相关设备将按照预设参数调整至对应状态。
- 定时: ESP RainMaker 的定时功能可按预设时间自动控制设备,提升便利性和能效。
- ESP Insights: 为开发者提供实时诊断和远程监控工具,高效调试、分析和维护已部署的 ESP32 设备。
- OTA 升级: 通过 OTA 升级为已部署的设备添加新功能并修复问题。
在真实开发板上体验
在 M5Stack 商店购买 M5StickC Plus 及配套模块,然后直接在本页烧录此示例。 选购 M5Stack
烧录并体验
选择部署
公共部署
由乐鑫托管,供评估使用。免费,无需任何部署。
设备设置说明
1. 准备工作
- Linux、macOS 或 Windows 电脑。
- M5 StickCplus。
- USB 数据线。
2. 连接设备
- 使用 USB 数据线将设备连接到电脑,然后点击终端上方左上角的
连接按钮。 - 选择正确的端口,然后点击
连接。 - 连接成功后,即可开始烧录设备。
3. 烧录设备
- 点击终端上方的
烧录设备,选择 擦除并烧录。等待erase_flash擦除过程完成后,再写入固件。 - 等待固件烧录完成。
- 看到
Leaving...时,即表示烧录成功。
4. 断开设备连接
- 点击终端上方的
断开连接按钮(仅需点击一次)。 - 关闭 M5 StickCplus 设备。
- 从电脑和设备上拔下 USB 数据线。
5. 开启设备
- 按下左侧按键开启 M5 StickCplus 设备,准备配网。
- 设备屏幕上将显示一个二维码。
6. 下载 ESP RainMaker 手机 App 并为设备配网
私有部署
您自己的 ESP RainMaker Classic 部署。请通过 Admin CLI 注册节点,而非 Dashboard。
- Register: With the ESP RainMaker Admin CLI, generate device certificates and register them with node_certs.csv.
- Load credentials: Zip the CLI batch folder (Mfg-…) or pick one node's .bin from its bin/ folder, and drop it into Device credentials.
- Flash: Write the firmware and the credentials in one pass. The board resets when done.
- Pair: Sign in to your private Classic deployment in the Home App, then add the device with the PoP from the console.
详细说明
1. Before you start
- A private ESP RainMaker Classic deployment (you need its deployment base URL and super-admin email from setup).
- The ESP RainMaker Admin CLI installed on your computer (esp-rainmaker-admin-cli).
- An ESP32-family DevKit that matches this example, a USB data cable, and Chrome or Edge.
2. Generate and register device certificates
- Follow the Admin CLI user guide. Set your deployment endpoint and log in:
python rainmaker_admin_cli.py account serverconfig --endpoint <your-deployment-base-url> python rainmaker_admin_cli.py account login --email <super-admin-email>
- Generate certificates for your boards (factory NVS images land under
bin/in the output folder):python rainmaker_admin_cli.py certs devicecert generate --count <n> --prov ble --outdir <outdir>
- Register them with the cloud using the batch's
common/node_certs.csv:python rainmaker_admin_cli.py certs devicecert register --inputfile <outdir>/<date>/Mfg-<no>/common/node_certs.csv
- Save the
request_idfrom the register command and check status when needed:python rainmaker_admin_cli.py certs devicecert getcertstatus --requestid <request_id>
- The output holds private keys. Keep it out of chats and repositories, and delete it when you are done.
3. Load the device credentials
- From the Admin CLI output folder, zip the
Mfg-<no>batch folder, or pick onebin/node-….binfile. - Drop that ZIP or
.binonto Device credentials above the console. It is read in your browser and never uploaded. - With the ZIP, pick the node for this board. Every board needs its own node: two boards with the same one connect as the same device.
- The credentials are flashed at
0x3F7000, where this example keeps itsfctrypartition.
4. Connect and flash
- Connect the board over USB, click
Connectabove the console and pick its port. - Click
Flash Deviceand choose Erase, then flash firmware + credentials. The firmware image goes to0x0and the credentials to0x3F7000in one pass, so the erase cannot wipe them. - The board resets when flashing is done. Type
get-node-idin the console when the firmware supports it: it prints the node you picked. - To give a board another node later, or restore one after a full erase, load the credentials and choose Credentials only. The firmware on the board is kept.
- To reflash only the firmware, choose Flash only. The credentials on the board are kept.
5. Sign in on your deployment
- In the Home App panel next to the console, sign in to your private ESP RainMaker Classic deployment (the base URL from your deployment setup).
- You can also use the ESP RainMaker phone app (iOS / Android); point it at the same deployment if your build supports a custom endpoint.
- Use a regular user account for day-to-day testing, not the super-admin account used with the Admin CLI.
6. Provision the device in the Home App
- Tap
+, choose I do not have a QR code, then Bluetooth. - In Chrome's Bluetooth window, pick the device whose name matches the one in the console, for example
PROV_ff7bf2. - Enter the PoP when asked. It is the
"pop"value in theQRCODE:line of the console, for example{"ver":"v1","name":"PROV_xxxxxx","pop":"xxxxxxxx","transport":"ble"}. - Pick your Wi-Fi network, enter its password and wait for provisioning to finish. The device then appears under My Devices.
- Control the device from the app.
仅支持烧录固件,烧录期间及烧录完成后均无法查看设备日志。
连接遇到问题?
- 确保设备已通过 USB 正确连接
- 检查是否已安装正确的驱动程序
- 尝试更换 USB 端口或数据线
- 确认设备已进入烧录模式
- 点击此处获取最新版 ESP RainMaker 手机 App