初始化提交

This commit is contained in:
王立帮
2024-07-20 22:09:06 +08:00
commit c247dd07a6
6876 changed files with 2743096 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
.gitattributes export-ignore
.gitignore export-ignore
.github export-ignore

View File

@@ -0,0 +1,16 @@
__vm/
Debug/
*.vcxproj
*.filters
.vs/
*.sln
.vscode/
src/BlinkerSimpleSerialBLE.h
src/BlinkerSimpleESP8266_WS.h
src/BlinkerSimpleESP8266_PRO.h
src/BlinkerSimpleESP8266_MQTT.h
src/BlinkerSimpleESP32_WS.h
src/BlinkerSimpleESP32_PRO.h
src/BlinkerSimpleESP32_MQTT.h
src/BlinkerSimpleESP32_BLE.h
src/Adapters/BlinkerArduinoWS.h

View File

@@ -0,0 +1,64 @@
----------------------------- 删除下面的内容 -----------------------------
提问指南
=============
请按如下说明描述您的问题,以便您的问题能够得到解决。
1. 对照下方的 基本信息 表,在[]中填入x。
2. 对照下发的 设备信息 表,在[]中填入您的设备信息。
3. 检查是否使用最新的库及APP因为这个问题可能在最新的版本中已修复。
4. 描述您的问题。
5. 如果有设备端串口LOG信息请提供LOG信息(建议DEBUG ALL下查看LOG信息)。
6. 一个能正常运行的描述您问题的最小示例代码。不要提供您的整个项目代码。
7. 如果编译报错,请提供完整的报错信息。
8. 如果使用串口蓝牙模块或者blinker AT固件, 请提供接线电路示意。
9. 提交您的问题前请将该提问指南删除。
----------------------------- 删除上面的内容 -----------------------------
== 提问请到论坛 https://www.arduino.cn/forum-132-1.html ==
## 基本信息
- [] 这个问题满足提问指南
- [] 我阅读了开发文档
- [] 我使用了最新的库及APP进行测试但是问题仍然存在
- [] 我搜索过类似问题的解决方法但是仍然无法解决
- [] 有设备端的LOG信息
- [] 有编译报错信息
- [] 我已填写基本信息
## 设备信息
- 硬件: [ESP-12|wifiduino|Arduino UNO]
- 接入方式: [BLE|WIFI]
- package版本: [esp8266-arduino-2.5.0dev|esp32-1.0.1-rc3]
- blinker库版本: [arduino 0.3.0|py 0.2.0]
- 开发环境: [Arduino|linux]
- 操作系统: [Windows|Ubuntu|MacOS]
## IDE 中的设置
- Module: [Generic ESP8266 Module|Wemos D1 mini r2|Nodemcu|other]
- Flash Mode: [qio|dio|other]
- Flash Size: [4MB/1MB]
- lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|160MHz]
- Upload Using: [OTA|SERIAL]
- Upload Speed: [115200|other] (serial upload only)
## 手机信息及APP信息
- 手机品牌及型号
- android系统版本请注意是android系统版本不是厂商自己的版本号
- blinker App版本
## 问题描述
在这里填写您的问题
## 代码
在这里填写您出现问题的最小示例代码
## LOG信息
在这里填写您设备串口输出的LOG信息
## 编译信息
在这里填写您IDE编译报错信息

View File

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

View File

@@ -0,0 +1,44 @@
# blinker-library
Blinker library for embedded hardware. Works with Arduino, ESP8266, ESP32.
# Why named blinker
When we learn a new embedded hardware, we usually started with the sketch **Blink**.
We think **Blink** is the **hello world** of embedded hardware.
We aim to build a easy learn IoT solution project, which like **Blink** a led.
So we named this project **blinker** with this inspiration.
# 为什么叫 blinker
当我们接触学习一个新的嵌入式硬件平台时, 我们通常是从 **Blink** 点亮一颗LED开始的。
我们把 **Blink** 当作硬件开发第一课的 **hello world**
我们期望做像 **Blink** 点亮一颗LED 那样简单的物联网解决方案。
根据这个灵感, 我们将这个项目命名为 **blinker**
# What's blinker
[blinker](https://blinker.app/) 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.
[blinker](https://blinker.app/) 是一套跨硬件、跨平台的物联网解决方案提供APP端、设备端、服务器端支持使用公有云服务进行数据传输存储。可用于智能家居、数据监测等领域可以帮助用户更好更快地搭建物联网项目。
# Reference/参考
* [EN-英文](https://github.com/blinker-iot/blinker-doc/wiki/Blinker-Arduino-library-reference)
* [CN-中文](https://github.com/blinker-iot/blinker-doc/wiki/Blinker-Arduino-%E5%BA%93%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C)
* [CN-中文/官网](https://diandeng.tech/doc)
# Thanks
[WebSockets](https://github.com/Links2004/arduinoWebSockets) - for Blinker to build up a websocket server
[Adafruit_MQTT_Library](https://github.com/adafruit/Adafruit_MQTT_Library) - for Blinker to build up a mqtt client
[ArduinoJson](https://github.com/bblanchon/ArduinoJson) - for Blinker to format Json data
[OneButton](https://github.com/mathertel/OneButton) - for Blinker to manage button
[painlessMesh](https://gitlab.com/painlessMesh/painlessMesh/tree/master) - for Blinker to build up a mesh network
[Blynk](https://github.com/blynkkk/blynk-library)
Due to frequent updates of versions, individual items may not be added in time. We hope to understand. If you find out, please let us know.
# 感谢
[WebSockets](https://github.com/Links2004/arduinoWebSockets) - Blinker 用这个库建立了一个 websocket 服务器
[Adafruit_MQTT_Library](https://github.com/adafruit/Adafruit_MQTT_Library) - Blinker 用这个库建立了一个 MQTT 客户端
[ArduinoJson](https://github.com/bblanchon/ArduinoJson) - Blinker 用这个库解析 Json
[OneButton](https://github.com/mathertel/OneButton) - Blinker 用这个库管理按键
[painlessMesh](https://gitlab.com/painlessMesh/painlessMesh/tree/master) - Blinker 用这个库建立mesh网络
[Blynk](https://github.com/blynkkk/blynk-library)
由于版本更新频繁,个别项目可能没有及时添加,望理解,如有发现可告知我们

View File

@@ -0,0 +1,51 @@
image: Ubuntu1804
environment:
BUILD_HOME: "/home/appveyor"
TARGET_LIB: "$BUILD_HOME/Arduino/libraries/blinker-library"
OTHER_LIB: "https://github.com/adafruit/Adafruit_NeoPixel.git,https://github.com/adafruit/DHT-sensor-library.git,https://github.com/adafruit/Adafruit_Sensor.git,https://github.com/adafruit/Adafruit-BMP085-Library.git"
ARDUINO_VER: "arduino-1.8.9"
ARDUINO_URL: "https://downloads.arduino.cc/arduino-1.8.9-linux64.tar.xz"
ARDUINO_PATH: "$BUILD_HOME/$ARDUINO_VER"
matrix:
- TARGET: "ESP32"
LIB_VER: "arduino-esp32-1.0.4"
LIB_URL: "https://github.com/espressif/arduino-esp32/archive/1.0.4.zip"
HWLIB_PATH: "$BUILD_HOME/Arduino/hardware/espressif"
TOOL_PATH: "$HWLIB_PATH/esp32/tools"
BOARD_CONF: "espressif:esp32:nodemcu-32s:FlashFreq=80"
BUILD_CONF: "build.warn_data_percentage=75,runtime.tools.xtensa-esp32-elf-gcc.path=$HWLIB_PATH/esp32/tools/xtensa-esp32-elf,runtime.tools.xtensa-esp32-elf-gcc-1.22.0-80-g6c4433a-5.2.0.path=$HWLIB_PATH/esp32/tools/xtensa-esp32-elf,runtime.tools.esptool_py.path=$HWLIB_PATH/esp32/tools/esptool_py/2.6.1,runtime.tools.esptool_py-2.6.1.path=$HWLIB_PATH/esp32/tools/esptool_py/2.6.1,runtime.tools.mkspiffs.path=$HWLIB_PATH/esp32/tools/mkspiffs/0.2.3,runtime.tools.mkspiffs-0.2.3.path=$HWLIB_PATH/esp32/tools/mkspiffs/0.2.3"
- TARGET: "UNO"
BOARD_CONF: "arduino:avr:uno"
- TARGET: "ESP8266"
LIB_VER: "esp8266-2.5.2"
LIB_URL: "https://github.com/esp8266/Arduino/releases/download/2.5.2/esp8266-2.5.2.zip"
HWLIB_PATH: "$BUILD_HOME/Arduino/hardware/esp8266com"
TOOL_PATH: "$HWLIB_PATH/esp8266/tools"
BOARD_CONF: "esp8266com:esp8266:wifiduino:xtal=80,vt=flash,exception=disabled,ssl=all,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600"
BUILD_CONF: "build.warn_data_percentage=75,runtime.tools.xtensa-lx106-elf-gcc.path=$HWLIB_PATH/esp8266/tools/xtensa-lx106-elf,runtime.tools.xtensa-lx106-elf-gcc-2.5.0-3-20ed2b9.path=$HWLIB_PATH/esp8266/tools/xtensa-lx106-elf,runtime.tools.mkspiffs.path=$HWLIB_PATH/esp8266/tools/mkspiffs,runtime.tools.mkspiffs-2.5.0-3-20ed2b9.path=$HWLIB_PATH/esp8266/tools/mkspiffs,runtime.tools.python.path=$HWLIB_PATH/esp8266/tools/python,runtime.tools.python-3.7.2-post1.path=$HWLIB_PATH/esp8266/tools/python"
init:
- mkdir -p $BUILD_HOME/Arduino/libraries
- mkdir -p $BUILD_HOME/Arduino/hardware
- mkdir -p $BUILD_HOME/build_cache
clone_folder: $TARGET_LIB
install:
- chmod +x $TARGET_LIB/test/install.sh
- chmod +x $TARGET_LIB/test/build.sh
- $TARGET_LIB/test/install.sh
build_script:
- $TARGET_LIB/test/build.sh

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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() + "\"}");
}
}

View 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

View File

@@ -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;
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View 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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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
#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 rtData()
{
Blinker.sendRtData("data1", (int32_t)random(0,120));
Blinker.sendRtData("data2", random(0,120)/(float)1.5);
Blinker.printRtData();
}
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.attachRTData(rtData);
}
void loop()
{
Blinker.run();
}

View File

@@ -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();
}

View File

@@ -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");
}
}

View File

@@ -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");
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -0,0 +1,333 @@
/* *****************************************************************
*
* 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_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 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();
wsState = true;
if (colorW == 0) colorW = 255;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerDuerOS.powerState("off");
BlinkerDuerOS.print();
wsState = false;
colorW == 0;
}
pixelShow();
}
void duerColor(int32_t color)
{
BLINKER_LOG("need set color: ", color);
colorR = color >> 16 & 0xFF;
colorG = color >> 8 & 0xFF;
colorB = color & 0xFF;
BLINKER_LOG("colorR: ", colorR, ", colorG: ", colorG, ", colorB: ", colorB);
pixelShow();
BlinkerDuerOS.color(color);
BlinkerDuerOS.print();
}
void duerMode(const String & mode)
{
BLINKER_LOG("need set mode: ", mode);
// READING阅读
// SLEEP睡眠
// ALARM报警
// NIGHT_LIGHT夜灯
// ROMANTIC浪漫
// SUNDOWN日落
// SUNRISE日出
// RELAX :休闲/放松
// LIGHTING :照明
// SUN :太阳
// STAR :星星
// ENERGY_SAVING节能
// MOON月亮
// JUDI蹦迪
wsMode = mode;
BlinkerDuerOS.mode(mode);
BlinkerDuerOS.print();
}
void duercMode(const String & cmode)
{
BLINKER_LOG("need cancel mode: ", cmode);
wsMode = BLINKER_CMD_COMMON; // new mode
BlinkerDuerOS.mode(wsMode); // must response
BlinkerDuerOS.print();
}
void duerBright(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();
BlinkerDuerOS.brightness(colorW);
BlinkerDuerOS.print();
}
void duerRelativeBright(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();
BlinkerDuerOS.brightness(bright);
BlinkerDuerOS.print();
}
void duerColoTemp(int32_t colorTemp)
{
BLINKER_LOG("need set colorTemperature: ", colorTemp);
BlinkerDuerOS.colorTemp(colorTemp);
BlinkerDuerOS.print();
}
void duerRelativeColoTemp(int32_t colorTemp)
{
BLINKER_LOG("need set relative colorTemperature: ", colorTemp);
BlinkerDuerOS.colorTemp(colorTemp);
BlinkerDuerOS.print();
}
void duerQuery(int32_t queryCode)
{
BLINKER_LOG("DuerOS Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_TIME_NUMBER :
BLINKER_LOG("DuerOS Query time");
BlinkerDuerOS.time(millis());
BlinkerDuerOS.print();
break;
default :
BlinkerDuerOS.time(millis());
BlinkerDuerOS.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);
BlinkerDuerOS.attachPowerState(duerPowerState);
BlinkerDuerOS.attachColor(duerColor);
BlinkerDuerOS.attachMode(duerMode);
BlinkerDuerOS.attachCancelMode(duercMode);
BlinkerDuerOS.attachBrightness(duerBright);
BlinkerDuerOS.attachRelativeBrightness(duerRelativeBright);
BlinkerDuerOS.attachColorTemperature(duerColoTemp);
BlinkerDuerOS.attachRelativeColorTemperature(duerRelativeColoTemp);
BlinkerDuerOS.attachQuery(duerQuery);
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();
}

View File

@@ -0,0 +1,115 @@
/* *****************************************************************
*
* 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_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 duerPowerState(const String & state, uint8_t num)
{
BLINKER_LOG("need set outlet: ", num, ", power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerDuerOS.powerState("on", num);
BlinkerDuerOS.print();
oState[num] = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerDuerOS.powerState("off", num);
BlinkerDuerOS.print();
oState[num] = false;
if (num == 0)
{
for (uint8_t o_num = 0; o_num < 5; o_num++)
{
oState[o_num] = 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, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerDuerOS.attachPowerState(duerPowerState);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_WIFI
#define BLINKER_DUEROS_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";
#define BUTTON_1 "ButtonKey"
BlinkerButton Button1(BUTTON_1);
bool oState = false;
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.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.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.attachQuery(duerQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,137 @@
/* *****************************************************************
*
* 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_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 duerQuery(int32_t queryCode)
{
BLINKER_LOG("DuerOS Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_AQI_NUMBER :
BLINKER_LOG("DuerOS Query AQI");
BlinkerDuerOS.aqi(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_CO2_NUMBER :
BLINKER_LOG("DuerOS Query CO2");
BlinkerDuerOS.co2(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_PM10_NUMBER :
BLINKER_LOG("DuerOS Query PM10");
BlinkerDuerOS.pm10(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_PM25_NUMBER :
BLINKER_LOG("DuerOS Query PM25");
BlinkerDuerOS.pm25(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_HUMI_NUMBER :
BLINKER_LOG("DuerOS Query HUMI");
BlinkerDuerOS.humi(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_TEMP_NUMBER :
BLINKER_LOG("DuerOS Query TEMP");
BlinkerDuerOS.temp(20);
BlinkerDuerOS.print();
break;
case BLINKER_CMD_QUERY_TIME_NUMBER :
BLINKER_LOG("DuerOS Query time");
BlinkerDuerOS.time(millis());
BlinkerDuerOS.print();
break;
default :
BlinkerDuerOS.temp(20);
BlinkerDuerOS.humi(20);
BlinkerDuerOS.pm25(20);
BlinkerDuerOS.pm10(20);
BlinkerDuerOS.co2(20);
BlinkerDuerOS.aqi(20);
BlinkerDuerOS.time(millis());
BlinkerDuerOS.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);
BlinkerDuerOS.attachQuery(duerQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,256 @@
/* *****************************************************************
*
* 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_MIOT_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;
uint8_t setLevel;
void miotLevel(uint8_t level)
{
BLINKER_LOG("need set level: ", level);
// 0:AUTO MODE, 1-3 LEVEL
setLevel = level;
BlinkerMIOT.level(level);
BlinkerMIOT.print();
}
void miotTemp(uint8_t temp)
{
BLINKER_LOG("need set temp: ", temp);
BlinkerMIOT.temp(temp);
BlinkerMIOT.print();
}
void miotHumi(uint8_t humi)
{
BLINKER_LOG("need set humi: ", humi);
BlinkerMIOT.humi(humi);
BlinkerMIOT.print();
}
void miotMode(const String & mode, const String & state)
{
// eco ECO节能模式
// anion 负离子
// heater 辅热功能
// dryer 干燥功能
// sleep 睡眠模式
// soft 柔风功能
// uv UV杀菌
// unsb un-straight-blowing 防直吹
BLINKER_LOG("need set mode: ", mode, ", state:", state);
BlinkerMIOT.mode(mode, state);
BlinkerMIOT.print();
}
void miotHSwingState(const String & state)
{
BLINKER_LOG("need set HSwing state: ", state);
// horizontal-swing
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.hswing("on");
BlinkerMIOT.print();
hsState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.hswing("off");
BlinkerMIOT.print();
hsState = false;
}
}
void miotVSwingState(const String & state)
{
BLINKER_LOG("need set VSwing state: ", state);
// vertical-swing
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.vswing("on");
BlinkerMIOT.print();
vsState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.vswing("off");
BlinkerMIOT.print();
vsState = false;
}
}
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.hswing(hsState ? "on" : "off");
BlinkerMIOT.vswing(vsState ? "on" : "off");
BlinkerMIOT.eco("off");
BlinkerMIOT.anion("off");
BlinkerMIOT.heater("off");
BlinkerMIOT.dryer("off");
BlinkerMIOT.sleep("off");
BlinkerMIOT.soft("off");
BlinkerMIOT.uv("off");
BlinkerMIOT.unStraightBlow("off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.temp(16);
BlinkerMIOT.humi(20);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.hswing(hsState ? "on" : "off");
BlinkerMIOT.vswing(vsState ? "on" : "off");
BlinkerMIOT.eco("off");
BlinkerMIOT.anion("off");
BlinkerMIOT.heater("off");
BlinkerMIOT.dryer("off");
BlinkerMIOT.sleep("off");
BlinkerMIOT.soft("off");
BlinkerMIOT.uv("off");
BlinkerMIOT.unStraightBlow("off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.temp(16);
BlinkerMIOT.humi(20);
BlinkerMIOT.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);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachHSwing(miotHSwingState);
BlinkerMIOT.attachVSwing(miotVSwingState);
BlinkerMIOT.attachLevel(miotLevel);
BlinkerMIOT.attachMode(miotMode);
BlinkerMIOT.attachTemp(miotTemp);
BlinkerMIOT.attachHumi(miotHumi);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,200 @@
/* *****************************************************************
*
* 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.4 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_MIOT_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 miotLevel(uint8_t level)
{
BLINKER_LOG("need set level: ", level);
// 0:AUTO MODE, 1-3 LEVEL
setLevel = level;
BlinkerMIOT.level(level);
BlinkerMIOT.print();
}
void miotHSwingState(const String & state)
{
BLINKER_LOG("need set HSwing state: ", state);
// horizontal-swing
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.hswing("on");
BlinkerMIOT.print();
hsState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.hswing("off");
BlinkerMIOT.print();
hsState = false;
}
}
void miotVSwingState(const String & state)
{
BLINKER_LOG("need set VSwing state: ", state);
// vertical-swing
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.vswing("on");
BlinkerMIOT.print();
vsState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.vswing("off");
BlinkerMIOT.print();
vsState = false;
}
}
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.hswing(hsState ? "on" : "off");
BlinkerMIOT.vswing(vsState ? "on" : "off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.hswing(hsState ? "on" : "off");
BlinkerMIOT.vswing(vsState ? "on" : "off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.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);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachHSwing(miotHSwingState);
BlinkerMIOT.attachVSwing(miotVSwingState);
BlinkerMIOT.attachLevel(miotLevel);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,308 @@
/* *****************************************************************
*
* 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_MIOT_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 2
#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;
uint8_t wsMode = BLINKER_CMD_MIOT_DAY;
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();
}
uint32_t getColor()
{
uint32_t color = colorR << 16 | colorG << 8 | colorB;
return color;
}
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
wsState = true;
if (colorW == 0) colorW = 255;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
wsState = false;
colorW = 0;
}
pixelShow();
}
void miotColor(int32_t color)
{
BLINKER_LOG("need set color: ", color);
colorR = color >> 16 & 0xFF;
colorG = color >> 8 & 0xFF;
colorB = color & 0xFF;
BLINKER_LOG("colorR: ", colorR, ", colorG: ", colorG, ", colorB: ", colorB);
pixelShow();
BlinkerMIOT.color(color);
BlinkerMIOT.print();
}
void miotMode(uint8_t mode)
{
BLINKER_LOG("need set mode: ", mode);
if (mode == BLINKER_CMD_MIOT_DAY) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_NIGHT) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_COLOR) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_WARMTH) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_TV) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_READING) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_COMPUTER) {
// Your mode function
}
wsMode = mode;
BlinkerMIOT.mode(mode);
BlinkerMIOT.print();
}
void miotBright(const String & bright)
{
BLINKER_LOG("need set brightness: ", bright);
colorW = bright.toInt();
BLINKER_LOG("now set brightness: ", colorW);
pixelShow();
BlinkerMIOT.brightness(colorW);
BlinkerMIOT.print();
}
void miotColoTemp(int32_t colorTemp)
{
BLINKER_LOG("need set colorTemperature: ", colorTemp);
BlinkerMIOT.colorTemp(colorTemp);
BlinkerMIOT.print();
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(wsState ? "on" : "off");
BlinkerMIOT.color(0);
BlinkerMIOT.mode(0);
BlinkerMIOT.colorTemp(1000);
BlinkerMIOT.brightness(1);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(wsState ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_COLOR_NUMBER :
BLINKER_LOG("MIOT Query Color");
BlinkerMIOT.color(0);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_MODE_NUMBER :
BLINKER_LOG("MIOT Query Mode");
BlinkerMIOT.mode(0);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_COLORTEMP_NUMBER :
BLINKER_LOG("MIOT Query ColorTemperature");
BlinkerMIOT.colorTemp(1000);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_BRIGHTNESS_NUMBER :
BLINKER_LOG("MIOT Query Brightness");
BlinkerMIOT.brightness(1);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(wsState ? "on" : "off");
BlinkerMIOT.color(0);
BlinkerMIOT.mode(0);
BlinkerMIOT.colorTemp(1000);
BlinkerMIOT.brightness(1);
BlinkerMIOT.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);
BLINKER_DEBUG.debugAll();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachColor(miotColor);
BlinkerMIOT.attachMode(miotMode);
BlinkerMIOT.attachBrightness(miotBright);
BlinkerMIOT.attachColorTemperature(miotColoTemp);
BlinkerMIOT.attachQuery(miotQuery);
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();
}

View File

@@ -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_MIOT_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 miotPowerState(const String & state, uint8_t num)
{
BLINKER_LOG("need set outlet: ", num, ", power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on", num);
BlinkerMIOT.print();
oState[num] = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off", num);
BlinkerMIOT.print();
oState[num] = false;
if (num == 0)
{
for (uint8_t o_num = 0; o_num < 5; o_num++)
{
oState[o_num] = false;
}
}
}
}
void miotQuery(int32_t queryCode, uint8_t num)
{
BLINKER_LOG("MIOT Query outlet: ", num,", codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num);
BlinkerMIOT.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);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_MIOT_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 miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.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);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,107 @@
/* *****************************************************************
*
* 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_MIOT_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 miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.temp(20);
BlinkerMIOT.humi(20);
BlinkerMIOT.pm25(20);
BlinkerMIOT.co2(20);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.temp(20);
BlinkerMIOT.humi(20);
BlinkerMIOT.pm25(20);
BlinkerMIOT.co2(20);
BlinkerMIOT.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);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,90 @@
/* *****************************************************************
*
* 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.5.0 or later ESP8266/Arduino package,
* if use ESP8266 with Blinker.
* https://github.com/esp8266/Arduino/releases
*
* Make sure installed 1.0.2 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.5.0 或更新的 ESP8266/Arduino 支持包。
* https://github.com/esp8266/Arduino/releases
*
* 如果使用 ESP32 接入 Blinker,
* 请确保安装了 1.0.2 或更新的 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 airData(const String & data)
{
BLINKER_LOG("air: ", 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));
Blinker.air();
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.attachAir(airData);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,97 @@
/* *****************************************************************
*
* 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);
}
void weatherForecastData(const String & data)
{
BLINKER_LOG("weather: ", 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));
Blinker.weather();
Blinker.weatherForecast();
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);
Blinker.attachWeatherForecast(weatherForecastData);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,99 @@
/* *****************************************************************
*
* 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_APCONFIG
#include <Blinker.h>
// Download OneButton library here:
// https://github.com/mathertel/OneButton
#include "OneButton.h"
#if defined(ESP32)
#define BLINKER_BUTTON_PIN 4
#else
#define BLINKER_BUTTON_PIN D7
#endif
// button trigged when pin input level is LOW
OneButton button(BLINKER_BUTTON_PIN, true);
char auth[] = "Your Device Secret Key";
void deviceReset()
{
// Reset device ,erase WiFi config.
Blinker.reset();
}
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);
button.attachLongPressStop(deviceReset);
}
void loop()
{
Blinker.run();
button.tick();
}

View File

@@ -0,0 +1,98 @@
/* *****************************************************************
*
* 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_APCONFIG_V2
#include <Blinker.h>
// Download OneButton library here:
// https://github.com/mathertel/OneButton
#include "OneButton.h"
#if defined(ESP32)
#define BLINKER_BUTTON_PIN 4
#else
#define BLINKER_BUTTON_PIN D7
#endif
// button trigged when pin input level is LOW
OneButton button(BLINKER_BUTTON_PIN, true);
void deviceReset()
{
// Reset device ,erase WiFi config.
Blinker.reset();
}
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();
Blinker.attachData(dataRead);
button.attachLongPressStop(deviceReset);
}
void loop()
{
Blinker.run();
button.tick();
}

View File

@@ -0,0 +1,99 @@
/* *****************************************************************
*
* 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>
// Download OneButton library here:
// https://github.com/mathertel/OneButton
#include "OneButton.h"
#if defined(ESP32)
#define BLINKER_BUTTON_PIN 4
#else
#define BLINKER_BUTTON_PIN D7
#endif
// button trigged when pin input level is LOW
OneButton button(BLINKER_BUTTON_PIN, true);
char auth[] = "Your Device Secret Key";
void deviceReset()
{
// Reset device ,erase WiFi config.
Blinker.reset();
}
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);
button.attachLongPressStop(deviceReset);
}
void loop()
{
Blinker.run();
button.tick();
}

View File

@@ -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
#define BLINKER_WIFI_MULTI
#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";
char ssid1[] = "Your WiFi network SSID or name";
char pswd1[] = "Your WiFi network WPA password or WEP key";
char ssid2[] = "Your WiFi network SSID or name";
char pswd2[] = "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.addAP(ssid2, pswd2);
Blinker.addAP(ssid1, pswd1);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop() {
Blinker.run();
}

View File

@@ -0,0 +1,190 @@
/* *****************************************************************
*
* 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
}
uint32_t run_time = millis();
uint8_t humis[10] = {19,18,17,18,21,20,19,18,17,16};
uint8_t humi_num = 0;
void auto_check()
{
if (millis() - run_time >= 10000)
{
run_time = millis();
Blinker.autoInput("num-abc", humis[humi_num]);
Blinker.autoRun();
humi_num = (humi_num + 1) % 10;
}
}
void loop()
{
Blinker.run();
auto_check();
}

View File

@@ -0,0 +1,135 @@
/* *****************************************************************
*
* 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
*
*
* *****************************************************************/
/*
*
* This example not complete at all, TODO.
*
*/
#define BLINKER_PRINT Serial
#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;
bool switch_state = false;
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");
int counter = 0;
bool switch_state = false;
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 switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
switch_state = true;
BUILTIN_SWITCH.print("on");
}
else {
digitalWrite(LED_BUILTIN, LOW);
switch_state = false;
BUILTIN_SWITCH.print("off");
}
Blinker.autoInput("switch", switch_state ? 1.0 : 0.0);
Blinker.autoRun();
}
void heartbeat()
{
if (switch_state) BUILTIN_SWITCH.print("on");
else BUILTIN_SWITCH.print("off");
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, ssid, pswd);
Blinker.attachData(dataRead);
Blinker.attachHeartbeat(heartbeat);
Button1.attach(button1_callback);
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
Blinker.autoRun();
}

View File

@@ -0,0 +1,141 @@
/* *****************************************************************
*
* 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>
#define BUTTON_1 "ButtonKey"
BlinkerButton Button1(BUTTON_1);
void button1_callback(const String & state)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get button state: ", state);
if (state == BLINKER_CMD_BUTTON_TAP) {
BLINKER_LOG("Button tap!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print();
}
else if (state == BLINKER_CMD_BUTTON_PRESSED) {
BLINKER_LOG("Button pressed!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print();
}
else if (state == BLINKER_CMD_BUTTON_RELEASED) {
BLINKER_LOG("Button released!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print();
}
else if (state == BLINKER_CMD_ON) {
BLINKER_LOG("Toggle on!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print("on");
}
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.text("Your button name", "describe");
Button1.print("off");
}
else {
BLINKER_LOG("Get user setting: ", state);
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
Button1.print();
}
}
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();
Button1.attach(button1_callback);
Blinker.attachData(dataRead);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,144 @@
/* *****************************************************************
*
* 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 BUTTON_1 "ButtonKey"
BlinkerButton Button1(BUTTON_1);
void button1_callback(const String & state)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get button state: ", state);
if (state == BLINKER_CMD_BUTTON_TAP) {
BLINKER_LOG("Button tap!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
Button1.print();
}
else if (state == BLINKER_CMD_BUTTON_PRESSED) {
BLINKER_LOG("Button pressed!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
Button1.print();
}
else if (state == BLINKER_CMD_BUTTON_RELEASED) {
BLINKER_LOG("Button released!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print();
}
else if (state == BLINKER_CMD_ON) {
BLINKER_LOG("Toggle on!");
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print("on");
}
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.text("Your button name", "describe");
Button1.print("off");
}
else {
BLINKER_LOG("Get user setting: ", state);
Button1.icon("icon_1");
Button1.color("#FFFFFF");
Button1.text("Your button name or describe");
// Button1.text("Your button name", "describe");
Button1.print();
}
}
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);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_BLE
#include <Blinker.h>
bool switch_state = false;
void switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
switch_state = true;
digitalWrite(LED_BUILTIN, HIGH);
BUILTIN_SWITCH.print("on");
}
else if (state == BLINKER_CMD_OFF) {
switch_state = false;
digitalWrite(LED_BUILTIN, LOW);
BUILTIN_SWITCH.print("off");
}
}
void heartbeat()
{
if (switch_state) BUILTIN_SWITCH.print("on");
else BUILTIN_SWITCH.print("off");
}
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();
Blinker.attachData(dataRead);
Blinker.attachHeartbeat(heartbeat);
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,117 @@
/* *****************************************************************
*
* 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";
bool switch_state = false;
void switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
switch_state = true;
digitalWrite(LED_BUILTIN, HIGH);
BUILTIN_SWITCH.print("on");
}
else if (state == BLINKER_CMD_OFF) {
switch_state = false;
digitalWrite(LED_BUILTIN, LOW);
BUILTIN_SWITCH.print("off");
}
}
void heartbeat()
{
if (switch_state) BUILTIN_SWITCH.print("on");
else BUILTIN_SWITCH.print("off");
}
String summary()
{
String data = "online, switch: " + STRING_format(switch_state ? "on" : "off");
return data;
}
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);
Blinker.attachHeartbeat(heartbeat);
Blinker.attachSummary(summary);
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,98 @@
/* *****************************************************************
*
* 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");
BlinkerImage Image1("img_abc");
int counter = 0;
void image1_callback(int32_t num)
{
BLINKER_LOG("image is tapped, number is : ", num);
}
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
Image1.print(digitalRead(LED_BUILTIN) ? 1 : 0);
}
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);
Image1.attach(image1_callback);
}
void loop() {
Blinker.run();
}

View File

@@ -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_BLE
#include <Blinker.h>
#define JOY_1 "JOYKey"
BlinkerJoystick JOY1(JOY_1);
void joystick1_callback(uint8_t xAxis, uint8_t yAxis)
{
BLINKER_LOG("Joystick1 X axis: ", xAxis);
BLINKER_LOG("Joystick1 Y axis: ", yAxis);
}
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();
Blinker.attachData(dataRead);
JOY1.attach(joystick1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,92 @@
/* *****************************************************************
*
* 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.5.0 or later ESP8266/Arduino package,
* if use ESP8266 with Blinker.
* https://github.com/esp8266/Arduino/releases
*
* Make sure installed 1.0.2 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.5.0 或更新的 ESP8266/Arduino 支持包。
* https://github.com/esp8266/Arduino/releases
*
* 如果使用 ESP32 接入 Blinker,
* 请确保安装了 1.0.2 或更新的 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 JOY_1 "JOYKey"
BlinkerJoystick JOY1(JOY_1);
void joystick1_callback(uint8_t xAxis, uint8_t yAxis)
{
BLINKER_LOG("Joystick1 X axis: ", xAxis);
BLINKER_LOG("Joystick1 Y axis: ", yAxis);
}
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);
JOY1.attach(joystick1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,79 @@
/* *****************************************************************
*
* 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>
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Blinker.notify("!Button Pressed!");
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();
Blinker.attachData(dataRead);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,83 @@
/* *****************************************************************
*
* 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);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Blinker.notify("!Button Pressed!");
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();
}

View File

@@ -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_BLE
#include <Blinker.h>
#define Number_1 "NUMKey"
BlinkerNumber Number1(Number_1);
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Number1.icon("icon_1");
Number1.color("#FFFFFF");
Number1.unit("ms");
Number1.print(BlinkerTime);
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();
Blinker.attachData(dataRead);
}
void loop()
{
Blinker.run();
}

View File

@@ -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";
#define Number_1 "NUMKey"
BlinkerNumber Number1(Number_1);
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Number1.icon("icon_1");
Number1.color("#FFFFFF");
Number1.unit("ms");
Number1.print(BlinkerTime);
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();
}

View File

@@ -0,0 +1,84 @@
/* *****************************************************************
*
* 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));
Blinker.push("Hello blinker!");
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);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,76 @@
/* *****************************************************************
*
* 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>
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();
Blinker.attachData(dataRead);
}
void loop()
{
Blinker.run();
}

View File

@@ -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);
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);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_BLE
#include <Blinker.h>
#define RGB_1 "RGBKey"
BlinkerRGB RGB1(RGB_1);
void rgb1_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);
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
RGB1.brightness(random(0, 255));
RGB1.print(random(0, 255), random(0, 255), random(0, 255));
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin();
Blinker.attachData(dataRead);
RGB1.attach(rgb1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,98 @@
/* *****************************************************************
*
* 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 RGB_1 "RGBKey"
BlinkerRGB RGB1(RGB_1);
void rgb1_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);
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
RGB1.brightness(random(0, 255));
RGB1.print(random(0, 255), random(0, 255), random(0, 255));
}
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);
RGB1.attach(rgb1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,84 @@
/* *****************************************************************
*
* 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));
Blinker.sms("Hello blinker!");
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);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_BLE
#include <Blinker.h>
#define Slider_1 "SliderKey"
BlinkerSlider Slider1(Slider_1);
void slider1_callback(int32_t value)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get slider value: ", value);
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Slider1.color("#FFFFFF");
Slider1.print(random(0, 128));
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin();
Blinker.attachData(dataRead);
Slider1.attach(slider1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -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";
#define Slider_1 "SliderKey"
BlinkerSlider Slider1(Slider_1);
void slider1_callback(int32_t value)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("get slider value: ", value);
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Slider1.color("#FFFFFF");
Slider1.print(random(0, 128));
}
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);
Slider1.attach(slider1_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,117 @@
/* *****************************************************************
*
* 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";
bool switch_state = false;
void switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
switch_state = true;
digitalWrite(LED_BUILTIN, HIGH);
BUILTIN_SWITCH.print("on");
}
else if (state == BLINKER_CMD_OFF) {
switch_state = false;
digitalWrite(LED_BUILTIN, LOW);
BUILTIN_SWITCH.print("off");
}
}
void heartbeat()
{
if (switch_state) BUILTIN_SWITCH.print("on");
else BUILTIN_SWITCH.print("off");
}
String summary()
{
String data = "online, switch: " + STRING_format(switch_state ? "on" : "off");
return data;
}
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);
Blinker.attachHeartbeat(heartbeat);
Blinker.attachSummary(summary);
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -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_BLE
#include <Blinker.h>
void switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BUILTIN_SWITCH.print("on");
}
else {
digitalWrite(LED_BUILTIN, LOW);
BUILTIN_SWITCH.print("off");
}
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin();
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,84 @@
/* *****************************************************************
*
* 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 switch_callback(const String & state)
{
BLINKER_LOG("get switch state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
BUILTIN_SWITCH.print("on");
}
else {
digitalWrite(LED_BUILTIN, LOW);
BUILTIN_SWITCH.print("off");
}
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
BUILTIN_SWITCH.attach(switch_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,84 @@
/* *****************************************************************
*
* 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>
#define TEXTE_1 "TextKey"
BlinkerText Text1(TEXTE_1);
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Text1.print("os time", BlinkerTime);
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();
Blinker.attachData(dataRead);
}
void loop()
{
Blinker.run();
}

View File

@@ -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";
#define TEXTE_1 "TextKey"
BlinkerText Text1(TEXTE_1);
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
Text1.print("os time", BlinkerTime);
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();
}

View File

@@ -0,0 +1,133 @@
/* *****************************************************************
*
* 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 Tab_1 "TabKey"
BlinkerTab Tab1(Tab_1);
bool tab[5] = { false };
void tab1_callback(uint8_t tab_set)
{
BLINKER_LOG("get tab set: ", tab_set);
switch (tab_set)
{
case BLINKER_CMD_TAB_0 :
tab[0] = true;
BLINKER_LOG("tab 0 set");
break;
case BLINKER_CMD_TAB_1 :
tab[1] = true;
BLINKER_LOG("tab 1 set");
break;
case BLINKER_CMD_TAB_2 :
tab[2] = true;
BLINKER_LOG("tab 2 set");
break;
case BLINKER_CMD_TAB_3 :
tab[3] = true;
BLINKER_LOG("tab 3 set");
break;
case BLINKER_CMD_TAB_4 :
tab[4] = true;
BLINKER_LOG("tab 4 set");
break;
default:
break;
}
}
void tab1_feedback()
{
for(uint8_t num = 0; num < 5; num++)
{
if (tab[num])
{
Tab1.tab(num);
tab[num] = false;
}
}
Tab1.print();
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
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);
Tab1.attach(tab1_callback, tab1_feedback);
}
void loop()
{
Blinker.run();
}

View File

@@ -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";
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("Now second: ", Blinker.second());
BLINKER_LOG("Now minute: ", Blinker.minute());
BLINKER_LOG("Now hour: ", Blinker.hour());
BLINKER_LOG("Now wday: ", Blinker.wday());
BLINKER_LOG("Now month: ", Blinker.month());
BLINKER_LOG("Now mday: ", Blinker.mday());
BLINKER_LOG("Now year: ", Blinker.year());
BLINKER_LOG("Now yday: ", Blinker.yday());
BLINKER_LOG("Now ntp time: ", Blinker.time());
}
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.setTimezone(8.0);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,84 @@
/* *****************************************************************
*
* 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));
Blinker.wechat("Hello blinker!","state","message");
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);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,99 @@
/* *****************************************************************
*
* 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>
// Download Adafruit_NeoPixel library here:
// https://github.com/adafruit/Adafruit_NeoPixel
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 13
#define NUMPIXELS 9
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define RGB_1 "RGBKey"
BlinkerRGB WS2812(RGB_1);
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);
pixels.setBrightness(bright_value);
for(int i = 0; i < NUMPIXELS; i++){
pixels.setPixelColor(i, r_value, g_value, b_value);
}
pixels.show();
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin();
pixels.begin();
WS2812.attach(ws2812_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,103 @@
/* *****************************************************************
*
* 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";
// Download Adafruit_NeoPixel library here:
// https://github.com/adafruit/Adafruit_NeoPixel
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 13
#define NUMPIXELS 9
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define RGB_1 "RGBKey"
BlinkerRGB WS2812(RGB_1);
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);
pixels.setBrightness(bright_value);
for(int i = 0; i < NUMPIXELS; i++){
pixels.setPixelColor(i, r_value, g_value, b_value);
}
pixels.show();
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
pixels.begin();
WS2812.attach(ws2812_callback);
}
void loop()
{
Blinker.run();
}

View File

@@ -0,0 +1,345 @@
#######################################
# Data types (KEYWORD1)
#######################################
Blinker KEYWORD1
BlinkerButton KEYWORD1
BlinkerRGB KEYWORD1
BlinkerSlider KEYWORD1
BlinkerNumber KEYWORD1
BlinkerImage KEYWORD1
BlinkerTab KEYWORD1
BlinkerText KEYWORD1
BlinkerJoystick KEYWORD1
BlinkerBridge KEYWORD1
BUILTIN_SWITCH KEYWORD1
BLINKER_DEBUG KEYWORD1
BlinkerTimer KEYWORD1
BlinkerTicker KEYWORD1
BlinkerAliGenie KEYWORD1
BlinkerDuerOS KEYWORD1
BlinkerMIOT KEYWORD1
BlinkerUpdater KEYWORD1
BlinkerEvent KEYWORD1
BLINKER_PROTOCOL_MQTT KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
BLINKER_TAST_INIT KEYWORD2
deviceName KEYWORD2
auth KEYWORD2
ssid KEYWORD2
pswd KEYWORD2
begin KEYWORD2
connect KEYWORD2
disconnect KEYWORD2
connected KEYWORD2
connected KEYWORD2
available KEYWORD2
readString KEYWORD2
print KEYWORD2
printObject KEYWORD2
delay KEYWORD2
notify KEYWORD2
attachDataStorage KEYWORD2
attachHeartbeat KEYWORD2
attachParse KEYWORD2
attachClick KEYWORD2
attachDoubleClick KEYWORD2
attachLongPressStart KEYWORD2
attachLongPressStop KEYWORD2
attachDuringLongPress KEYWORD2
attachLongPressPowerdown KEYWORD2
attachLongPressReset KEYWORD2
attachNoButtonReset KEYWORD2
attachAQI KEYWORD2
attachAir KEYWORD2
attachWeather KEYWORD2
attachWeatherForecast KEYWORD2
attachConfigGet KEYWORD2
attachDataGet KEYWORD2
pressedTime KEYWORD2
attach KEYWORD2
icon KEYWORD2
color KEYWORD2
text KEYWORD2
brightness KEYWORD2
unit KEYWORD2
ahrs KEYWORD2
attachAhrs KEYWORD2
detachAhrs KEYWORD2
gps KEYWORD2
event KEYWORD2
vibrate KEYWORD2
timingState KEYWORD2
loopState KEYWORD2
countdownState KEYWORD2
deleteTiming KEYWORD2
deleteLoop KEYWORD2
deleteCountdown KEYWORD2
deleteTimer KEYWORD2
setTimezone KEYWORD2
time KEYWORD2
second KEYWORD2
minute KEYWORD2
hour KEYWORD2
wday KEYWORD2
mday KEYWORD2
yday KEYWORD2
month KEYWORD2
year KEYWORD2
bridge KEYWORD2
bridgeAvailable KEYWORD2
bridgeRead KEYWORD2
bridgePrint KEYWORD2
bridgeBeginFormat KEYWORD2
bridgeEndFormat KEYWORD2
configUpdate KEYWORD2
configGet KEYWORD2
configDelete KEYWORD2
timeSlotData KEYWORD2
textData KEYWORD2
jsonData KEYWORD2
dataStorage KEYWORD2
dataUpdate KEYWORD2
dataGet KEYWORD2
dataDelete KEYWORD2
sms KEYWORD2
push KEYWORD2
wechat KEYWORD2
weather KEYWORD2
weatherForecast KEYWORD2
aqi KEYWORD2
air KEYWORD2
status KEYWORD2
flush KEYWORD2
init KEYWORD2
beginAuto KEYWORD2
autoInput KEYWORD2
autoInput KEYWORD2
autoRun KEYWORD2
setType KEYWORD2
type KEYWORD2
reset KEYWORD2
tick KEYWORD2
lang KEYWORD2
lat KEYWORD2
warning KEYWORD2
error KEYWORD2
message KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_LOG KEYWORD2
BLINKER_ERR_LOG KEYWORD2
BLINKER_LOG_FreeHeap KEYWORD2
BLINKER_LOG_FreeHeap_ALL KEYWORD2
BLINKER_F KEYWORD2
BLINKER_PRINT KEYWORD2
BLINKER_DEBUG_ALL KEYWORD2
BLINKER_ESP_SMARTCONFIG KEYWORD2
BLINKER_APCONFIG KEYWORD2
BLINKER_APCONFIG_V2 KEYWORD2
BLINKER_WIFI_MULTI KEYWORD2
BLINKER_BLE KEYWORD2
BLINKER_WIFI KEYWORD2
BLINKER_WITHOUT_SSL KEYWORD2
BLINKER_WIFI_AUTO KEYWORD2
BLINKER_LOWPOWER KEYWORD2
BLINKER_LOWPOWER_AIR202 KEYWORD2
BLINKER_MQTT KEYWORD2
BLINKER_MQTT_AUTO KEYWORD2
BLINKER_WIFI_GATEWAY KEYWORD2
BLINKER_WIFI_SUBDEVICE KEYWORD2
BLINKER_PRO KEYWORD2
BLINKER_PRO_ESP KEYWORD2
BLINKER_ESP_TASK KEYWORD2
BLINKER_AT_MQTT KEYWORD2
BLINKER_AT_PRO KEYWORD2
BLINKER_NBIOT_WH KEYWORD2
BLINKER_GPRS_AIR202 KEYWORD2
BLINKER_GPRS KEYWORD2
BLINKER_NBIOT_SIM7020 KEYWORD2
BLINKER_NBIOT_SIM7000 KEYWORD2
BLINKER_QRCODE_NBIOT_SIM7020 KEYWORD2
BLINKER_QRCODE_NBIOT_SIM7000 KEYWORD2
BLINKER_PRO_SIM7020 KEYWORD2
BLINKER_PRO_AIR202 KEYWORD2
BLINKER_ESP_AT KEYWORD2
BLINKER_NO_BUTTON KEYWORD2
BLINKER_BUTTON KEYWORD2
BLINKER_BUTTON_PIN KEYWORD2
BLINKER_BUTTON_PULLDOWN KEYWORD2
BLINKER_BUTTON_LONGPRESS_POWERDOWN KEYWORD2
BLINKER_MAX_SEND_SIZE KEYWORD2
BLINKER_MAX_READ_SIZE KEYWORD2
BLINKER_ALIGENIE_LIGHT KEYWORD2
BLINKER_ALIGENIE_OUTLET KEYWORD2
BLINKER_ALIGENIE_MULTI_OUTLET KEYWORD2
BLINKER_ALIGENIE_SWITCH KEYWORD2
BLINKER_ALIGENIE_SENSOR KEYWORD2
BLINKER_ALIGENIE_FAN KEYWORD2
BLINKER_ALIGENIE_AIRCONDITION KEYWORD2
BLINKER_DUEROS_LIGHT KEYWORD2
BLINKER_DUEROS_OUTLET KEYWORD2
BLINKER_DUEROS_MULTI_OUTLET KEYWORD2
BLINKER_DUEROS_SWITCH KEYWORD2
BLINKER_DUEROS_SENSOR KEYWORD2
BLINKER_DUEROS_FAN KEYWORD2
BLINKER_DUEROS_AIRCONDITION KEYWORD2
BLINKER_MIOT_LIGHT KEYWORD2
BLINKER_MIOT_OUTLET KEYWORD2
BLINKER_MIOT_MULTI_OUTLET KEYWORD2
BLINKER_MIOT_SWITCH KEYWORD2
BLINKER_MIOT_SENSOR KEYWORD2
BLINKER_MIOT_FAN KEYWORD2
BLINKER_MIOT_AIRCONDITION KEYWORD2
BLINKER_CMD_READING KEYWORD2
BLINKER_CMD_MOVIE KEYWORD2
BLINKER_CMD_SLEEP KEYWORD2
BLINKER_CMD_HOLIDAY KEYWORD2
BLINKER_CMD_MUSIC KEYWORD2
BLINKER_CMD_COMMON KEYWORD2
BLINKER_CMD_ON KEYWORD2
BLINKER_CMD_OFF KEYWORD2
BLINKER_CMD_QUERY_ALL_NUMBER KEYWORD2
BLINKER_CMD_QUERY_POWERSTATE_NUMBER KEYWORD2
BLINKER_CMD_QUERY_COLOR_NUMBER KEYWORD2
BLINKER_CMD_QUERY_MODE_NUMBER KEYWORD2
BLINKER_CMD_QUERY_COLORTEMP_NUMBER KEYWORD2
BLINKER_CMD_QUERY_BRIGHTNESS_NUMBER KEYWORD2
BLINKER_CMD_QUERY_TEMP_NUMBER KEYWORD2
BLINKER_CMD_QUERY_HUMI_NUMBER KEYWORD2
BLINKER_CMD_QUERY_PM25_NUMBER KEYWORD2
BLINKER_CMD_QUERY_PM10_NUMBER KEYWORD2
BLINKER_CMD_QUERY_CO2_NUMBER KEYWORD2
BLINKER_CMD_QUERY_AQI_NUMBER KEYWORD2
BLINKER_CMD_TAB_0 KEYWORD2
BLINKER_CMD_TAB_1 KEYWORD2
BLINKER_CMD_TAB_2 KEYWORD2
BLINKER_CMD_TAB_3 KEYWORD2
BLINKER_CMD_TAB_4 KEYWORD2
BLINKER_CMD_ALIGENIE_READING KEYWORD2
BLINKER_CMD_ALIGENIE_MOVIE KEYWORD2
BLINKER_CMD_ALIGENIE_SLEEP KEYWORD2
BLINKER_CMD_ALIGENIE_HOLIDAY KEYWORD2
BLINKER_CMD_ALIGENIE_MUSIC KEYWORD2
BLINKER_CMD_ALIGENIE_COMMON KEYWORD2
BLINKER_CMD_DUEROS_READING KEYWORD2
BLINKER_CMD_DUEROS_SLEEP KEYWORD2
BLINKER_CMD_DUEROS_ALARM KEYWORD2
BLINKER_CMD_DUEROS_NIGHT_LIGHT KEYWORD2
BLINKER_CMD_DUEROS_ROMANTIC KEYWORD2
BLINKER_CMD_DUEROS_SUNDOWN KEYWORD2
BLINKER_CMD_DUEROS_SUNRISE KEYWORD2
BLINKER_CMD_DUEROS_RELAX KEYWORD2
BLINKER_CMD_DUEROS_LIGHTING KEYWORD2
BLINKER_CMD_DUEROS_SUN KEYWORD2
BLINKER_CMD_DUEROS_STAR KEYWORD2
BLINKER_CMD_DUEROS_ENERGY_SAVING KEYWORD2
BLINKER_CMD_DUEROS_MOON KEYWORD2
BLINKER_CMD_DUEROS_JUDI KEYWORD2
BLINKER_CMD_MIOT_DAY KEYWORD2
BLINKER_CMD_MIOT_NIGHT KEYWORD2
BLINKER_CMD_MIOT_COLOR KEYWORD2
BLINKER_CMD_MIOT_WARMTH KEYWORD2
BLINKER_CMD_MIOT_TV KEYWORD2
BLINKER_CMD_MIOT_READING KEYWORD2
BLINKER_CMD_MIOT_COMPUTER KEYWORD2
attachPowerState KEYWORD2
attachColor KEYWORD2
attachMode KEYWORD2
attachCancelMode KEYWORD2
attachBrightness KEYWORD2
attachRelativeBrightness KEYWORD2
attachColorTemperature KEYWORD2
attachRelativeColorTemperature KEYWORD2
attachQuery KEYWORD2
attachSummary KEYWORD2
attachData KEYWORD2
attachAir202Reset KEYWORD2
attachSIM7020Reset KEYWORD2
attachSleep KEYWORD2
attachLowPower KEYWORD2
attachHSwing KEYWORD2
attachVSwing KEYWORD2
attachLevel KEYWORD2
attachRelativeLevel KEYWORD2
attachTemp KEYWORD2
attachRelativeTemp KEYWORD2
attachECO KEYWORD2
attachAnion KEYWORD2
attachHeater KEYWORD2
attachDryer KEYWORD2
attachSleep KEYWORD2
attachSoft KEYWORD2
attachUV KEYWORD2
attachUnStraightBlow KEYWORD2
attachHumi KEYWORD2
hswing KEYWORD2
vswing KEYWORD2
eco KEYWORD2
anion KEYWORD2
heater KEYWORD2
dryer KEYWORD2
sleep KEYWORD2
soft KEYWORD2
uv KEYWORD2
unStraightBlow KEYWORD2
level KEYWORD2
STRING_format KEYWORD2
powerState KEYWORD2
colorTemp KEYWORD2
temp KEYWORD2
humi KEYWORD2
pm25 KEYWORD2
pm10 KEYWORD2
ppm KEYWORD2
co2 KEYWORD2
mode KEYWORD2
tab KEYWORD2
report KEYWORD2
stream KEYWORD2
debugAll KEYWORD2
BLINKER_OTA_VERSION_CODE KEYWORD2
attachGatewayAvailable KEYWORD2
attachGatewayRead KEYWORD2
attachGatewayPrint KEYWORD2
attachSubAvailable KEYWORD2
attachSubRead KEYWORD2
attachSubPrint KEYWORD2
configType KEYWORD2
apConfigInit KEYWORD2
esptouchInit KEYWORD2
#######################################
# Literals (LITERAL1)
#######################################
Yaw LITERAL1
Roll LITERAL1
Pitch LITERAL1
LONG LITERAL1
LAT LITERAL1
BLINKER_AP_CONFIG LITERAL1
BLINKER_SMART_CONFIG LITERAL1

View File

@@ -0,0 +1,28 @@
{
"name": "Blinker",
"description": "Build a easy way for your IoT project. Blinker library for embedded hardware. Works with Arduino, ESP8266, ESP32.",
"keywords": "wifi, websocket, Bluetooth, mqtt",
"authors": [
{
"name": "i3water",
"url": "https://github.com/i3water",
"maintainer": true
}
],
"repository": {
"type": "git",
"url": "https://github.com/blinker-iot/blinker-library.git"
},
"version": "0.3.9",
"homepage": "https://diandeng.tech/home",
"export": {
"exclude": [
"tests"
]
},
"frameworks": "arduino",
"platforms": "*",
"examples": [
"examples/*/*/*.ino"
]
}

View File

@@ -0,0 +1,9 @@
name=Blinker
version=0.3.9
author=i3water
maintainer=i3wawter
sentence=Build a easy way for your IoT project.
paragraph=Blinker library for embedded hardware. Support Arduino, ESP8266, ESP32, WiFi, BLE, MQTT.
category=Communication
url=https://diandeng.tech/home
architectures=*

View File

@@ -0,0 +1,370 @@
#ifndef BLINKER_AIR202_LP_H
#define BLINKER_AIR202_LP_H
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include "../Blinker/BlinkerConfig.h"
#include "../Blinker/BlinkerDebug.h"
#include "../Blinker/BlinkerStream.h"
#include "../Blinker/BlinkerUtility.h"
#include "../Functions/BlinkerAIR202.h"
#include "../Functions/BlinkerHTTPAIR202.h"
#ifndef ARDUINOJSON_VERSION_MAJOR
#include "../modules/ArduinoJson/ArduinoJson.h"
#endif
class BlinkerAIR202LP : public BlinkerStream
{
public :
BlinkerAIR202LP()
: stream(NULL), isConnect(false)
{}
int connect() { return isGPRSinit ? true : false; }
int connected() { return isGPRSinit ? true : false; }
void disconnect() { delay(1); }
void ping() { delay(1); }
int available()
{
dataGet();
if (isAvail)
{
isAvail = false; return true;
}
else return false;
}
char * lastRead() { if (isFresh) return msgBuf; return ""; }
void flush() { if (isFresh) { free(msgBuf); isFresh = false; isAvail = false; } }
void dataGet();
int print(char * data, bool needCheck = true);
void begin(const char* _key, const char* _deviceType, String _imei);
void initStream(Stream& s, bool state, blinker_callback_t func);
char * deviceName() { return _deviceName; }
char * authKey() { return _authKey; }
char * token() { if (!isGPRSinit) return ""; else return _authKey; }
int init() { return isGPRSinit; }
int deviceRegister() { return connectServer(); }
private :
bool isGPRSinit = false;
int connectServer();
protected :
Stream* stream;
char* msgBuf;
bool isConnect;
bool isHWS = false;
char* imei;
bool isAvail = false;
bool isFresh = false;
bool _isAuthKey = false;
const char* _vipKey;
const char* _deviceType;
char* _authKey;
char* _deviceName;
blinker_callback_t listenFunc = NULL;
};
int BlinkerAIR202LP::print(char * data, bool needCheck)
{
String msg = BLINKER_F("{\"deviceName\":\"");
msg += _deviceName;
msg += BLINKER_F("\",\"key\":\"");
msg += _authKey;
msg += BLINKER_F("\",\"data\":");
msg += data;
msg += BLINKER_F("}");
String host = BLINKER_F(BLINKER_SERVER_HTTPS);
String url_iot = BLINKER_F("/api/v1/user/device/lowpower/data");
BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host + url_iot);
BlinkerHTTPAIR202 http(*stream, isHWS, listenFunc);
String conType = BLINKER_F("Content-Type");
String application = BLINKER_F("application/json;charset=utf-8");
http.begin(host, url_iot);
String payload;
if (http.POST(msg, conType, application))
{
BLINKER_LOG(BLINKER_F("[HTTP] ... success"));
payload = http.getString();
}
else
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... failed"));
return false;
}
BLINKER_LOG_ALL(BLINKER_F("reply was:"));
BLINKER_LOG_ALL(BLINKER_F("=============================="));
BLINKER_LOG_ALL(payload);
BLINKER_LOG_ALL(BLINKER_F("=============================="));
// DynamicJsonBuffer jsonBuffer;
// JsonObject& data_rp = jsonBuffer.parseObject(payload);
DynamicJsonDocument jsonBuffer(1024);
DeserializationError error = deserializeJson(jsonBuffer, payload);
JsonObject data_rp = jsonBuffer.as<JsonObject>();
// if (data_rp.success())
if (!error)
{
uint16_t msg_code = data_rp[BLINKER_CMD_MESSAGE];
if (msg_code != 1000)
{
String _detail = data_rp[BLINKER_CMD_DETAIL];
BLINKER_ERR_LOG(_detail);
}
else
{
payload = data_rp[BLINKER_CMD_DETAIL][BLINKER_CMD_DATA].as<String>();
}
}
BLINKER_LOG_ALL(BLINKER_F("payload: "), payload);
return true;
}
void BlinkerAIR202LP::dataGet()
{
String host = BLINKER_F(BLINKER_SERVER_HTTPS);
String uri = "";
uri += BLINKER_F("/api/v1/user/device/lowpower/data?deviceName=");
uri += _deviceName;
uri += BLINKER_F("&key=");
uri += _authKey;
BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host + uri);
BlinkerHTTPAIR202 http(*stream, isHWS, listenFunc);
http.begin(host, uri);
String payload;
if (http.GET())
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... success"));
payload = http.getString();
}
else
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... failed"));
return;
}
BLINKER_LOG_ALL(BLINKER_F("reply was:"));
BLINKER_LOG_ALL(BLINKER_F("=============================="));
BLINKER_LOG_ALL(payload);
BLINKER_LOG_ALL(BLINKER_F("=============================="));
// DynamicJsonBuffer jsonBuffer;
// JsonObject& data_rp = jsonBuffer.parseObject(payload);
DynamicJsonDocument jsonBuffer(1024);
DeserializationError error = deserializeJson(jsonBuffer, payload);
JsonObject data_rp = jsonBuffer.as<JsonObject>();
// if (data_rp.success())
if (!error)
{
uint16_t msg_code = data_rp[BLINKER_CMD_MESSAGE];
if (msg_code != 1000)
{
String _detail = data_rp[BLINKER_CMD_DETAIL];
BLINKER_ERR_LOG(_detail);
}
else
{
payload = data_rp[BLINKER_CMD_DETAIL][BLINKER_CMD_DATA].as<String>();
if (isFresh) free(msgBuf);
if (payload != "{}")
{
msgBuf = (char*)malloc((payload.length()+1)*sizeof(char));
strcpy(msgBuf, payload.c_str());
isFresh = true;
isAvail = true;
BLINKER_LOG_ALL(BLINKER_F("isAvail"));
}
}
}
BLINKER_LOG_ALL(BLINKER_F("payload: "), payload);
}
void BlinkerAIR202LP::begin(const char* _key, const char* _type, String _imei)
{
_vipKey = _key;
_deviceType = _type;
BLINKER_LOG_ALL(BLINKER_F("PRO deviceType: "), _type);
imei = (char*)malloc((_imei.length() + 1)*sizeof(char));
strcpy(imei, _imei.c_str());
// authKey = (char*)malloc((strlen(_deviceType) + 1)*sizeof(char));
// strcpy(authKey, _deviceType);
}
void BlinkerAIR202LP::initStream(Stream& s, bool state, blinker_callback_t func)
{
stream = &s;
stream->setTimeout(BLINKER_STREAM_TIMEOUT);
isHWS = state;
listenFunc = func;
}
int BlinkerAIR202LP::connectServer()
{
String host = BLINKER_F(BLINKER_SERVER_HTTPS);
String uri = "";
if (!_isAuthKey)
{
// uri += BLINKER_F("/api/v1/user/device/register?deviceType=");
// uri += _deviceType;
// uri += BLINKER_F("&deviceName=");
// uri += imei;
uri += BLINKER_F("/api/v1/user/device/pro/lowpower/auth/get?deviceType=");
uri += _deviceType;
uri += BLINKER_F("&vipKey=");
uri += _vipKey;
uri += BLINKER_F("&deviceName=");
uri += imei;
BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host + uri);
BlinkerHTTPAIR202 http(*stream, isHWS, listenFunc);
http.begin(host, uri);
String payload;
if (http.GET())
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... success"));
payload = http.getString();
// return true;
}
else
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... failed"));
return false;
}
BLINKER_LOG_ALL(BLINKER_F("reply was:"));
BLINKER_LOG_ALL(BLINKER_F("=============================="));
BLINKER_LOG_ALL(payload);
BLINKER_LOG_ALL(BLINKER_F("=============================="));
// DynamicJsonBuffer jsonBuffer;
// JsonObject& root = jsonBuffer.parseObject(payload);
DynamicJsonDocument jsonBuffer(1024);
DeserializationError error = deserializeJson(jsonBuffer, payload);
JsonObject root = jsonBuffer.as<JsonObject>();
if (STRING_contains_string(payload, BLINKER_CMD_NOTFOUND) || error ||
!STRING_contains_string(payload, BLINKER_CMD_AUTHKEY)) {
// while(1) {
BLINKER_ERR_LOG(("Please make sure you have register this device!"));
// ::delay(60000);
return false;
// }
}
String _getAuthKey = root[BLINKER_CMD_DETAIL][BLINKER_CMD_AUTHKEY];
_authKey = (char*)malloc((_getAuthKey.length()+1)*sizeof(char));
strcpy(_authKey, _getAuthKey.c_str());
BLINKER_LOG_ALL(BLINKER_F("===================="));
BLINKER_LOG_ALL(BLINKER_F("_authKey: "), _authKey);
BLINKER_LOG_ALL(BLINKER_F("===================="));
_isAuthKey = true;
}
String url_iot = BLINKER_F("/api/v1/user/device/pro/lowpower/auth?authKey=");
url_iot += _authKey;
BLINKER_LOG_ALL(BLINKER_F("HTTPS begin: "), host + url_iot);
BlinkerHTTPAIR202 http(*stream, isHWS, listenFunc);
http.begin(host, url_iot);
String payload;
if (http.GET())
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... success"));
payload = http.getString();
// return true;
}
else
{
BLINKER_LOG(BLINKER_F("[HTTP] GET... failed"));
return false;
}
BLINKER_LOG_ALL(BLINKER_F("reply was:"));
BLINKER_LOG_ALL(BLINKER_F("=============================="));
BLINKER_LOG_ALL(payload);
BLINKER_LOG_ALL(BLINKER_F("=============================="));
// DynamicJsonBuffer jsonBuffer;
// JsonObject& root = jsonBuffer.parseObject(payload);
DynamicJsonDocument jsonBuffer(1024);
DeserializationError error = deserializeJson(jsonBuffer, payload);
JsonObject root = jsonBuffer.as<JsonObject>();
if (STRING_contains_string(payload, BLINKER_CMD_NOTFOUND) || error ||
!STRING_contains_string(payload, BLINKER_CMD_DEVICENAME)) {
// while(1) {
BLINKER_ERR_LOG(("Please make sure you have register this device!"));
// ::delay(60000);
return false;
// }
}
String _device_name = root[BLINKER_CMD_DETAIL][BLINKER_CMD_DEVICENAME];
if (isGPRSinit)
{
free(_deviceName);
isGPRSinit = false;
}
_deviceName = (char*)malloc((_device_name.length()+1)*sizeof(char));
strcpy(_deviceName, _device_name.c_str());
isGPRSinit = true;
return true;
}
#endif

View File

@@ -0,0 +1,343 @@
#ifndef BLINKER_BLE_H
#define BLINKER_BLE_H
#if defined(ESP32)
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>
#include "../Blinker/BlinkerConfig.h"
#include "../Blinker/BlinkerDebug.h"
#include "../Blinker/BlinkerStream.h"
#include "../Blinker/BlinkerUtility.h"
class BlinkerBLE : public BlinkerStream, public BLEServerCallbacks, public BLECharacteristicCallbacks
{
public :
BlinkerBLE()
: deviceConnected(false), isAvail(false)
{}
void begin();
int available();
int read();
int timedRead();
char * lastRead();// { return _isFresh ? BLEBuf : ""; }
void flush();
// bool print(String s, bool needCheck = true);
int print(char * data, bool needCheck = true);
int connect() { return deviceConnected; }
void disconnect() { deviceConnected = false; }
int connected() { return deviceConnected; }
private :
bool deviceConnected;
char* BLEBuf;//[BLINKER_MAX_READ_SIZE];
bool _isFresh = false;
bool isAvail;
bool isFresh;
uint32_t _bufLen;
uint32_t freshTime;
BLEServer *pServer;
BLEService *pService;
BLECharacteristic *pCharacteristic;
BLEAdvertising *pAdvertising;
BLEAdvertisementData pAdvertisementData;
uint8_t respTimes = 0;
uint32_t respTime = 0;
// bool isAvailBLE = false;
// uint8_t* bleReadBuf;//[20];
// uint32_t bleReadBufLen = 0;
// uint32_t getNum = 0;
// bool isNewLine = false;
void onConnect(BLEServer* pServer);
void onDisconnect(BLEServer* pServer);
void onWrite(BLECharacteristic *pCharacteristic);
int checkTimeOut();
int checkPrintSpan();
};
void BlinkerBLE::begin()
{
BLEDevice::init("Blinker");
pServer = BLEDevice::createServer();
pService = pServer->createService(BLEUUID((uint16_t)0xffe0));//SERVICE_UUID
pServer->setCallbacks(this);
pCharacteristic = pService->createCharacteristic(
BLEUUID((uint16_t)0xffe1),//CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY |
BLECharacteristic::PROPERTY_WRITE_NR
);
pCharacteristic->setCallbacks(this);
pCharacteristic->addDescriptor(new BLE2902());
pCharacteristic->setValue("Blinker");
pService->start();
pAdvertising = pServer->getAdvertising();
BLEAddress otherAddress = BLEDevice::getAddress();
esp_bd_addr_t ble_m_address;
memcpy(ble_m_address, otherAddress.getNative(), ESP_BD_ADDR_LEN);
char macStr[9] = { 0 };
macStr[0] = 0x48;
macStr[1] = 0X4d;
for (uint8_t cpynum = 0; cpynum < 6; cpynum++) {
macStr[cpynum+2] = (char)ble_m_address[cpynum];
}
pAdvertisementData.setManufacturerData(macStr);
pAdvertising->setAdvertisementData(pAdvertisementData);
pAdvertising->addServiceUUID(BLEUUID((uint16_t)0xffe0));
pAdvertising->start();
_bufLen = 0;
}
int BlinkerBLE::available()
{
// checkTimeOut();
if (_bufLen)
{
bool isNewLine = false;
for (uint8_t num = 0; num < _bufLen; num++)
{
if (BLEBuf[num] == '\n')
{
BLEBuf[num] = '\0';
isNewLine = true;
}
}
if (isNewLine)
{
BLINKER_LOG_ALL(BLINKER_F("GET1: "), BLEBuf);
isAvail = true;
_isFresh = true;
// for (uint8_t num = 0; num < _bufLen; num++)
// {
// Serial.print(BLEBuf[num]);
// }
// Serial.println();
}
else
{
if (checkTimeOut())
{
BLEBuf[_bufLen] = '\0';
BLINKER_LOG_ALL(BLINKER_F("GET: "), BLEBuf);
isAvail = true;
_isFresh = true;
}
}
}
if (isAvail)
{
BLINKER_LOG_ALL(BLINKER_F("handleBLE: "), BLEBuf);
BLINKER_LOG_FreeHeap_ALL();
isAvail = false;
return true;
}
else {
return false;
}
return false;
}
// int BlinkerBLE::read()
// {
// uint32_t num = getNum;
// if (num < bleReadBufLen)
// {
// getNum++;
// return bleReadBuf[num];
// }
// else
// {
// return -1;
// }
// }
// int BlinkerBLE::timedRead()
// {
// int c;
// uint32_t _startMillis = millis();
// do {
// c = read();
// if (c >= 0) return c;
// } while(millis() - _startMillis < 1000);
// return -1;
// }
char * BlinkerBLE::lastRead()
{
if (_isFresh) return BLEBuf;
else return "";
}
void BlinkerBLE::flush()
{
if (_isFresh || _bufLen)
{
BLINKER_LOG_ALL(BLINKER_F("flush"));
free(BLEBuf); //isFresh = false;
isAvail = false; _isFresh = false;
_bufLen = 0; //isNewLine = false;
}
}
// bool BlinkerBLE::print(String s, bool needCheck)
int BlinkerBLE::print(char * data, bool needCheck)
{
if (needCheck)
{
if (!checkPrintSpan())
{
respTime = millis();
return false;
}
}
String s = data;
respTime = millis();
BLINKER_LOG_ALL(BLINKER_F("Response: "), s);
if (connected())
{
BLINKER_LOG_ALL(BLINKER_F("Success..."));
s += BLINKER_CMD_NEWLINE;
String s_send;
uint8_t parts = s.length()/20 + 1;
for (uint8_t num = 0; num < parts; num++)
{
if ((num + 1) == parts)
s_send = s.substring(num*(20), s.length());
else
s_send = s.substring(num*(20), (num+1)*20);
// BLINKER_LOG_ALL("s_send: ", s_send);
pCharacteristic->setValue(s_send.c_str());
pCharacteristic->notify();
delay(5);
}
return true;
}
else
{
BLINKER_LOG_ALL(BLINKER_F("Faile... Disconnected"));
return false;
}
}
void BlinkerBLE::onConnect(BLEServer* pServer)
{
deviceConnected = true;
BLINKER_LOG_ALL("BLE connect");
}
void BlinkerBLE::onDisconnect(BLEServer* pServer)
{
deviceConnected = false;
BLINKER_LOG_ALL("BLE disconnect");
pServer->startAdvertising();
}
void BlinkerBLE::onWrite(BLECharacteristic *pCharacteristic)
{
std::string value = pCharacteristic->getValue();
int vlen = value.length();
if (vlen > 0)
{
int data;
uint8_t num;
if (!_bufLen) BLEBuf = (char*)malloc(BLINKER_MAX_READ_SIZE*sizeof(char));
for (num = 0; num < vlen; num++)
{
data = value[num];
if (data == '\n')
{
BLEBuf[_bufLen+num] = data;
num++;
BLINKER_LOG_ALL(BLINKER_F("GET \\n"));
break;
}
BLEBuf[_bufLen+num] = (char)data;
}
if (_bufLen) _bufLen += num;
else _bufLen = num;
freshTime = millis();
BLINKER_LOG_ALL(BLINKER_F("vlen: "), vlen);
BLINKER_LOG_ALL(BLINKER_F("_bufLen: "), _bufLen);
}
}
int BlinkerBLE::checkTimeOut()
{
::delay(10);
uint32_t timeout_ms = millis() - freshTime;
// BLINKER_LOG_ALL(BLINKER_F("timeout_ms: "), timeout_ms);
return timeout_ms > 1000;
}
int BlinkerBLE::checkPrintSpan()
{
if (millis() - respTime < BLINKER_PRINT_MSG_LIMIT)
{
if (respTimes > BLINKER_PRINT_MSG_LIMIT)
{
BLINKER_ERR_LOG("DEVICE NOT CONNECT OR MSG LIMIT");
return false;
}
else
{
respTimes++;
return true;
}
}
else
{
respTimes = 0;
return true;
}
}
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More