Skip to content

Commit 655f5b8

Browse files
committed
v1.0.1
0 parents  commit 655f5b8

16 files changed

+1657
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.vscode

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 MiniIot
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
## 官网地址
2+
http://www.miniiot.top
3+
4+
## 示例代码(esp8266)
5+
```c++
6+
// 登录控制台与查看文档请访问官网:http://www.miniiot.top
7+
8+
// 当前程序版本(仅用于后台展示)
9+
#define APP_VERSION "2504231612"
10+
11+
// 默认WIFI配置(出厂设置)
12+
#define DEFAULT_WIFI_SSID "Tenda_375160章"
13+
#define DEFAULT_WIFI_PASSWORD "87472998"
14+
15+
// 打印日志(建议调试完成后注释掉)
16+
#define MiniIot_DEBUG_LOG
17+
18+
// 导入miniiot
19+
#include <MiniIot.h>
20+
21+
22+
int num = 0;
23+
24+
void addNum(){
25+
// 上报属性
26+
MiniIot.propertyPost("num_1", num);
27+
num++;
28+
}
29+
30+
// 业务回调函数
31+
void ServiceCallbackFunction(JsonObject dataObj)
32+
{
33+
// 所有参数默认都是以String类型返回,需要自行转换成目标类型
34+
// json库使用ArduinoJson
35+
String serviceName = dataObj["serviceName"].as<String>();
36+
37+
// Ping
38+
if(serviceName == "miniiot_ping"){
39+
addNum();
40+
}
41+
42+
// 测试服务(解析参数)
43+
if(serviceName == "test"){
44+
Serial.print("参数a1:");Serial.println(dataObj["serviceParams"]["a1"].as<String>());
45+
Serial.print("参数a2:");Serial.println(dataObj["serviceParams"]["a2"].as<String>());
46+
Serial.print("参数a3:");Serial.println(dataObj["serviceParams"]["a3"].as<String>());
47+
Serial.print("参数a4:");Serial.println(dataObj["serviceParams"]["a4"].as<String>());
48+
Serial.print("参数a5:");Serial.println(dataObj["serviceParams"]["a5"].as<String>());
49+
}
50+
}
51+
52+
53+
54+
void setup()
55+
{
56+
Serial.begin(115200);
57+
58+
// 使用产品密钥初始化MiniIot,(产品ID,产品密钥)
59+
// 设备不存在会自动注册添加设备
60+
MiniIot.begin("ZnnQmFTH", "h5Tmn1l3m2S9DY2I");
61+
62+
// 使用设备密钥初始化MiniIot,(产品ID,设备ID,设备密钥)
63+
// 必须现在平台上添加设备
64+
// MiniIot.begin("ZnnQmFTH", "Ab79b2a5a3", "h5Tmn1l3m2S9DY2I");
65+
66+
// 绑定回调函数
67+
MiniIot.attach(ServiceCallbackFunction);
68+
}
69+
70+
void loop()
71+
{
72+
MiniIot.loop();
73+
74+
// 服务器连接成功
75+
if(MiniIot.running()){
76+
// 不能直接使用delay延时
77+
MiniIot.delay(3000);
78+
79+
Serial.printf("剩余内存: %dB\n", ESP.getFreeHeap());
80+
}
81+
}
82+
83+
84+
```

examples/EspTest_all/EspTest_all.ino

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// 登录控制台与查看文档请访问官网:http://www.miniiot.top
2+
3+
// 当前程序版本(仅用于后台展示)
4+
#define APP_VERSION "2504231612"
5+
6+
// 默认WIFI配置(出厂设置)
7+
#define DEFAULT_WIFI_SSID "Tenda_375160章"
8+
#define DEFAULT_WIFI_PASSWORD "87472998"
9+
10+
// 使用ip测试地址(预留私有部署与调试使用,不必理会)
11+
// #define MiniIot_MQTT_HOST_IS_IP
12+
// #define MiniIot_MQTT_HOST "192.168.0.192"
13+
// #define MiniIot_HTTP_HOST "192.168.0.192"
14+
15+
// 后台服务(用于上位机调试,开发测试中,建议关闭)
16+
// #define MiniIot_Admin_Service
17+
18+
// 打印日志(建议调试完成后注释掉)
19+
#define MiniIot_DEBUG_LOG
20+
21+
// 导入miniiot
22+
#include <MiniIot.h>
23+
// 定时任务(与miniiot无关,用于实现长按恢复出厂设置)
24+
#include <Ticker.h>
25+
26+
// 复用Boot按键用于恢复出厂设置
27+
#ifdef ESP8266
28+
#define SYS_RST_IO 0
29+
#endif
30+
31+
#ifdef ESP32
32+
#define SYS_RST_IO 9
33+
#endif
34+
35+
// 恢复出厂设置计数(秒)
36+
int sys_rst_count = 0;
37+
38+
int num = 0;
39+
40+
Ticker TickerRST;
41+
42+
43+
// 按5秒开发板上的按钮恢复出厂设置
44+
void SysRstfun()
45+
{
46+
if (digitalRead(SYS_RST_IO) == LOW)
47+
{
48+
sys_rst_count++;
49+
}
50+
else
51+
{
52+
sys_rst_count = 0;
53+
}
54+
if (sys_rst_count >= 5)
55+
{
56+
// 格式化存储
57+
MiniIot.RESET();
58+
}
59+
}
60+
61+
62+
63+
void addNum(){
64+
// 上报属性
65+
MiniIot.propertyPost("num_1", num);
66+
num++;
67+
}
68+
69+
// 业务回调函数
70+
void ServiceCallbackFunction(JsonObject dataObj)
71+
{
72+
// 所有参数默认都是以String类型返回,需要自行转换成目标类型
73+
// json库使用ArduinoJson
74+
String serviceName = dataObj["serviceName"].as<String>();
75+
76+
// Ping
77+
if(serviceName == "miniiot_ping"){
78+
addNum();
79+
}
80+
81+
// 测试服务(解析参数)
82+
if(serviceName == "test"){
83+
Serial.print("参数a1:");Serial.println(dataObj["serviceParams"]["a1"].as<String>());
84+
Serial.print("参数a2:");Serial.println(dataObj["serviceParams"]["a2"].as<String>());
85+
Serial.print("参数a3:");Serial.println(dataObj["serviceParams"]["a3"].as<String>());
86+
Serial.print("参数a4:");Serial.println(dataObj["serviceParams"]["a4"].as<String>());
87+
Serial.print("参数a5:");Serial.println(dataObj["serviceParams"]["a5"].as<String>());
88+
}
89+
90+
Serial.printf("剩余内存: %dB\n", ESP.getFreeHeap());
91+
}
92+
93+
94+
95+
void setup()
96+
{
97+
Serial.begin(115200);
98+
99+
pinMode(SYS_RST_IO, INPUT_PULLUP);
100+
101+
// 绑定定时任务回调函数
102+
TickerRST.attach(1, SysRstfun);
103+
104+
// 使用产品密钥初始化MiniIot,(产品ID,产品密钥)
105+
// 设备不存在会自动注册添加设备
106+
MiniIot.begin("ZnnQmFTH", "h5Tmn1l3m2S9DY2I");
107+
108+
// 使用设备密钥初始化MiniIot,(产品ID,设备ID,设备密钥)
109+
// 必须现在平台上添加设备
110+
// MiniIot.begin("ZnnQmFTH", "Ab79b2a5a3", "h5Tmn1l3m2S9DY2I");
111+
112+
// 绑定回调函数
113+
MiniIot.attach(ServiceCallbackFunction);
114+
115+
Serial.printf("剩余内存: %dB\n", ESP.getFreeHeap());
116+
Serial.print("cpu运行频率:");Serial.println(ESP.getCpuFreqMHz());
117+
Serial.print("当前固件大小:");Serial.println(ESP.getSketchSize());
118+
Serial.print("剩余固件空间:");Serial.println(ESP.getFreeSketchSpace());
119+
120+
}
121+
122+
void loop()
123+
{
124+
MiniIot.loop();
125+
126+
// 服务器连接成功
127+
if(MiniIot.running()){
128+
// 不能直接使用delay延时
129+
MiniIot.delay(3000);
130+
131+
Serial.printf("剩余内存: %dB\n", ESP.getFreeHeap());
132+
}
133+
}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// 登录控制台与查看文档请访问官网:http://www.miniiot.top
2+
3+
// 当前程序版本(仅用于后台展示)
4+
#define APP_VERSION "2504231612"
5+
6+
// 默认WIFI配置(出厂设置)
7+
#define DEFAULT_WIFI_SSID "Tenda_375160章"
8+
#define DEFAULT_WIFI_PASSWORD "87472998"
9+
10+
// 打印日志(建议调试完成后注释掉)
11+
#define MiniIot_DEBUG_LOG
12+
13+
// 导入miniiot
14+
#include <MiniIot.h>
15+
16+
17+
int num = 0;
18+
19+
void addNum(){
20+
// 上报属性
21+
MiniIot.propertyPost("num_1", num);
22+
num++;
23+
}
24+
25+
// 业务回调函数
26+
void ServiceCallbackFunction(JsonObject dataObj)
27+
{
28+
// 所有参数默认都是以String类型返回,需要自行转换成目标类型
29+
// json库使用ArduinoJson
30+
String serviceName = dataObj["serviceName"].as<String>();
31+
32+
// Ping
33+
if(serviceName == "miniiot_ping"){
34+
addNum();
35+
}
36+
37+
// 测试服务(解析参数)
38+
if(serviceName == "test"){
39+
Serial.print("参数a1:");Serial.println(dataObj["serviceParams"]["a1"].as<String>());
40+
Serial.print("参数a2:");Serial.println(dataObj["serviceParams"]["a2"].as<String>());
41+
Serial.print("参数a3:");Serial.println(dataObj["serviceParams"]["a3"].as<String>());
42+
Serial.print("参数a4:");Serial.println(dataObj["serviceParams"]["a4"].as<String>());
43+
Serial.print("参数a5:");Serial.println(dataObj["serviceParams"]["a5"].as<String>());
44+
}
45+
}
46+
47+
48+
49+
void setup()
50+
{
51+
Serial.begin(115200);
52+
53+
// 使用产品密钥初始化MiniIot,(产品ID,产品密钥)
54+
// 设备不存在会自动注册添加设备
55+
MiniIot.begin("ZnnQmFTH", "h5Tmn1l3m2S9DY2I");
56+
57+
// 使用设备密钥初始化MiniIot,(产品ID,设备ID,设备密钥)
58+
// 必须现在平台上添加设备
59+
// MiniIot.begin("ZnnQmFTH", "Ab79b2a5a3", "h5Tmn1l3m2S9DY2I");
60+
61+
// 绑定回调函数
62+
MiniIot.attach(ServiceCallbackFunction);
63+
}
64+
65+
void loop()
66+
{
67+
MiniIot.loop();
68+
69+
// 服务器连接成功
70+
if(MiniIot.running()){
71+
// 不能直接使用delay延时
72+
MiniIot.delay(3000);
73+
74+
Serial.printf("剩余内存: %dB\n", ESP.getFreeHeap());
75+
}
76+
}

keywords.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
MiniIot KEYWORD1
3+
4+
5+
begin KEYWORD2
6+
attach KEYWORD2
7+
propertyPost KEYWORD2
8+
eventPost KEYWORD2
9+
loop KEYWORD2
10+
RESET KEYWORD2
11+
12+
13+
APP_VERSION KEYWORD3
14+
DEFAULT_WIFI_SSID KEYWORD3
15+
DEFAULT_WIFI_PASSWORD KEYWORD3
16+
MiniIot_MQTT_HOST_IS_IP KEYWORD3
17+
MiniIot_MQTT_HOST KEYWORD3

library.properties

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=miniiot
2+
version=1.0.1
3+
author=天才小坑Bee
4+
5+
sentence=用于将esp8266、ESP32设备连接到www.miniiot.top物联网平台。
6+
paragraph=详细文档请访问www.miniiot.top。
7+
category=Other
8+
url=https://github.com/miniiot/miniiot-arduino.git
9+
architectures=esp8266,esp32
10+
depends=PubSubClient(>=2.8.0),ArduinoJson(>=7.4.1)

0 commit comments

Comments
 (0)