Skip to content

Commit 897645f

Browse files
committed
refactor(reTerminal): restructure E1001/E1002 code with framework pattern
- Reorganize code into 3 sections: User Config, Custom UI, Framework - Add EntityData struct and API functions (getEntity, getEntityById, etc.) - Move predefinitions before user code to fix compilation errors - Provide both dynamic and fixed layout examples for dashboards - Keep all original UI designs unchanged - Update README files for various examples
1 parent eebd792 commit 897645f

File tree

13 files changed

+1797
-1487
lines changed

13 files changed

+1797
-1487
lines changed

arduino/SeeedHADiscovery/examples/ButtonSwitch/README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A multi-click button detection example that creates three independent switches i
99
- **Long Press (>1s)**: Toggle Switch 3
1010
- Bidirectional control (button ↔ Home Assistant)
1111
- Real-time state synchronization
12+
- **WiFi Provisioning**: Web-based WiFi configuration (no hardcoded credentials needed)
1213

1314
## Hardware Requirements
1415

@@ -43,9 +44,22 @@ Install manually from [GitHub](https://github.com/limengdu/SeeedHADiscovery).
4344

4445
## Quick Start
4546

46-
### 1. Configure WiFi
47+
### 1. WiFi Configuration
4748

49+
**Option A: WiFi Provisioning (Recommended)**
50+
51+
WiFi provisioning is enabled by default. On first boot:
52+
1. Device creates AP hotspot: `Seeed_Button_AP`
53+
2. Connect your phone/computer to this AP
54+
3. Browser opens automatically, or navigate to `http://192.168.4.1`
55+
4. Select your WiFi network and enter password
56+
5. Device restarts and connects to your WiFi
57+
58+
**Option B: Hardcoded Credentials**
59+
60+
To use hardcoded credentials instead:
4861
```cpp
62+
#define USE_WIFI_PROVISIONING false
4963
const char* WIFI_SSID = "Your_WiFi_SSID";
5064
const char* WIFI_PASSWORD = "Your_WiFi_Password";
5165
```
@@ -56,7 +70,14 @@ const char* WIFI_PASSWORD = "Your_WiFi_Password";
5670
#define BUTTON_PIN D1 // Change if needed
5771
```
5872

59-
### 3. Upload and Connect
73+
### 3. ESP32-C5 5GHz WiFi (Optional)
74+
75+
To force a specific WiFi band on ESP32-C5:
76+
```cpp
77+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // or WIFI_BAND_MODE_2G_ONLY
78+
```
79+
80+
### 4. Upload and Connect
6081
6182
1. Select board: **XIAO ESP32C6** (or your board)
6283
2. Upload the sketch
@@ -105,8 +126,12 @@ const char* WIFI_PASSWORD = "Your_WiFi_Password";
105126
### WiFi connection fails
106127
- Verify SSID and password
107128
- Check WiFi signal strength
129+
- If using provisioning, ensure device is in AP mode
130+
131+
### Can't access provisioning page
132+
- Make sure you're connected to the device's AP
133+
- Try navigating manually to `http://192.168.4.1`
108134
109135
## License
110136
111137
Part of the SeeedHADiscovery library.
112-

arduino/SeeedHADiscovery/examples/ButtonSwitch/README_CN.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- **长按(>1秒)**:切换开关 3
1010
- 双向控制(按钮 ↔ Home Assistant)
1111
- 实时状态同步
12+
- **WiFi 配网**:网页配置 WiFi(无需硬编码凭据)
1213

1314
## 硬件要求
1415

@@ -43,9 +44,22 @@
4344

4445
## 快速开始
4546

46-
### 1. 配置 WiFi
47+
### 1. WiFi 配置
4748

49+
**方式 A:WiFi 配网(推荐)**
50+
51+
WiFi 配网默认启用。首次启动时:
52+
1. 设备创建 AP 热点:`Seeed_Button_AP`
53+
2. 将手机/电脑连接到此 AP
54+
3. 浏览器自动打开,或手动访问 `http://192.168.4.1`
55+
4. 选择你的 WiFi 网络并输入密码
56+
5. 设备重启并连接到你的 WiFi
57+
58+
**方式 B:硬编码凭据**
59+
60+
如需使用硬编码凭据:
4861
```cpp
62+
#define USE_WIFI_PROVISIONING false
4963
const char* WIFI_SSID = "你的WiFi名称";
5064
const char* WIFI_PASSWORD = "你的WiFi密码";
5165
```
@@ -56,7 +70,14 @@ const char* WIFI_PASSWORD = "你的WiFi密码";
5670
#define BUTTON_PIN D1 // 根据需要修改
5771
```
5872

59-
### 3. 上传并连接
73+
### 3. ESP32-C5 5GHz WiFi(可选)
74+
75+
在 ESP32-C5 上强制使用特定 WiFi 频段:
76+
```cpp
77+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // 或 WIFI_BAND_MODE_2G_ONLY
78+
```
79+
80+
### 4. 上传并连接
6081
6182
1. 选择开发板:**XIAO ESP32C6**(或你的开发板)
6283
2. 上传程序
@@ -105,8 +126,12 @@ const char* WIFI_PASSWORD = "你的WiFi密码";
105126
### WiFi 连接失败
106127
- 验证 SSID 和密码
107128
- 检查 WiFi 信号强度
129+
- 如使用配网,确保设备处于 AP 模式
130+
131+
### 无法访问配网页面
132+
- 确保已连接到设备的 AP
133+
- 尝试手动访问 `http://192.168.4.1`
108134
109135
## 许可证
110136
111137
SeeedHADiscovery 库的一部分。
112-

arduino/SeeedHADiscovery/examples/HAStateSubscribe/README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Receive and display entity states from Home Assistant on your device. Perfect fo
99
- Real-time state updates
1010
- Access to entity attributes (friendly name, unit, device class)
1111
- Dynamic entity configuration via HA interface
12+
- **WiFi Provisioning**: Web-based WiFi configuration (no hardcoded credentials needed)
1213

1314
## Use Cases
1415

@@ -41,20 +42,40 @@ Install manually from [GitHub](https://github.com/limengdu/SeeedHADiscovery).
4142

4243
## Quick Start
4344

44-
### 1. Configure WiFi
45+
### 1. WiFi Configuration
4546

47+
**Option A: WiFi Provisioning (Recommended)**
48+
49+
WiFi provisioning is enabled by default. On first boot:
50+
1. Device creates AP hotspot: `Seeed_StateDisplay_AP`
51+
2. Connect your phone/computer to this AP
52+
3. Browser opens automatically, or navigate to `http://192.168.4.1`
53+
4. Select your WiFi network and enter password
54+
5. Device restarts and connects to your WiFi
55+
56+
**Option B: Hardcoded Credentials**
57+
58+
To use hardcoded credentials instead:
4659
```cpp
60+
#define USE_WIFI_PROVISIONING false
4761
const char* WIFI_SSID = "your-wifi-ssid";
4862
const char* WIFI_PASSWORD = "your-wifi-password";
4963
```
5064
51-
### 2. Upload and Connect
65+
### 2. ESP32-C5 5GHz WiFi (Optional)
66+
67+
To force a specific WiFi band on ESP32-C5:
68+
```cpp
69+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // or WIFI_BAND_MODE_2G_ONLY
70+
```
71+
72+
### 3. Upload and Connect
5273

5374
1. Upload the sketch to your device
5475
2. Open Serial Monitor (115200 baud)
5576
3. Add device in Home Assistant
5677

57-
### 3. Configure Subscriptions in HA
78+
### 4. Configure Subscriptions in HA
5879

5980
1. Find your device in **Settings****Devices & Services**
6081
2. Click **Configure** on your device
@@ -142,7 +163,10 @@ if (temp && temp->hasValue() && temp->getFloat() > 28.0) {
142163
- Verify HA WebSocket connection
143164
- Check if entities exist in HA
144165

166+
### Can't access provisioning page
167+
- Make sure you're connected to the device's AP
168+
- Try navigating manually to `http://192.168.4.1`
169+
145170
## License
146171

147172
Part of the SeeedHADiscovery library.
148-

arduino/SeeedHADiscovery/examples/HAStateSubscribe/README_CN.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- 实时状态更新
1010
- 访问实体属性(友好名称、单位、设备类别)
1111
- 通过 HA 界面动态配置实体
12+
- **WiFi 配网**:网页配置 WiFi(无需硬编码凭据)
1213

1314
## 使用场景
1415

@@ -41,20 +42,40 @@
4142

4243
## 快速开始
4344

44-
### 1. 配置 WiFi
45+
### 1. WiFi 配置
4546

47+
**方式 A:WiFi 配网(推荐)**
48+
49+
WiFi 配网默认启用。首次启动时:
50+
1. 设备创建 AP 热点:`Seeed_StateDisplay_AP`
51+
2. 将手机/电脑连接到此 AP
52+
3. 浏览器自动打开,或手动访问 `http://192.168.4.1`
53+
4. 选择你的 WiFi 网络并输入密码
54+
5. 设备重启并连接到你的 WiFi
55+
56+
**方式 B:硬编码凭据**
57+
58+
如需使用硬编码凭据:
4659
```cpp
60+
#define USE_WIFI_PROVISIONING false
4761
const char* WIFI_SSID = "你的WiFi名称";
4862
const char* WIFI_PASSWORD = "你的WiFi密码";
4963
```
5064
51-
### 2. 上传并连接
65+
### 2. ESP32-C5 5GHz WiFi(可选)
66+
67+
在 ESP32-C5 上强制使用特定 WiFi 频段:
68+
```cpp
69+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // 或 WIFI_BAND_MODE_2G_ONLY
70+
```
71+
72+
### 3. 上传并连接
5273

5374
1. 上传程序到设备
5475
2. 打开串口监视器(115200 波特率)
5576
3. 在 Home Assistant 中添加设备
5677

57-
### 3. 在 HA 中配置订阅
78+
### 4. 在 HA 中配置订阅
5879

5980
1. 在 **设置** → **设备与服务** 中找到你的设备
6081
2. 点击设备上的 **配置**
@@ -142,7 +163,10 @@ if (temp && temp->hasValue() && temp->getFloat() > 28.0) {
142163
- 验证 HA WebSocket 连接
143164
- 检查实体是否存在于 HA 中
144165

166+
### 无法访问配网页面
167+
- 确保已连接到设备的 AP
168+
- 尝试手动访问 `http://192.168.4.1`
169+
145170
## 许可证
146171

147172
SeeedHADiscovery 库的一部分。
148-

arduino/SeeedHADiscovery/examples/LEDSwitch/README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Control an LED from Home Assistant via WiFi. This example demonstrates basic swi
88
- Real-time state feedback
99
- Support for both onboard and external LEDs
1010
- Configurable LED polarity (active high/low)
11+
- **WiFi Provisioning**: Web-based WiFi configuration (no hardcoded credentials needed)
1112

1213
## Hardware Requirements
1314

@@ -55,9 +56,22 @@ Install manually from [GitHub](https://github.com/limengdu/SeeedHADiscovery).
5556

5657
## Quick Start
5758

58-
### 1. Configure WiFi
59+
### 1. WiFi Configuration
5960

61+
**Option A: WiFi Provisioning (Recommended)**
62+
63+
WiFi provisioning is enabled by default. On first boot:
64+
1. Device creates AP hotspot: `Seeed_LED_AP`
65+
2. Connect your phone/computer to this AP
66+
3. Browser opens automatically, or navigate to `http://192.168.4.1`
67+
4. Select your WiFi network and enter password
68+
5. Device restarts and connects to your WiFi
69+
70+
**Option B: Hardcoded Credentials**
71+
72+
To use hardcoded credentials instead:
6073
```cpp
74+
#define USE_WIFI_PROVISIONING false
6175
const char* WIFI_SSID = "Your_WiFi_SSID";
6276
const char* WIFI_PASSWORD = "Your_WiFi_Password";
6377
```
@@ -78,7 +92,14 @@ For XIAO ESP32-C3 or external LED:
7892
#define LED_ACTIVE_LOW true
7993
```
8094
81-
### 4. Upload and Connect
95+
### 4. ESP32-C5 5GHz WiFi (Optional)
96+
97+
To force a specific WiFi band on ESP32-C5:
98+
```cpp
99+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // or WIFI_BAND_MODE_2G_ONLY
100+
```
101+
102+
### 5. Upload and Connect
82103

83104
1. Select board: **XIAO ESP32C6** (or your board)
84105
2. Upload the sketch
@@ -112,9 +133,12 @@ Access device status at: `http://<device_ip>/`
112133
### WiFi connection fails
113134
- Verify SSID and password
114135
- Check WiFi signal strength
115-
- Red LED will blink if connection fails
136+
- LED will blink if connection fails
137+
138+
### Can't access provisioning page
139+
- Make sure you're connected to the device's AP
140+
- Try navigating manually to `http://192.168.4.1`
116141

117142
## License
118143

119144
Part of the SeeedHADiscovery library.
120-

arduino/SeeedHADiscovery/examples/LEDSwitch/README_CN.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- 实时状态反馈
99
- 支持板载和外接 LED
1010
- 可配置 LED 极性(高电平/低电平有效)
11+
- **WiFi 配网**:网页配置 WiFi(无需硬编码凭据)
1112

1213
## 硬件要求
1314

@@ -55,9 +56,22 @@ GPIO 引脚 ---[220Ω]--- LED (+) --- LED (-) --- GND
5556

5657
## 快速开始
5758

58-
### 1. 配置 WiFi
59+
### 1. WiFi 配置
5960

61+
**方式 A:WiFi 配网(推荐)**
62+
63+
WiFi 配网默认启用。首次启动时:
64+
1. 设备创建 AP 热点:`Seeed_LED_AP`
65+
2. 将手机/电脑连接到此 AP
66+
3. 浏览器自动打开,或手动访问 `http://192.168.4.1`
67+
4. 选择你的 WiFi 网络并输入密码
68+
5. 设备重启并连接到你的 WiFi
69+
70+
**方式 B:硬编码凭据**
71+
72+
如需使用硬编码凭据:
6073
```cpp
74+
#define USE_WIFI_PROVISIONING false
6175
const char* WIFI_SSID = "你的WiFi名称";
6276
const char* WIFI_PASSWORD = "你的WiFi密码";
6377
```
@@ -78,7 +92,14 @@ const char* WIFI_PASSWORD = "你的WiFi密码";
7892
#define LED_ACTIVE_LOW true
7993
```
8094
81-
### 4. 上传并连接
95+
### 4. ESP32-C5 5GHz WiFi(可选)
96+
97+
在 ESP32-C5 上强制使用特定 WiFi 频段:
98+
```cpp
99+
#define WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY // 或 WIFI_BAND_MODE_2G_ONLY
100+
```
101+
102+
### 5. 上传并连接
82103

83104
1. 选择开发板:**XIAO ESP32C6**(或你的开发板)
84105
2. 上传程序
@@ -114,7 +135,10 @@ const char* WIFI_PASSWORD = "你的WiFi密码";
114135
- 检查 WiFi 信号强度
115136
- 如果连接失败,LED 会闪烁
116137

138+
### 无法访问配网页面
139+
- 确保已连接到设备的 AP
140+
- 尝试手动访问 `http://192.168.4.1`
141+
117142
## 许可证
118143

119144
SeeedHADiscovery 库的一部分。
120-

0 commit comments

Comments
 (0)