first commit
This commit is contained in:
1
blinker-library/examples/.pydio
Normal file
1
blinker-library/examples/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
9b049167-3861-4c6c-8f9d-1c25bd4db82d
|
||||
1
blinker-library/examples/Blinker_AT_Firmware/.pydio
Normal file
1
blinker-library/examples/Blinker_AT_Firmware/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
99d5c867-b417-41db-aabd-18079af026f8
|
||||
@@ -0,0 +1 @@
|
||||
b47b4b4a-42f8-4523-b8b4-5e2d1a0c25ec
|
||||
@@ -0,0 +1,58 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_AT_MQTT
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
Blinker.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_ArduinoJson/.pydio
Normal file
1
blinker-library/examples/Blinker_ArduinoJson/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
460dd916-2bf0-4bc1-a6f4-33b76b9e1c36
|
||||
@@ -0,0 +1 @@
|
||||
e70730c2-0822-43ad-a318-9ceee3c997a3
|
||||
@@ -0,0 +1,104 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void weatherData(const String & data)
|
||||
{
|
||||
BLINKER_LOG("weather: ", data);
|
||||
|
||||
DynamicJsonDocument jsonBuffer(1024);
|
||||
DeserializationError error = deserializeJson(jsonBuffer, data);
|
||||
JsonObject weather = jsonBuffer.as<JsonObject>();
|
||||
|
||||
if (error)
|
||||
{
|
||||
BLINKER_LOG(data, " , not a Json buffer!");
|
||||
}
|
||||
|
||||
String weather_text = weather["cond_txt"];
|
||||
int8_t weather_temp = weather["tmp"];
|
||||
|
||||
BLINKER_LOG("Local weather is: ", weather_text, " ,temperature is: ", weather_temp, "℃");
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.vibrate();
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
Blinker.weather();
|
||||
|
||||
Blinker.delay(60000);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachWeather(weatherData);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Bridge/.pydio
Normal file
1
blinker-library/examples/Blinker_Bridge/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
7a053fba-686a-4575-b461-0c8531aef540
|
||||
@@ -0,0 +1 @@
|
||||
982e6392-796a-413a-ba03-deb6d6c052e5
|
||||
@@ -0,0 +1,87 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
#define BRIDGE_1 "Your Device Secret Key of bridge to device"
|
||||
|
||||
BlinkerBridge BridgeDevice1(BRIDGE_1);
|
||||
|
||||
void bridge1Read(const String & data)
|
||||
{
|
||||
BLINKER_LOG("BridgeDevice1 readString: ", data);
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
// must print Json data
|
||||
BridgeDevice1.print("{\"hello\":\"bridge\"}");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BridgeDevice1.attach(bridge1Read);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Cloud/.pydio
Normal file
1
blinker-library/examples/Blinker_Cloud/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
909a51d1-27d9-4f31-a904-698210707b78
|
||||
@@ -0,0 +1 @@
|
||||
eca17031-b486-474c-9c22-337162f04dd0
|
||||
@@ -0,0 +1 @@
|
||||
9aa96af5-4ab8-4339-a246-229e31e2ea10
|
||||
@@ -0,0 +1,88 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.vibrate();
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
void dataStorage()
|
||||
{
|
||||
Blinker.dataStorage("data1", random(0,120));
|
||||
Blinker.dataStorage("data2", random(0,120)/2.0);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachDataStorage(dataStorage);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
112f8898-7da6-4376-b94e-f5adeaeb857a
|
||||
@@ -0,0 +1 @@
|
||||
165af3c1-550f-4643-9cab-c4383600250e
|
||||
@@ -0,0 +1,91 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
|
||||
Blinker.coordinate(104.0667, 30.6667);
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
76e1bb29-64e0-4191-934c-00e6818bb04d
|
||||
@@ -0,0 +1 @@
|
||||
b53f9e64-c60f-4683-8914-d4362a78362e
|
||||
@@ -0,0 +1,93 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void configGet(const String & data)
|
||||
{
|
||||
BLINKER_LOG("config get: ", data);
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.vibrate();
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
|
||||
// update data must be Json
|
||||
if (Blinker.configUpdate("{\"Hello\":\"blinker\"}"))
|
||||
{
|
||||
Blinker.configGet();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachConfigGet(configGet);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
53bb5ac5-ca06-4f16-984e-0a89570099a7
|
||||
@@ -0,0 +1,80 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.textData("text data");
|
||||
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
6d1dc563-cc11-40f4-bd29-83dcbd14ad09
|
||||
@@ -0,0 +1,88 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.vibrate();
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
void dataStorage()
|
||||
{
|
||||
Blinker.timeSlotData("data1", (int32_t)random(0,120));
|
||||
Blinker.timeSlotData("data2", random(0,120)/(float)1.5);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachDataStorage(dataStorage);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
c3944b91-6da6-4ad5-9b24-a2471ebeb5aa
|
||||
@@ -0,0 +1 @@
|
||||
256c575b-c5dd-428c-bcd4-838298bd505a
|
||||
@@ -0,0 +1,95 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// 新建组件对象
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// 按下按键即会执行该函数
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
// 如果未绑定的组件被触发,则会执行其中内容
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
Blinker.gps(30.6573130504,104.0661831040);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// 初始化串口
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
// 初始化有LED的IO
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
// 初始化blinker
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
1f46c0e6-cf43-491d-937e-b9c72a57ccce
|
||||
@@ -0,0 +1 @@
|
||||
7d840479-015c-4b33-bfc0-20c2917a48c5
|
||||
@@ -0,0 +1,91 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
|
||||
Blinker.log("button pressed");
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_ESP32_CAM/.pydio
Normal file
1
blinker-library/examples/Blinker_ESP32_CAM/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
c1a2e691-f8d8-4fb3-b915-e53c75028567
|
||||
@@ -0,0 +1,89 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ESP_SMARTCONFIG
|
||||
|
||||
#include <Blinker.h>
|
||||
#include "ESP32_CAM_SERVER.h"
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
bool setup_camera = false;
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth);
|
||||
Blinker.attachData(dataRead);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
|
||||
if (Blinker.connected() && !setup_camera)
|
||||
{
|
||||
setupCamera();
|
||||
setup_camera = true;
|
||||
|
||||
Blinker.printObject("video", "{\"str\":\"mjpg\",\"url\":\"http://"+ WiFi.localIP().toString() + "\"}");
|
||||
}
|
||||
}
|
||||
256
blinker-library/examples/Blinker_ESP32_CAM/ESP32_CAM_SERVER.h
Normal file
256
blinker-library/examples/Blinker_ESP32_CAM/ESP32_CAM_SERVER.h
Normal file
@@ -0,0 +1,256 @@
|
||||
#ifndef ESP_CAM_SERVER_H
|
||||
#define ESP_CAM_SERVER_H
|
||||
|
||||
#include "esp_camera.h"
|
||||
#include <WiFi.h>
|
||||
#include "esp_timer.h"
|
||||
#include "img_converters.h"
|
||||
#include "Arduino.h"
|
||||
#include "fb_gfx.h"
|
||||
#include "soc/soc.h" //disable brownout problems
|
||||
#include "soc/rtc_cntl_reg.h" //disable brownout problems
|
||||
#include "esp_http_server.h"
|
||||
|
||||
|
||||
#define PART_BOUNDARY "123456789000000000000987654321"
|
||||
|
||||
// This project was tested with the AI Thinker Model, M5STACK PSRAM Model and M5STACK WITHOUT PSRAM
|
||||
#define CAMERA_MODEL_AI_THINKER
|
||||
//#define CAMERA_MODEL_M5STACK_PSRAM
|
||||
//#define CAMERA_MODEL_M5STACK_WITHOUT_PSRAM
|
||||
|
||||
// Not tested with this model
|
||||
//#define CAMERA_MODEL_WROVER_KIT
|
||||
|
||||
#if defined(CAMERA_MODEL_WROVER_KIT)
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 21
|
||||
#define SIOD_GPIO_NUM 26
|
||||
#define SIOC_GPIO_NUM 27
|
||||
|
||||
#define Y9_GPIO_NUM 35
|
||||
#define Y8_GPIO_NUM 34
|
||||
#define Y7_GPIO_NUM 39
|
||||
#define Y6_GPIO_NUM 36
|
||||
#define Y5_GPIO_NUM 19
|
||||
#define Y4_GPIO_NUM 18
|
||||
#define Y3_GPIO_NUM 5
|
||||
#define Y2_GPIO_NUM 4
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 23
|
||||
#define PCLK_GPIO_NUM 22
|
||||
|
||||
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM 15
|
||||
#define XCLK_GPIO_NUM 27
|
||||
#define SIOD_GPIO_NUM 25
|
||||
#define SIOC_GPIO_NUM 23
|
||||
|
||||
#define Y9_GPIO_NUM 19
|
||||
#define Y8_GPIO_NUM 36
|
||||
#define Y7_GPIO_NUM 18
|
||||
#define Y6_GPIO_NUM 39
|
||||
#define Y5_GPIO_NUM 5
|
||||
#define Y4_GPIO_NUM 34
|
||||
#define Y3_GPIO_NUM 35
|
||||
#define Y2_GPIO_NUM 32
|
||||
#define VSYNC_GPIO_NUM 22
|
||||
#define HREF_GPIO_NUM 26
|
||||
#define PCLK_GPIO_NUM 21
|
||||
|
||||
#elif defined(CAMERA_MODEL_M5STACK_WITHOUT_PSRAM)
|
||||
#define PWDN_GPIO_NUM -1
|
||||
#define RESET_GPIO_NUM 15
|
||||
#define XCLK_GPIO_NUM 27
|
||||
#define SIOD_GPIO_NUM 25
|
||||
#define SIOC_GPIO_NUM 23
|
||||
|
||||
#define Y9_GPIO_NUM 19
|
||||
#define Y8_GPIO_NUM 36
|
||||
#define Y7_GPIO_NUM 18
|
||||
#define Y6_GPIO_NUM 39
|
||||
#define Y5_GPIO_NUM 5
|
||||
#define Y4_GPIO_NUM 34
|
||||
#define Y3_GPIO_NUM 35
|
||||
#define Y2_GPIO_NUM 17
|
||||
#define VSYNC_GPIO_NUM 22
|
||||
#define HREF_GPIO_NUM 26
|
||||
#define PCLK_GPIO_NUM 21
|
||||
|
||||
#elif defined(CAMERA_MODEL_AI_THINKER)
|
||||
#define PWDN_GPIO_NUM 32
|
||||
#define RESET_GPIO_NUM -1
|
||||
#define XCLK_GPIO_NUM 0
|
||||
#define SIOD_GPIO_NUM 26
|
||||
#define SIOC_GPIO_NUM 27
|
||||
|
||||
#define Y9_GPIO_NUM 35
|
||||
#define Y8_GPIO_NUM 34
|
||||
#define Y7_GPIO_NUM 39
|
||||
#define Y6_GPIO_NUM 36
|
||||
#define Y5_GPIO_NUM 21
|
||||
#define Y4_GPIO_NUM 19
|
||||
#define Y3_GPIO_NUM 18
|
||||
#define Y2_GPIO_NUM 5
|
||||
#define VSYNC_GPIO_NUM 25
|
||||
#define HREF_GPIO_NUM 23
|
||||
#define PCLK_GPIO_NUM 22
|
||||
#else
|
||||
#error "Camera model not selected"
|
||||
#endif
|
||||
|
||||
static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
|
||||
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
||||
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
||||
|
||||
httpd_handle_t stream_httpd = NULL;
|
||||
|
||||
static esp_err_t stream_handler(httpd_req_t *req){
|
||||
camera_fb_t * fb = NULL;
|
||||
esp_err_t res = ESP_OK;
|
||||
size_t _jpg_buf_len = 0;
|
||||
uint8_t * _jpg_buf = NULL;
|
||||
char * part_buf[64];
|
||||
|
||||
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
|
||||
if(res != ESP_OK){
|
||||
return res;
|
||||
}
|
||||
|
||||
while(true){
|
||||
fb = esp_camera_fb_get();
|
||||
if (!fb) {
|
||||
Serial.println("Camera capture failed");
|
||||
res = ESP_FAIL;
|
||||
} else {
|
||||
if(fb->width > 400){
|
||||
if(fb->format != PIXFORMAT_JPEG){
|
||||
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
if(!jpeg_converted){
|
||||
Serial.println("JPEG compression failed");
|
||||
res = ESP_FAIL;
|
||||
}
|
||||
} else {
|
||||
_jpg_buf_len = fb->len;
|
||||
_jpg_buf = fb->buf;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fb->format != PIXFORMAT_JPEG){
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
} else {
|
||||
_jpg_buf = fb->buf;
|
||||
_jpg_buf_len = fb->len;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(res == ESP_OK){
|
||||
size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
|
||||
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
|
||||
}
|
||||
if(res == ESP_OK){
|
||||
res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
|
||||
}
|
||||
if(res == ESP_OK){
|
||||
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
|
||||
}
|
||||
if(fb){
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
_jpg_buf = NULL;
|
||||
} else if(_jpg_buf){
|
||||
free(_jpg_buf);
|
||||
_jpg_buf = NULL;
|
||||
}
|
||||
if(res != ESP_OK){
|
||||
break;
|
||||
}
|
||||
//Serial.printf("MJPG: %uB\n",(uint32_t)(_jpg_buf_len));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void startCameraServer(){
|
||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||
config.server_port = 80;
|
||||
|
||||
httpd_uri_t index_uri = {
|
||||
.uri = "/",
|
||||
.method = HTTP_GET,
|
||||
.handler = stream_handler,
|
||||
.user_ctx = NULL
|
||||
};
|
||||
|
||||
//Serial.printf("Starting web server on port: '%d'\n", config.server_port);
|
||||
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
|
||||
httpd_register_uri_handler(stream_httpd, &index_uri);
|
||||
}
|
||||
}
|
||||
|
||||
void setupCamera()
|
||||
{
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||
|
||||
// Serial.begin(115200);
|
||||
// Serial.setDebugOutput(false);
|
||||
|
||||
camera_config_t config;
|
||||
config.ledc_channel = LEDC_CHANNEL_0;
|
||||
config.ledc_timer = LEDC_TIMER_0;
|
||||
config.pin_d0 = Y2_GPIO_NUM;
|
||||
config.pin_d1 = Y3_GPIO_NUM;
|
||||
config.pin_d2 = Y4_GPIO_NUM;
|
||||
config.pin_d3 = Y5_GPIO_NUM;
|
||||
config.pin_d4 = Y6_GPIO_NUM;
|
||||
config.pin_d5 = Y7_GPIO_NUM;
|
||||
config.pin_d6 = Y8_GPIO_NUM;
|
||||
config.pin_d7 = Y9_GPIO_NUM;
|
||||
config.pin_xclk = XCLK_GPIO_NUM;
|
||||
config.pin_pclk = PCLK_GPIO_NUM;
|
||||
config.pin_vsync = VSYNC_GPIO_NUM;
|
||||
config.pin_href = HREF_GPIO_NUM;
|
||||
config.pin_sscb_sda = SIOD_GPIO_NUM;
|
||||
config.pin_sscb_scl = SIOC_GPIO_NUM;
|
||||
config.pin_pwdn = PWDN_GPIO_NUM;
|
||||
config.pin_reset = RESET_GPIO_NUM;
|
||||
config.xclk_freq_hz = 20000000;
|
||||
config.pixel_format = PIXFORMAT_JPEG;
|
||||
|
||||
if(psramFound()){
|
||||
config.frame_size = FRAMESIZE_QVGA;
|
||||
config.jpeg_quality = 10;
|
||||
config.fb_count = 2;
|
||||
} else {
|
||||
config.frame_size = FRAMESIZE_QVGA;
|
||||
config.jpeg_quality = 10;
|
||||
config.fb_count = 2;
|
||||
}
|
||||
|
||||
// Camera init
|
||||
esp_err_t err = esp_camera_init(&config);
|
||||
if (err != ESP_OK) {
|
||||
Serial.printf("Camera init failed with error 0x%x", err);
|
||||
return;
|
||||
}
|
||||
// Wi-Fi connection
|
||||
// WiFi.begin(ssid, password);
|
||||
// while (WiFi.status() != WL_CONNECTED) {
|
||||
// delay(500);
|
||||
// Serial.print(".");
|
||||
// }
|
||||
// Serial.println("");
|
||||
// Serial.println("WiFi connected");
|
||||
|
||||
// Serial.print("Camera Stream Ready! Go to: http://");
|
||||
// Serial.println(WiFi.localIP());
|
||||
|
||||
// Start streaming web server
|
||||
startCameraServer();
|
||||
}
|
||||
|
||||
#endif
|
||||
1
blinker-library/examples/Blinker_Hello/.pydio
Normal file
1
blinker-library/examples/Blinker_Hello/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8c7f1d82-a68a-4a2e-9f0e-f521d25e5a75
|
||||
@@ -0,0 +1 @@
|
||||
30498214-1fb0-46ad-8117-93fc292d57cd
|
||||
@@ -0,0 +1,102 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_HTTP
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// 新建组件对象
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// 按下按键即会执行该函数
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
// 如果未绑定的组件被触发,则会执行其中内容
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// 初始化串口
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
// 初始化有LED的IO
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
// 初始化blinker
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
uint32_t time_os_run = 0;
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
|
||||
if ((millis() - time_os_run) >= 60000)
|
||||
{
|
||||
Blinker.subscribe();
|
||||
time_os_run += 60000;
|
||||
}
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Hello/Hello_BLE/.pydio
Normal file
1
blinker-library/examples/Blinker_Hello/Hello_BLE/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
cd484f7c-f6c3-4807-88b9-fb56461debbe
|
||||
@@ -0,0 +1,85 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_BLE
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Hello/Hello_WiFi/.pydio
Normal file
1
blinker-library/examples/Blinker_Hello/Hello_WiFi/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
3807e855-a36b-4668-ae1d-ce752af5e7c1
|
||||
@@ -0,0 +1,94 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// 新建组件对象
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// 按下按键即会执行该函数
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
// 如果未绑定的组件被触发,则会执行其中内容
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// 初始化串口
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
// 初始化有LED的IO
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
// 初始化blinker
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
4ae01131-ba92-4681-bb04-10aa23efd89d
|
||||
@@ -0,0 +1,95 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_WITHOUT_SSL
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// 新建组件对象
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// 按下按键即会执行该函数
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
// 如果未绑定的组件被触发,则会执行其中内容
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// 初始化串口
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
// 初始化有LED的IO
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
// 初始化blinker
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_MQTT/.pydio
Normal file
1
blinker-library/examples/Blinker_MQTT/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
c1b16c8c-f934-4def-bbe9-92a4877aeddf
|
||||
1
blinker-library/examples/Blinker_MQTT/MQTT_PUB/.pydio
Normal file
1
blinker-library/examples/Blinker_MQTT/MQTT_PUB/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
4732c82b-59fc-40b9-b6f5-ba8eb850e712
|
||||
100
blinker-library/examples/Blinker_MQTT/MQTT_PUB/MQTT_PUB.ino
Normal file
100
blinker-library/examples/Blinker_MQTT/MQTT_PUB/MQTT_PUB.ino
Normal file
@@ -0,0 +1,100 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// 新建组件对象
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// 按下按键即会执行该函数
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
// 如果未绑定的组件被触发,则会执行其中内容
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
if (BLINKER_PROTOCOL_MQTT != NULL) {
|
||||
String pub_topic = "/device/" + Blinker.deviceName() + "/s";
|
||||
String pub_data = "{\"toDevice\":\"the device name you need pub to\",\"data\":{\"hello\":\"blinker\"}}";
|
||||
BLINKER_PROTOCOL_MQTT->publish(pub_topic.c_str(), pub_data.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// 初始化串口
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
// 初始化有LED的IO
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
// 初始化blinker
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
Button1.attach(button1_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_PRO/.pydio
Normal file
1
blinker-library/examples/Blinker_PRO/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
65284a9e-4a26-4140-8e2f-8d008aa8d552
|
||||
@@ -0,0 +1 @@
|
||||
5832cbcf-f223-4242-abf3-3f272f70feb3
|
||||
@@ -0,0 +1,163 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_AIR202
|
||||
// #define BLINKER_BUTTON
|
||||
// #define BLINKER_BUTTON_PIN D7
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
// Blinker.print("hello", "blinker");
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
Blinker.print(BlinkerTime);
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
c565f625-fbb7-488a-b4e4-1688adcbc7fa
|
||||
@@ -0,0 +1,174 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#define BLINKER_SERVER_HTTPS "https://iot.diandeng.tech"
|
||||
|
||||
#define BLINKER_SERVER_HOST "iot.diandeng.tech"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
2a3c9f01-f4ac-4d9d-82e8-0daa3210ddd3
|
||||
@@ -0,0 +1,170 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
65108938-a1a1-4f8c-b2ea-347220a70890
|
||||
@@ -0,0 +1,182 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.apConfigInit();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
2d7ca55d-a1e0-4482-976a-f0a264dc80e6
|
||||
@@ -0,0 +1 @@
|
||||
aa7dbde7-4224-4429-8056-55a4db17f013
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.warning("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
25c1101c-e164-4fd7-93f7-46691f20f843
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.message("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
3dfce2de-e679-404d-9843-bcd4d6d62040
|
||||
@@ -0,0 +1,181 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
|
||||
BlinkerEvent.warning("button click!");
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
640c8e68-17e4-4cca-84c8-8440336f5a31
|
||||
@@ -0,0 +1 @@
|
||||
18c5bb91-c842-49e7-b323-6fde537b99cd
|
||||
@@ -0,0 +1,184 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
#define BLINKER_OTA_BLINK_TIME 500
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
uint32_t os_time;
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
// void otaStatus(uint32_t load_size, uint32_t total_size)
|
||||
// {
|
||||
// if (millis() - os_time >= BLINKER_OTA_BLINK_TIME)
|
||||
// {
|
||||
// os_time = millis();
|
||||
|
||||
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
// }
|
||||
// }
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
// BlinkerUpdater.onProgress(otaStatus);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
072d0936-ad7e-45a2-ab83-8f8d59a88c2c
|
||||
@@ -0,0 +1,163 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_SIM7020
|
||||
// #define BLINKER_BUTTON
|
||||
// #define BLINKER_BUTTON_PIN D7
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
// Blinker.print("hello", "blinker");
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
Blinker.print(BlinkerTime);
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
362b3899-6d40-4d91-9147-1525e76adf96
|
||||
@@ -0,0 +1,211 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#define BLINKER_BUTTON_LONGPRESS_POWERDOWN
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
BlinkerButton Button1("btn-abc");
|
||||
BlinkerNumber Number1("num-abc");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When long press start, device will call this function
|
||||
*/
|
||||
void longPressStart()
|
||||
{
|
||||
BLINKER_LOG("Button long press start!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When during long press, device will call this function
|
||||
*/
|
||||
void duringLongPress()
|
||||
{
|
||||
// BLINKER_LOG("During button long press!");
|
||||
|
||||
uint16_t pressed_time = Blinker.pressedTime();
|
||||
|
||||
if (pressed_time >= 5000 && Blinker.configType() != BLINKER_AP_CONFIG)
|
||||
{
|
||||
Blinker.esptouchInit();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
counter++;
|
||||
Number1.print(counter);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
Button1.attach(button1_callback);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
Blinker.attachLongPressStart(longPressStart);
|
||||
Blinker.attachDuringLongPress(duringLongPress);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_PRO_Device/.pydio
Normal file
1
blinker-library/examples/Blinker_PRO_Device/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
a6e4b4fc-4683-4945-a1ab-942dda7e9ad0
|
||||
@@ -0,0 +1 @@
|
||||
b791ff96-f4ec-47cd-874e-38d286635607
|
||||
@@ -0,0 +1,209 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
/*
|
||||
* BLINKER_PRO is use for professional device
|
||||
*
|
||||
* Please make sure you have permission to modify professional device!
|
||||
* Please read usermanual first! Thanks!
|
||||
* https://diandeng.tech/doc
|
||||
*
|
||||
* Written by i3water for blinker.
|
||||
* Learn more:https://blinker.app/
|
||||
*/
|
||||
|
||||
#define BLINKER_PRO_ESP
|
||||
#define BLINKER_BUTTON
|
||||
#if defined(ESP32)
|
||||
#define BLINKER_BUTTON_PIN 4
|
||||
#else
|
||||
#define BLINKER_BUTTON_PIN D7
|
||||
#endif
|
||||
|
||||
#define BLINKER_OTA_VERSION_CODE "0.1.1"
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char type[] = "Your Device Type";
|
||||
char auth[] = "Your Device Secret Key";
|
||||
|
||||
#define powerKey "power"
|
||||
|
||||
bool sw_state = false;
|
||||
|
||||
float power_read()
|
||||
{
|
||||
return sw_state ? random(0, 10)/2.0 : 0.0;
|
||||
}
|
||||
|
||||
void switch_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get switch state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
sw_state = true;
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
BUILTIN_SWITCH.print("on");
|
||||
Blinker.print(powerKey, power_read());
|
||||
}
|
||||
else {
|
||||
sw_state = false;
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
BUILTIN_SWITCH.print("off");
|
||||
Blinker.print(powerKey, power_read());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your command parse code in this function
|
||||
*
|
||||
* When get a command and device not parsed this command, device will call this function
|
||||
*/
|
||||
bool dataParse(const JsonObject & data)
|
||||
{
|
||||
String getData;
|
||||
|
||||
serializeJson(data, getData);
|
||||
|
||||
BLINKER_LOG("Get user command: ", getData);
|
||||
|
||||
// if you parsed this data, return TRUE.
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your heartbeat message detail in this function
|
||||
*
|
||||
* When get heartbeat command {"get": "state"}, device will call this function
|
||||
* For example, you can print message back
|
||||
*
|
||||
* Every 30s will get a heartbeat command from app
|
||||
*/
|
||||
void heartbeat()
|
||||
{
|
||||
BUILTIN_SWITCH.print(sw_state ? "on" : "off");
|
||||
Blinker.print(powerKey, power_read());
|
||||
|
||||
BLINKER_LOG("heartbeat!");
|
||||
}
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
/*
|
||||
* Blinker provide a button parse function for user if you defined BLINKER_BUTTON
|
||||
*
|
||||
* Blinker button can detect singal click/ double click/ long press
|
||||
*
|
||||
* Blinker.tick() will run by default, use interrupt will be better
|
||||
*/
|
||||
ICACHE_RAM_ATTR void buttonTick()
|
||||
{
|
||||
Blinker.tick();
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button clicked, device will call this function
|
||||
*/
|
||||
void singleClick()
|
||||
{
|
||||
BLINKER_LOG("Button clicked!");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add your code in this function
|
||||
*
|
||||
* When button double clicked, device will call this function
|
||||
*/
|
||||
void doubleClick()
|
||||
{
|
||||
BLINKER_LOG("Button double clicked!");
|
||||
}
|
||||
#endif
|
||||
|
||||
void dataStorage()
|
||||
{
|
||||
Blinker.dataStorage("power", power_read());
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, type);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachParse(dataParse);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
#if defined(BLINKER_BUTTON)
|
||||
Blinker.attachClick(singleClick);
|
||||
Blinker.attachDoubleClick(doubleClick);
|
||||
attachInterrupt(BLINKER_BUTTON_PIN, buttonTick, CHANGE);
|
||||
#endif
|
||||
|
||||
BUILTIN_SWITCH.attach(switch_callback);
|
||||
Blinker.attachDataStorage(dataStorage);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Sensor/.pydio
Normal file
1
blinker-library/examples/Blinker_Sensor/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
d5733326-3a68-42d6-b463-8caa2265d107
|
||||
@@ -0,0 +1 @@
|
||||
5db05e13-7a56-4f18-ab66-8fefe7996c20
|
||||
@@ -0,0 +1 @@
|
||||
45cd5624-b5ab-4d99-94c1-5bbbca074e7d
|
||||
@@ -0,0 +1,104 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
BlinkerNumber TEMP("temp"); // Temperature
|
||||
BlinkerNumber PRES("pres"); // Pressure
|
||||
BlinkerNumber ALTI("alti"); // Altitude
|
||||
|
||||
// Download Adafruit-BMP085-Library library here:
|
||||
// https://github.com/adafruit/Adafruit-BMP085-Library
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_BMP085.h>
|
||||
|
||||
Adafruit_BMP085 bmp;
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void heartbeat()
|
||||
{
|
||||
TEMP.print(bmp.readTemperature());
|
||||
PRES.print(bmp.readPressure());
|
||||
ALTI.print(bmp.readAltitude());
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
if (!bmp.begin()) {
|
||||
BLINKER_LOG("Could not find a valid BMP085 sensor, check wiring!");
|
||||
while (1) {delay(100);}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
84c5a792-06d2-43d0-9de0-16fe678d7b7d
|
||||
@@ -0,0 +1 @@
|
||||
3f7cd58b-408e-424c-b764-d8c8596ec05c
|
||||
@@ -0,0 +1,126 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_BLE
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
BlinkerNumber HUMI("humi");
|
||||
BlinkerNumber TEMP("temp");
|
||||
|
||||
// Download Adafruit DHT-sensor-library library here:
|
||||
// https://github.com/adafruit/DHT-sensor-library
|
||||
#include <DHT.h>
|
||||
|
||||
#define DHTPIN 2
|
||||
|
||||
//#define DHTTYPE DHT11 // DHT 11
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
uint32_t read_time = 0;
|
||||
|
||||
float humi_read, temp_read;
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void heartbeat()
|
||||
{
|
||||
HUMI.print(humi_read);
|
||||
TEMP.print(temp_read);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin();
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
|
||||
if (read_time == 0 || (millis() - read_time) >= 2000)
|
||||
{
|
||||
read_time = millis();
|
||||
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
|
||||
if (isnan(h) || isnan(t)) {
|
||||
BLINKER_LOG("Failed to read from DHT sensor!");
|
||||
return;
|
||||
}
|
||||
|
||||
float hic = dht.computeHeatIndex(t, h, false);
|
||||
|
||||
humi_read = h;
|
||||
temp_read = t;
|
||||
|
||||
BLINKER_LOG("Humidity: ", h, " %");
|
||||
BLINKER_LOG("Temperature: ", t, " *C");
|
||||
BLINKER_LOG("Heat index: ", hic, " *C");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
56b6e643-3901-4ecb-bacd-622b7946f535
|
||||
@@ -0,0 +1,130 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
BlinkerNumber HUMI("humi");
|
||||
BlinkerNumber TEMP("temp");
|
||||
|
||||
// Download Adafruit DHT-sensor-library library here:
|
||||
// https://github.com/adafruit/DHT-sensor-library
|
||||
#include <DHT.h>
|
||||
|
||||
#define DHTPIN 2
|
||||
|
||||
//#define DHTTYPE DHT11 // DHT 11
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
uint32_t read_time = 0;
|
||||
|
||||
float humi_read, temp_read;
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void heartbeat()
|
||||
{
|
||||
HUMI.print(humi_read);
|
||||
TEMP.print(temp_read);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
Blinker.attachHeartbeat(heartbeat);
|
||||
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
|
||||
if (read_time == 0 || (millis() - read_time) >= 2000)
|
||||
{
|
||||
read_time = millis();
|
||||
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
|
||||
if (isnan(h) || isnan(t)) {
|
||||
BLINKER_LOG("Failed to read from DHT sensor!");
|
||||
return;
|
||||
}
|
||||
|
||||
float hic = dht.computeHeatIndex(t, h, false);
|
||||
|
||||
humi_read = h;
|
||||
temp_read = t;
|
||||
|
||||
BLINKER_LOG("Humidity: ", h, " %");
|
||||
BLINKER_LOG("Temperature: ", t, " *C");
|
||||
BLINKER_LOG("Heat index: ", hic, " *C");
|
||||
}
|
||||
}
|
||||
1
blinker-library/examples/Blinker_Voice_Assistant/.pydio
Normal file
1
blinker-library/examples/Blinker_Voice_Assistant/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
b7a78739-12a5-455a-9cb5-831065ad4777
|
||||
@@ -0,0 +1 @@
|
||||
9e05126e-2393-4584-a9ad-96ca2035e968
|
||||
@@ -0,0 +1 @@
|
||||
77e1d9eb-8980-428a-88fc-fa2fbdb26932
|
||||
@@ -0,0 +1,239 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_AIRCONDITION
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
bool oState = false;
|
||||
bool hsState = false;
|
||||
bool vsState = false;
|
||||
String setLevel = "auto";
|
||||
uint8_t setTemp = 26;
|
||||
|
||||
void aligenieTemp(uint8_t temp)
|
||||
{
|
||||
BLINKER_LOG("need set temp: ", temp);
|
||||
|
||||
setTemp = temp;
|
||||
|
||||
BlinkerAliGenie.temp(temp);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieRelativeTemp(uint8_t relTemp)
|
||||
{
|
||||
BLINKER_LOG("need set temp: ", relTemp);
|
||||
|
||||
setTemp = setTemp + relTemp;
|
||||
|
||||
BlinkerAliGenie.temp(setTemp);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieLevel(const String & level)
|
||||
{
|
||||
BLINKER_LOG("need set level: ", level);
|
||||
// auto 自动风
|
||||
// low 低风
|
||||
// medium 中风
|
||||
// high 高风
|
||||
|
||||
setLevel = level;
|
||||
|
||||
BlinkerAliGenie.level(level);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieHSwingState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set HSwing state: ", state);
|
||||
// horizontal-swing
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.hswing("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
hsState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.hswing("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
hsState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieVSwingState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set VSwing state: ", state);
|
||||
// vertical-swing
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.vswing("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
vsState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.vswing("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
vsState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieMode(const String & mode)
|
||||
{
|
||||
BLINKER_LOG("need set mode: ", mode);
|
||||
|
||||
BlinkerAliGenie.mode(mode);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligeniePowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.powerState("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.powerState("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.hswing(hsState ? "on" : "off");
|
||||
BlinkerAliGenie.vswing(vsState ? "on" : "off");
|
||||
BlinkerAliGenie.level(setLevel);
|
||||
BlinkerAliGenie.mode("quietWind");
|
||||
BlinkerAliGenie.temp(setTemp);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Power State");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.hswing(hsState ? "on" : "off");
|
||||
BlinkerAliGenie.vswing(vsState ? "on" : "off");
|
||||
BlinkerAliGenie.level(setLevel);
|
||||
BlinkerAliGenie.mode("quietWind");
|
||||
BlinkerAliGenie.temp(setTemp);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachPowerState(aligeniePowerState);
|
||||
BlinkerAliGenie.attachHSwing(aligenieHSwingState);
|
||||
BlinkerAliGenie.attachVSwing(aligenieVSwingState);
|
||||
BlinkerAliGenie.attachLevel(aligenieLevel);
|
||||
BlinkerAliGenie.attachMode(aligenieMode);
|
||||
BlinkerAliGenie.attachTemp(aligenieTemp);
|
||||
BlinkerAliGenie.attachRelativeTemp(aligenieRelativeTemp);
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
2113466f-7660-4654-a01f-7bc0a7ebabe0
|
||||
@@ -0,0 +1,211 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_FAN
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
bool oState = false;
|
||||
bool hsState = false;
|
||||
bool vsState = false;
|
||||
uint8_t setLevel;
|
||||
|
||||
void aligenieLevel(uint8_t level)
|
||||
{
|
||||
BLINKER_LOG("need set level: ", level);
|
||||
// 0:AUTO MODE, 1-3 LEVEL
|
||||
|
||||
setLevel = level;
|
||||
|
||||
BlinkerAliGenie.level(level);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieHSwingState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set HSwing state: ", state);
|
||||
// horizontal-swing
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.hswing("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
hsState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.hswing("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
hsState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieVSwingState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set VSwing state: ", state);
|
||||
// vertical-swing
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.vswing("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
vsState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.vswing("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
vsState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieMode(const String & mode)
|
||||
{
|
||||
BLINKER_LOG("need set mode: ", mode);
|
||||
|
||||
BlinkerAliGenie.mode(mode);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligeniePowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.powerState("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.powerState("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.hswing(hsState ? "on" : "off");
|
||||
BlinkerAliGenie.vswing(vsState ? "on" : "off");
|
||||
BlinkerAliGenie.level(setLevel);
|
||||
BlinkerAliGenie.mode("quietWind");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Power State");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.hswing(hsState ? "on" : "off");
|
||||
BlinkerAliGenie.vswing(vsState ? "on" : "off");
|
||||
BlinkerAliGenie.level(setLevel);
|
||||
BlinkerAliGenie.mode("quietWind");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachPowerState(aligeniePowerState);
|
||||
BlinkerAliGenie.attachHSwing(aligenieHSwingState);
|
||||
BlinkerAliGenie.attachVSwing(aligenieVSwingState);
|
||||
BlinkerAliGenie.attachLevel(aligenieLevel);
|
||||
BlinkerAliGenie.attachMode(aligenieMode);
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
f831f50d-1197-45d5-8250-e202e65be74e
|
||||
@@ -0,0 +1,439 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_LIGHT
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
// Download Adafruit_NeoPixel library here:
|
||||
// https://github.com/adafruit/Adafruit_NeoPixel
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define PIN 13
|
||||
#define NUMPIXELS 24
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
#define RGB_1 "RGBKey"
|
||||
|
||||
BlinkerRGB WS2812(RGB_1);
|
||||
|
||||
uint8_t colorR, colorG, colorB, colorW;
|
||||
bool wsState;
|
||||
String wsMode = BLINKER_CMD_COMMON;
|
||||
|
||||
void pixelShow()
|
||||
{
|
||||
pixels.setBrightness(colorW);
|
||||
|
||||
for(int i = 0; i < NUMPIXELS; i++){
|
||||
pixels.setPixelColor(i, colorR, colorG, colorB);
|
||||
}
|
||||
pixels.show();
|
||||
}
|
||||
|
||||
void ws2812_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value)
|
||||
{
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
BLINKER_LOG("R value: ", r_value);
|
||||
BLINKER_LOG("G value: ", g_value);
|
||||
BLINKER_LOG("B value: ", b_value);
|
||||
BLINKER_LOG("Rrightness value: ", bright_value);
|
||||
|
||||
colorR = r_value;
|
||||
colorG = g_value;
|
||||
colorB = b_value;
|
||||
colorW = bright_value;
|
||||
|
||||
pixelShow();
|
||||
}
|
||||
|
||||
String getColor()
|
||||
{
|
||||
uint32_t color = colorR << 16 | colorG << 8 | colorB;
|
||||
|
||||
switch (color)
|
||||
{
|
||||
case 0xFF0000 :
|
||||
return "Red";
|
||||
case 0xFFFF00 :
|
||||
return "Yellow";
|
||||
case 0x0000FF :
|
||||
return "Blue";
|
||||
case 0x00FF00 :
|
||||
return "Green";
|
||||
case 0xFFFFFF :
|
||||
return "White";
|
||||
case 0x000000 :
|
||||
return "Black";
|
||||
case 0x00FFFF :
|
||||
return "Cyan";
|
||||
case 0x800080 :
|
||||
return "Purple";
|
||||
case 0xFFA500 :
|
||||
return "Orange";
|
||||
default :
|
||||
return "White";
|
||||
}
|
||||
}
|
||||
|
||||
void aligeniePowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.powerState("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
wsState = true;
|
||||
|
||||
if (colorW == 0) colorW = 255;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.powerState("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
wsState = false;
|
||||
|
||||
colorW == 0;
|
||||
}
|
||||
|
||||
pixelShow();
|
||||
}
|
||||
|
||||
void aligenieColor(const String & color)
|
||||
{
|
||||
BLINKER_LOG("need set color: ", color);
|
||||
|
||||
if (color == "Red") {
|
||||
colorR = 255;
|
||||
colorG = 0;
|
||||
colorB = 0;
|
||||
}
|
||||
else if (color == "Yellow") {
|
||||
colorR = 255;
|
||||
colorG = 255;
|
||||
colorB = 0;
|
||||
}
|
||||
else if (color == "Blue") {
|
||||
colorR = 0;
|
||||
colorG = 0;
|
||||
colorB = 255;
|
||||
}
|
||||
else if (color == "Green") {
|
||||
colorR = 0;
|
||||
colorG = 255;
|
||||
colorB = 0;
|
||||
}
|
||||
else if (color == "White") {
|
||||
colorR = 255;
|
||||
colorG = 255;
|
||||
colorB = 255;
|
||||
}
|
||||
else if (color == "Black") {
|
||||
colorR = 0;
|
||||
colorG = 0;
|
||||
colorB = 0;
|
||||
}
|
||||
else if (color == "Cyan") {
|
||||
colorR = 0;
|
||||
colorG = 255;
|
||||
colorB = 255;
|
||||
}
|
||||
else if (color == "Purple") {
|
||||
colorR = 128;
|
||||
colorG = 0;
|
||||
colorB = 128;
|
||||
}
|
||||
else if (color == "Orange") {
|
||||
colorR = 255;
|
||||
colorG = 165;
|
||||
colorB = 0;
|
||||
}
|
||||
|
||||
if (wsState == false) {
|
||||
wsState = true;
|
||||
colorW = 255;
|
||||
}
|
||||
|
||||
if (colorW == 0) {
|
||||
colorW = 255;
|
||||
}
|
||||
|
||||
pixelShow();
|
||||
|
||||
BlinkerAliGenie.color(color);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieMode(const String & mode)
|
||||
{
|
||||
BLINKER_LOG("need set mode: ", mode);
|
||||
|
||||
if (mode == BLINKER_CMD_ALIGENIE_READING) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (mode == BLINKER_CMD_ALIGENIE_MOVIE) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (mode == BLINKER_CMD_ALIGENIE_SLEEP) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (mode == BLINKER_CMD_ALIGENIE_HOLIDAY) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (mode == BLINKER_CMD_ALIGENIE_MUSIC) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (mode == BLINKER_CMD_ALIGENIE_COMMON) {
|
||||
// Your mode function
|
||||
}
|
||||
|
||||
wsMode = mode;
|
||||
|
||||
BlinkerAliGenie.mode(mode);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligeniecMode(const String & cmode)
|
||||
{
|
||||
BLINKER_LOG("need cancel mode: ", cmode);
|
||||
|
||||
if (cmode == BLINKER_CMD_ALIGENIE_READING) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (cmode == BLINKER_CMD_ALIGENIE_MOVIE) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (cmode == BLINKER_CMD_ALIGENIE_SLEEP) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (cmode == BLINKER_CMD_ALIGENIE_HOLIDAY) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (cmode == BLINKER_CMD_ALIGENIE_MUSIC) {
|
||||
// Your mode function
|
||||
}
|
||||
else if (cmode == BLINKER_CMD_ALIGENIE_COMMON) {
|
||||
// Your mode function
|
||||
}
|
||||
|
||||
wsMode = BLINKER_CMD_COMMON; // new mode
|
||||
|
||||
BlinkerAliGenie.mode(wsMode); // must response
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieBright(const String & bright)
|
||||
{
|
||||
BLINKER_LOG("need set brightness: ", bright);
|
||||
|
||||
if (bright == BLINKER_CMD_MAX) {
|
||||
colorW = 255;
|
||||
}
|
||||
else if (bright == BLINKER_CMD_MIN) {
|
||||
colorW = 0;
|
||||
}
|
||||
else {
|
||||
colorW = bright.toInt();
|
||||
}
|
||||
|
||||
BLINKER_LOG("now set brightness: ", colorW);
|
||||
|
||||
pixelShow();
|
||||
|
||||
BlinkerAliGenie.brightness(colorW);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieRelativeBright(int32_t bright)
|
||||
{
|
||||
BLINKER_LOG("need set relative brightness: ", bright);
|
||||
|
||||
if (colorW + bright < 255 && colorW + bright >= 0) {
|
||||
colorW += bright;
|
||||
}
|
||||
|
||||
BLINKER_LOG("now set brightness: ", colorW);
|
||||
|
||||
pixelShow();
|
||||
|
||||
BlinkerAliGenie.brightness(bright);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieColoTemp(int32_t colorTemp)
|
||||
{
|
||||
BLINKER_LOG("need set colorTemperature: ", colorTemp);
|
||||
|
||||
BlinkerAliGenie.colorTemp(colorTemp);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieRelativeColoTemp(int32_t colorTemp)
|
||||
{
|
||||
BLINKER_LOG("need set relative colorTemperature: ", colorTemp);
|
||||
|
||||
BlinkerAliGenie.colorTemp(colorTemp);
|
||||
BlinkerAliGenie.print();
|
||||
}
|
||||
|
||||
void aligenieQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.powerState(wsState ? "on" : "off");
|
||||
BlinkerAliGenie.color(getColor());
|
||||
BlinkerAliGenie.mode(wsMode);
|
||||
BlinkerAliGenie.colorTemp(50);
|
||||
BlinkerAliGenie.brightness(colorW);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Power State");
|
||||
BlinkerAliGenie.powerState(wsState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_COLOR_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Color");
|
||||
BlinkerAliGenie.color(getColor());
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_MODE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Mode");
|
||||
BlinkerAliGenie.mode(wsMode);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_COLORTEMP_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query ColorTemperature");
|
||||
BlinkerAliGenie.colorTemp(50);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_BRIGHTNESS_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Brightness");
|
||||
BlinkerAliGenie.brightness(colorW);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.powerState(wsState ? "on" : "off");
|
||||
BlinkerAliGenie.color(getColor());
|
||||
BlinkerAliGenie.mode(wsMode);
|
||||
BlinkerAliGenie.colorTemp(50);
|
||||
BlinkerAliGenie.brightness(colorW);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachPowerState(aligeniePowerState);
|
||||
BlinkerAliGenie.attachColor(aligenieColor);
|
||||
BlinkerAliGenie.attachMode(aligenieMode);
|
||||
BlinkerAliGenie.attachCancelMode(aligeniecMode);
|
||||
BlinkerAliGenie.attachBrightness(aligenieBright);
|
||||
BlinkerAliGenie.attachRelativeBrightness(aligenieRelativeBright);
|
||||
BlinkerAliGenie.attachColorTemperature(aligenieColoTemp);
|
||||
BlinkerAliGenie.attachRelativeColorTemperature(aligenieRelativeColoTemp);
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
|
||||
pinMode(14, OUTPUT);
|
||||
digitalWrite(14, HIGH);
|
||||
pinMode(15, OUTPUT);
|
||||
digitalWrite(15, HIGH);
|
||||
|
||||
colorR = 255;
|
||||
colorG = 255;
|
||||
colorB = 255;
|
||||
colorW = 0;
|
||||
wsState = true;
|
||||
|
||||
pixels.begin();
|
||||
pixels.setBrightness(colorW);
|
||||
WS2812.attach(ws2812_callback);
|
||||
pixelShow();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
|
||||
for(int i = 0; i < NUMPIXELS; i++){
|
||||
pixels.setPixelColor(i, colorR, colorG, colorB);
|
||||
}
|
||||
pixels.show();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
bf20fa62-e30e-4f08-8f26-29139386248a
|
||||
@@ -0,0 +1,139 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_MULTI_OUTLET
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
bool oState[5] = { false };
|
||||
|
||||
void aligeniePowerState(const String & state, uint8_t num)
|
||||
{
|
||||
BLINKER_LOG("need set outlet: ", num, ", power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.powerState("on", num);
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState[num] = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.powerState("off", num);
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState[num] = true;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
for (uint8_t o_num = 0; o_num < 5; o_num++)
|
||||
{
|
||||
oState[o_num] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieQuery(int32_t queryCode, uint8_t num)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query outlet: ", num,", codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.powerState(oState[num] ? "on" : "off", num);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Power State");
|
||||
BlinkerAliGenie.powerState(oState[num] ? "on" : "off", num);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.powerState(oState[num] ? "on" : "off", num);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachPowerState(aligeniePowerState);
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ae9b53b1-cca5-484e-9896-64034e6846d0
|
||||
@@ -0,0 +1,131 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_OUTLET
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
bool oState = false;
|
||||
|
||||
void aligeniePowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerAliGenie.powerState("on");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerAliGenie.powerState("off");
|
||||
BlinkerAliGenie.print();
|
||||
|
||||
oState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void aligenieQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query Power State");
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.powerState(oState ? "on" : "off");
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachPowerState(aligeniePowerState);
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
d463a16b-b238-4d61-a351-c93965263fde
|
||||
@@ -0,0 +1,105 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_ALIGENIE_SENSOR
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
void aligenieQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("AliGenie Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_ALL_NUMBER :
|
||||
BLINKER_LOG("AliGenie Query All");
|
||||
BlinkerAliGenie.temp(20);
|
||||
BlinkerAliGenie.humi(20);
|
||||
BlinkerAliGenie.pm25(20);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerAliGenie.temp(20);
|
||||
BlinkerAliGenie.humi(20);
|
||||
BlinkerAliGenie.pm25(20);
|
||||
BlinkerAliGenie.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
Blinker.vibrate();
|
||||
|
||||
uint32_t BlinkerTime = millis();
|
||||
|
||||
Blinker.print("millis", BlinkerTime);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerAliGenie.attachQuery(aligenieQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
f35e0edb-4e9c-4d34-b784-e3df40001fa3
|
||||
@@ -0,0 +1 @@
|
||||
a6ca2f94-7b22-452e-8f25-b6940c14bf98
|
||||
@@ -0,0 +1,251 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_DUEROS_AIRCONDITION
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
#define BUTTON_1 "ButtonKey"
|
||||
|
||||
BlinkerButton Button1(BUTTON_1);
|
||||
|
||||
bool oState = false;
|
||||
bool hsState = false;
|
||||
bool vsState = false;
|
||||
uint8_t setLevel;
|
||||
uint8_t setTemp;
|
||||
String wsMode = "AUTO";
|
||||
|
||||
void duerLevel(uint8_t level)
|
||||
{
|
||||
BLINKER_LOG("need set level: ", level);
|
||||
// 0:AUTO MODE, 1-3 LEVEL
|
||||
|
||||
setLevel = level;
|
||||
|
||||
BlinkerDuerOS.level(level);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerRelativeLevel(int32_t level)
|
||||
{
|
||||
BLINKER_LOG("need set relative level: ", level);
|
||||
// 0:AUTO MODE, 1-3 LEVEL
|
||||
|
||||
setLevel += level;
|
||||
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerTemp(uint8_t temp)
|
||||
{
|
||||
BLINKER_LOG("need set temp: ", temp);
|
||||
|
||||
setTemp = temp;
|
||||
|
||||
BlinkerDuerOS.temp(temp);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerRelativeTemp(int32_t temp)
|
||||
{
|
||||
BLINKER_LOG("need set relative temp: ", temp);
|
||||
|
||||
setTemp += temp;
|
||||
|
||||
BlinkerDuerOS.temp(setTemp);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerMode(const String & mode)
|
||||
{
|
||||
BLINKER_LOG("need set mode: ", mode);
|
||||
// COOL:制冷
|
||||
// HEAT:制热
|
||||
// AUTO:自动
|
||||
// FAN:送风
|
||||
// DEHUMIDIFICATION:除湿
|
||||
// SLEEP:睡眠
|
||||
// CLEAN:净化
|
||||
// NAI:负离子
|
||||
// NO_WIND_FEELING: 无风感
|
||||
// NO_UP_WIND_FEELING: 上无风感
|
||||
// NO_DOWN_WIND_FEELING: 下无风感
|
||||
// UP_DOWN_SWING: 上下摆风
|
||||
// LEFT_RIGHT_SWING: 左右摆风
|
||||
|
||||
wsMode = mode;
|
||||
|
||||
BlinkerDuerOS.mode(mode);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
BLINKER_LOG("Toggle on!");
|
||||
|
||||
Button1.icon("icon_1");
|
||||
Button1.color("#FFFFFF");
|
||||
Button1.text("Your button name or describe");
|
||||
Button1.print("on");
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
BLINKER_LOG("Toggle off!");
|
||||
|
||||
Button1.icon("icon_1");
|
||||
Button1.color("#FFFFFF");
|
||||
Button1.text("Your button name or describe");
|
||||
Button1.print("off");
|
||||
|
||||
oState = false;
|
||||
}
|
||||
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.report();
|
||||
|
||||
digitalWrite(LED_BUILTIN, oState);
|
||||
}
|
||||
|
||||
void duerPowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerDuerOS.powerState("on");
|
||||
BlinkerDuerOS.print();
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerDuerOS.powerState("off");
|
||||
BlinkerDuerOS.print();
|
||||
|
||||
oState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void duerQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("DuerOS Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("DuerOS Query power state");
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.temp(setTemp);
|
||||
BlinkerDuerOS.mode(wsMode);
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_TIME_NUMBER :
|
||||
BLINKER_LOG("DuerOS Query time");
|
||||
BlinkerDuerOS.time(millis());
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.temp(setTemp);
|
||||
BlinkerDuerOS.mode(wsMode);
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
// Blinker.vibrate();
|
||||
|
||||
// uint32_t BlinkerTime = millis();
|
||||
|
||||
// Blinker.print("millis", BlinkerTime);
|
||||
|
||||
BlinkerDuerOS.powerState("off");
|
||||
BlinkerDuerOS.report();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerDuerOS.attachPowerState(duerPowerState);
|
||||
BlinkerDuerOS.attachLevel(duerLevel);
|
||||
BlinkerDuerOS.attachRelativeLevel(duerRelativeLevel);
|
||||
BlinkerDuerOS.attachTemp(duerTemp);
|
||||
BlinkerDuerOS.attachRelativeTemp(duerRelativeTemp);
|
||||
BlinkerDuerOS.attachMode(duerMode);
|
||||
BlinkerDuerOS.attachQuery(duerQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
858ff0e8-610f-4ea2-a903-286097de9233
|
||||
@@ -0,0 +1,225 @@
|
||||
/* *****************************************************************
|
||||
*
|
||||
* Download latest Blinker library here:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
*
|
||||
* Blinker is a cross-hardware, cross-platform solution for the IoT.
|
||||
* It provides APP, device and server support,
|
||||
* and uses public cloud services for data transmission and storage.
|
||||
* It can be used in smart home, data monitoring and other fields
|
||||
* to help users build Internet of Things projects better and faster.
|
||||
*
|
||||
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
|
||||
* if use ESP8266 with Blinker.
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* Make sure installed 1.0.5 or later ESP32/Arduino package,
|
||||
* if use ESP32 with Blinker.
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* Docs: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************
|
||||
*
|
||||
* Blinker 库下载地址:
|
||||
* https://github.com/blinker-iot/blinker-library/archive/master.zip
|
||||
*
|
||||
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
|
||||
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
|
||||
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
|
||||
*
|
||||
* 如果使用 ESP8266 接入 Blinker,
|
||||
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
|
||||
* https://github.com/esp8266/Arduino/releases
|
||||
*
|
||||
* 如果使用 ESP32 接入 Blinker,
|
||||
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
|
||||
* https://github.com/espressif/arduino-esp32/releases
|
||||
*
|
||||
* 文档: https://diandeng.tech/doc
|
||||
*
|
||||
*
|
||||
* *****************************************************************/
|
||||
|
||||
#define BLINKER_WIFI
|
||||
#define BLINKER_DUEROS_FAN
|
||||
|
||||
#include <Blinker.h>
|
||||
|
||||
char auth[] = "Your Device Secret Key";
|
||||
char ssid[] = "Your WiFi network SSID or name";
|
||||
char pswd[] = "Your WiFi network WPA password or WEP key";
|
||||
|
||||
#define BUTTON_1 "ButtonKey"
|
||||
|
||||
BlinkerButton Button1(BUTTON_1);
|
||||
|
||||
bool oState = false;
|
||||
bool hsState = false;
|
||||
bool vsState = false;
|
||||
uint8_t setLevel;
|
||||
String wsMode = "NIGHT";
|
||||
|
||||
void duerLevel(uint8_t level)
|
||||
{
|
||||
BLINKER_LOG("need set level: ", level);
|
||||
// 0:AUTO MODE, 1-3 LEVEL
|
||||
|
||||
setLevel = level;
|
||||
|
||||
BlinkerDuerOS.level(level);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerRelativeLevel(int32_t level)
|
||||
{
|
||||
BLINKER_LOG("need set relative level: ", level);
|
||||
// 0:AUTO MODE, 1-3 LEVEL
|
||||
|
||||
setLevel += level;
|
||||
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void duerMode(const String & mode)
|
||||
{
|
||||
BLINKER_LOG("need set mode: ", mode);
|
||||
// NIGHT:夜间
|
||||
// SWING:摆动/摆风
|
||||
// SINGLE:单人
|
||||
// MULTI:多人
|
||||
// SPURT:喷射
|
||||
// SPREAD:扩散
|
||||
// QUIET:安静
|
||||
// NORMAL:正常风速/适中风速/一般风速
|
||||
// POWERFUL:强效
|
||||
// MUTE:静音风速
|
||||
// NATURAL:自然风速
|
||||
// BABY:无感风速/轻微风速
|
||||
// COMFORTABLE:舒适风速
|
||||
// FEEL:人感风速
|
||||
|
||||
wsMode = mode;
|
||||
|
||||
BlinkerDuerOS.mode(mode);
|
||||
BlinkerDuerOS.print();
|
||||
}
|
||||
|
||||
void button1_callback(const String & state)
|
||||
{
|
||||
BLINKER_LOG("get button state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
BLINKER_LOG("Toggle on!");
|
||||
|
||||
Button1.icon("icon_1");
|
||||
Button1.color("#FFFFFF");
|
||||
Button1.text("Your button name or describe");
|
||||
Button1.print("on");
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
BLINKER_LOG("Toggle off!");
|
||||
|
||||
Button1.icon("icon_1");
|
||||
Button1.color("#FFFFFF");
|
||||
Button1.text("Your button name or describe");
|
||||
Button1.print("off");
|
||||
|
||||
oState = false;
|
||||
}
|
||||
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.report();
|
||||
|
||||
digitalWrite(LED_BUILTIN, oState);
|
||||
}
|
||||
|
||||
void duerPowerState(const String & state)
|
||||
{
|
||||
BLINKER_LOG("need set power state: ", state);
|
||||
|
||||
if (state == BLINKER_CMD_ON) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
BlinkerDuerOS.powerState("on");
|
||||
BlinkerDuerOS.print();
|
||||
|
||||
oState = true;
|
||||
}
|
||||
else if (state == BLINKER_CMD_OFF) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
BlinkerDuerOS.powerState("off");
|
||||
BlinkerDuerOS.print();
|
||||
|
||||
oState = false;
|
||||
}
|
||||
}
|
||||
|
||||
void duerQuery(int32_t queryCode)
|
||||
{
|
||||
BLINKER_LOG("DuerOS Query codes: ", queryCode);
|
||||
|
||||
switch (queryCode)
|
||||
{
|
||||
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
|
||||
BLINKER_LOG("DuerOS Query power state");
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
case BLINKER_CMD_QUERY_TIME_NUMBER :
|
||||
BLINKER_LOG("DuerOS Query time");
|
||||
BlinkerDuerOS.time(millis());
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
default :
|
||||
BlinkerDuerOS.powerState(oState ? "on" : "off");
|
||||
BlinkerDuerOS.level(setLevel);
|
||||
BlinkerDuerOS.print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dataRead(const String & data)
|
||||
{
|
||||
BLINKER_LOG("Blinker readString: ", data);
|
||||
|
||||
// Blinker.vibrate();
|
||||
|
||||
// uint32_t BlinkerTime = millis();
|
||||
|
||||
// Blinker.print("millis", BlinkerTime);
|
||||
|
||||
BlinkerDuerOS.powerState("off");
|
||||
BlinkerDuerOS.report();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
BLINKER_DEBUG.stream(Serial);
|
||||
BLINKER_DEBUG.debugAll();
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
Blinker.begin(auth, ssid, pswd);
|
||||
Blinker.attachData(dataRead);
|
||||
|
||||
BlinkerDuerOS.attachPowerState(duerPowerState);
|
||||
BlinkerDuerOS.attachLevel(duerLevel);
|
||||
BlinkerDuerOS.attachRelativeLevel(duerRelativeLevel);
|
||||
BlinkerDuerOS.attachMode(duerMode);
|
||||
BlinkerDuerOS.attachQuery(duerQuery);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blinker.run();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
e4b6dc09-72a5-444e-8579-2a9941dd078e
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user