[Alapha]ESP8266 新版小爱同学-三星空调控制

支持直接通过小爱控制空调

代码重写,但是因为技术不太行,只完成了一半功能 doge

APP端 开启关闭空调,DHT传感器,目前设定的温度

小爱同学 开启关闭,调温度【只有制冷模式】

求大佬开发

#define BLINKER_WIFI
#define BLINKER_MIOT_AIRCONDITION
#include
#include
#include
#include
#include
//
const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
IRSamsungAc ac(kIrLed); // Set the GPIO used for sending messages.
//DHT21
#define DHTTYPE DHT21
#include
#include
#define DHTPIN 14
DHT dht(DHTPIN, DHTTYPE);
uint32_t read_time = 0;
float humi_read, temp_read;
void dataStorage()
{
Blinker.dataStorage(“cha-temp”, temp_read);
Blinker.dataStorage(“cha-humi”, humi_read);
}
BlinkerNumber HUMI(“humi”);
BlinkerNumber TEMP(“temp”);

//
char auth[] = “99b9263f6e05”;
char ssid[] = “Emmm…IOT”;
char pswd[] = “181205456.1”;

bool oState = false;
bool hsState = false;
bool vsState = false;
uint8_t setLevel;
uint8_t setTemp;
void miotLevel(uint8_t level)
{
BLINKER_LOG(“need set level: “, level);
// 0:AUTO MODE, 1-3 LEVEL

setLevel = level;
ac.setFan(setLevel);
BlinkerMIOT.level(level);
BlinkerMIOT.print();
}

void miotTemp(int32_t temp)
{
BLINKER_LOG(“need set temp: “, temp);
setTemp = temp;

ac.setTemp(setTemp);
ac.send();
BlinkerMIOT.temp(temp);
BlinkerMIOT.print();
}

//APP控制
BlinkerButton Button1(“BUTTON_1”);
BlinkerNumber Number1(“temps”);
#define BUTTON_1 “power”
//温度APP控制

//求教

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

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 heartbeat()//心跳
{
HUMI.print(humi_read);
TEMP.print(temp_read);
}
//APP控制开关
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(“#FF0000”);
Button1.text(“电源开”);
Button1.print(“on”);
ac.on();
ac.send();
}
else if (state == BLINKER_CMD_OFF) {
BLINKER_LOG(“Toggle off!”);
Button1.icon(“icon_1”);
Button1.color(“#FF0000”);
Button1.text(“电源关”);
// Button1.text(“Your button name”, “describe”);
Button1.print(“off”);
ac.off();
ac.send();
}
else {
BLINKER_LOG(“Get user setting: “, state);

Button1.icon(“icon_1”);
Button1.color(“#FFFFFF”);
Button1.text(“?”);
// Button1.text(“Your button name”, “describe”);
Button1.print();

}
}
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);
ac.on();
ac.send();
BlinkerMIOT.powerState(“on”);
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, LOW);
ac.off();
ac.send();
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(setTemp);

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(setTemp);

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()
{
//
ac.begin();
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
//APP控制
Button1.attach(button1_callback);
//
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
//DHT
Blinker.attachHeartbeat(heartbeat);
Blinker.attachDataStorage(dataStorage);
dht.begin();
//
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachHSwing(miotHSwingState);
BlinkerMIOT.attachVSwing(miotVSwingState);
BlinkerMIOT.attachLevel(miotLevel);
BlinkerMIOT.attachMode(miotMode);
BlinkerMIOT.attachTemp(miotTemp);
BlinkerMIOT.attachQuery(miotQuery);
}

void loop()
{
Blinker.run();
//dht
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
BLINKER_LOG(“Failed to read from DHT sensor!”);
}
else
{
// BLINKER_LOG(“Humidity: “, h, ” %”);
//BLINKER_LOG(“Temperature: “, t, ” *C”);
humi_read = h;
temp_read = t;
float hic = dht.computeHeatIndex(t, h, false);
}
}

界面配置

{¨config¨{¨headerColor¨¨transparent¨¨headerStyle¨¨dark¨¨background¨{¨img¨¨assets/img/bg/f5.jpg¨¨isFull¨»}}¨dashboard¨|{¨type¨¨btn¨¨ico¨¨fad fa-power-off¨¨mode¨Ê¨t0¨¨电源¨¨t1¨¨文本2¨¨bg¨É¨cols¨Ë¨rows¨Ë¨key¨¨BUTTON_1¨´x´Ï´y´É¨speech¨|{¨cmd¨¨开关电脑¨¨act¨¨tap¨}÷¨lstyle¨Ê¨clr¨¨#076EEF¨}{ßA¨deb¨ßEÉßJÉßKÑßLÌßM¨debug¨´x´É´y´Ð}{ßA¨num¨ßF¨设定温度¨ßC¨fad fa-thermometer-three-quarters¨ßU¨#389BEE¨¨min¨É¨max¨¤U¨uni¨´℃´ßJÉßKËßLËßM¨temps¨´x´Í´y´ÉßO|÷}{ßAßYßF¨实时湿度¨ßC¨fad fa-humidity¨ßUßbßcÉßd¢1cße´%´ßJÉßKÍßLËßM¨humi¨´x´Í´y´ËßO|÷ßTÊ}{ßAßYßF¨实时温度¨ßCßaßUßbßcÉßd¤eße´℃´ßJÉßKÍßLËßM¨temp¨´x´É´y´ËßO|÷ßTÊ}{ßA¨cha¨ßJɨsty¨¨line¨ßUßV¨sty1¨ßn¨clr1¨¨#EA0909¨¨sty2¨ßn¨clr2¨ßbßKÑßLÌßM¨cha-humi¨´x´É´y´ÍßO|÷¨key0¨ßt¨key1¨¨cha-temp¨ßF¨湿度¨ßH¨温度¨}{ßA¨tex¨ßF¨空调控制¨ßH´´¨size¨¤EßJÉßC¨fad fa-air-conditioner¨ßKÍßLËßMß10´x´É´y´ÉßO|÷ßTÌßUßV}÷¨actions¨|¦ßP¦¨switch¨‡¨text¨‡´on´¨打开?name¨¨off¨¨关闭?name¨—÷¨triggers¨|{¨source¨ß14¨source_zh¨¨开关状态¨¨state¨|´on´ß17÷¨state_zh¨|´打开´´关闭´÷}÷}

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇