1812z's blog
1812z's blog
ESP8266与空调智能遥控-点灯科技-小爱同学

这篇文章只写主要内容,基础操作自行百度[库安装,开发板设定]

本文分两个版本

  • 原版【只有遥控器】
  • 修改版【加入气象站】

Part.0-准备材料

硬件材料

https://img2.moeblog.vip/images/ZY2K.png
总览

需要 1.esp8266开发板 [10元]

2.红外模块 [3元]

3.杜邦线

4.各种工具

软件材料

安装Arduino软件,官网:https://www.arduino.cc/en/Main/Software

确保驱动安装正常[会自动安装]

下载”GREEcontrol.ino” [就是源码的原版,下面有]

https://pan.baidu.com/s/17jP8MX4hUl3nnxtWqwjW8A 提取码:gg8x [地址来自原帖]

Part.1-key获取

1.手机安装点灯科技app 官网:https://www.diandeng.tech/home

2.注册登录并添加设备

https://img2.moeblog.vip/images/ZjjW.jpg
选择独立设备
https://img2.moeblog.vip/images/ZzNH.jpg
选择WIFI接入
https://img2.moeblog.vip/images/Z36D.jpg
成功,复制key备用

Part.2-接线

DAt-D0

VCC-3v

GNd-G

https://img2.moeblog.vip/images/ZIzI.png
红外是无元件的那面
https://img2.moeblog.vip/images/ZEmA.png
图片来自原帖

Part.3-开发板程序配置

1.打开”GREEcontrol.ino”

2.选择开发板

先点”文件“-“首选项”-“附加开发板管理网址” 输入 保存http://arduino.esp8266.com/stable/package_esp8266com_index.json

再点上面的”工具”-“开发板”-“开发板管理器” 等待自动下载

再搜索 ESP8266 安装第一个选项 并选择如图选项

https://img2.moeblog.vip/images/ZVIb.png

3.修改黄色区域代码

https://img2.moeblog.vip/images/ZDBu.png

改auth,wifi的ssid和pswd 以及空调厂商

https://img2.moeblog.vip/images/Zx9t.png
对照表 [图片来自原帖]

4.写入开发板-点击上面的向右蓝色箭头即可[usb线要能传数据的]

Part.4-手机app界面配置

https://img2.moeblog.vip/images/Zf5c.jpg
按图片里模仿

可以在界面配置里复制下面代码

界面配置代码
keyboard_arrow_down

{¨config¨{¨headerColor¨¨transparent¨¨headerStyle¨¨dark¨¨background¨{¨img¨¨assets/img/bg/f1.jpg¨¨isFull¨»}}¨dashboard¨|{¨type¨¨btn¨¨ico¨¨fad fa-toggle-on¨¨mode¨Ê¨t0¨´关´¨clr¨¨#389BEE¨¨t1¨¨文本2¨¨bg¨É¨cols¨Ë¨rows¨Ë¨key¨¨powerac¨´x´Í´y´É¨speech¨|{¨cmd¨¨开灯¨¨act¨¨tap¨}÷¨lstyle¨É¨cus¨¨OFF¨}{ßA¨deb¨ßEÉßKÉßLÑßMÌßN¨debug¨´x´É´y´ÑßP|÷}{ßA¨ran¨ßF¨温度¨ßGßH¨max¨¤U¨min¨¤GßKÉßLÏßMËßN¨sethump¨´x´É´y´ËßP|÷ßUÊ}{ßA¨tex¨ßF¨空调控制¨ßI¨三星¨ßKÉßC¨fal fa-font¨ßLÍßMËßN´´´x´É´y´ÉßP|÷ßUÌ}{ßA¨num¨ßFßaßC¨fad fa-thermometer-three-quarters¨ßGßHßcÉßb¤U¨uni¨ßaßKÉßLËßMËßNßd´x´Ï´y´ËßP|÷ßUÉ}{ßA¨tab¨ßKÉßLÑßMËßN¨setspeed¨´x´É´y´ÏßP|÷ßC¨fad fa-fan¨ßF¨自动¨¨ico1¨¨iconfont icon-n1¨¨ico2¨¨iconfont icon-n2¨¨ico3¨¨iconfont icon-n3¨¨ico4¨¨iconfont icon-n4¨ßI¨一档¨¨t2¨¨二档¨´t3´´三档´´t4´´四档´}{ßAßlßKÉßLÑßMËßN¨setmode¨´x´É´y´ÍßP|÷ßFßoßI´制冷´ßC¨fad fa-chart-network¨ßp¨fad fa-snowflakes¨ßy´除湿´´t3´´制热´´t4´´通风´ßr¨fad fa-tint¨ßt¨fad fa-sun¨ßv¨fad fa-wind¨}{ßAßBßC¨fad fa-flower-tulip¨ßEÊßF´健康´ßIßJßKÉßLËßMËßN¨healthac¨´x´Ï´y´ÉßP|÷ßUÉ}÷¨actions¨|¦ßQ¦¨switch¨‡¨text¨‡´on´¨打开?name¨¨off¨¨关闭?name¨—÷¨triggers¨|{¨source¨ß19¨source_zh¨¨开关状态¨¨state¨|´on´ß1C÷¨state_zh¨|´打开´´关闭´÷}÷}

【可选】Part.5-温湿度感应+运行时间

加入温湿度感应+运行时间+0.96 oled【可显示温湿度】

源码 酷安@仟念

提示:曲线图不知道为什么不能用,看运气

https://img2.moeblog.vip/images/ZJNT.jpg

源码


#define BLINKER_MIOT_OUTLET
#define BLINKER_WIFI

#include <Blinker.h>
//红外使用库
char auth[] = "key";
char ssid[] = "ssid";
char pswd[] = "password";
//by 1812z

#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRac.h>
#include <IRutils.h>

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>

int ledPin = 2;


//设置空调厂商(18格力,48aux)
int firm = 46;
//红外基础引脚设置 16 (D0).
// ESP8266 GPIO pin to use. Recommended: 16 (D0).
const uint16_t kIrLed = 16;
// Create a A/C object using GPIO to sending messages with.
IRac ac(kIrLed);
// Where we will store the desired state of the A/C.
//我们将在那里存储所需的空调状态。
stdAc::state_t state;
// Where we will store the previous state of the A/C.
//我们将在那里存储以前的空调状态
stdAc::state_t prev;

int countSetMode = 0;
int countFan = 0;
uint8_t lastSetMode;
uint8_t lastSetFan;
uint8_t twoLastSetMode;
uint8_t twoLastSetFan;

bool tab[5] = {false};
bool tab1[5] = {false};

//初始化模式tab为false
bool tabSetMode[5] = {false};
//初始化风速tab为false
bool tabSetFan[5] = {false};

BlinkerButton ButtonPower("powerac");
BlinkerButton ButtonHealth("healthac");
BlinkerSlider SliderHump("sethump");

BlinkerTab setModeTab("setmode");
BlinkerTab setSpeedTab("setspeed");

BlinkerText TEXT1("tex-s"); 
BlinkerNumber HUMI("humi");
BlinkerNumber TEMP("temp");

bool oState = false;

#define DHTPIN 14
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

//#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 dataStorage()
{
    Blinker.dataStorage("cha-temp", temp_read);
    Blinker.dataStorage("cha-humi", humi_read);
}

 
String rts()//计算运行时间
    {
    int rt =Blinker.runTime();
    int r,e,f,s;
    String fh;
    Blinker.delay(100);
    if(rt >= 86400)//天数
    {r = rt / 86400;
     e = rt / 3600 - r*24;
     f = rt / 60 - r*1440 - e*60;
     s = rt - r*86400 - e*3600 - f*60;}
    else if(rt >= 3600)
    {r = 0;
     e = rt / 3600;
     f = rt / 60 - e*60;
     s = rt - e*3600 - f*60;}
    else
    {r = 0;
     e = 0;
     f = rt / 60;
     s = rt - f*60;}
     
    //BLINKER_LOG(r," ",e," ",f," ",s);//输出数据测试
    
    if(f==0 & e==0 & r==0)
    {fh = String("")+ s +"秒";}
    else if(r == 0 & e == 0 )
    {fh = String("")+ f + "分" + s +"秒";}
    else if(r == 0)
    {fh = String("")+ e + "时" + f + "分" + s +"秒"; }
    else
    {fh = String("")+ r + "天" + e + "时" + f + "分" + s +"秒";}

    return(fh);
    }

void heartbeat()//心跳
{ 
   HUMI.print(humi_read);
    TEMP.print(temp_read);
    TEXT1.print(rts());
}

void miotPowerState(const String &state)
{
  BLINKER_LOG("need set power state: ", state);

  if (state == BLINKER_CMD_ON)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    powerOn();
    BlinkerMIOT.powerState("on");
    BlinkerMIOT.print();

    oState = true;
  }
  else if (state == BLINKER_CMD_OFF)
  {
    digitalWrite(LED_BUILTIN, LOW);
    powerOff();
    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 buttonPower_callback(const String &state)
{
  ledState();
  BLINKER_LOG("get buttonPower state: ", state);

  if (state == BLINKER_CMD_ON)
  {
    BLINKER_LOG("power on!");
    powerOn();
    //    ButtonPower.icon("icon_1");
    ButtonPower.color("#008000");
    ButtonPower.text("电源开");
    // ButtonPower.text("Your button name", "describe");
    ButtonPower.print("on");
  }
  else if (state == BLINKER_CMD_OFF)
  {
    BLINKER_LOG("power off!");
    powerOff();
    //    ButtonPower.icon("icon_1");
    ButtonPower.color("#FF0000");
    ButtonPower.text("电源关");
    // ButtonPower.text("Your button name", "describe");
    ButtonPower.print("off");
  }
  else
  {
    BLINKER_LOG("Get user setting  buttonPower: ", state);

    //    ButtonPower.icon("icon_1");
    ButtonPower.color("#FFFFFF");
    ButtonPower.text("Your button name or describe");
    // ButtonPower.text("Your button name", "describe");
    ButtonPower.print();
  }
}

void buttonHealth_callback(const String &state)
{
  ledState();
  BLINKER_LOG("get buttonHealth state: ", state);

  if (state == BLINKER_CMD_ON)
  {
    BLINKER_LOG("buttonHealth on!");
    healthOn();
    //    ButtonHealth.icon("icon_1");
    ButtonHealth.color("#008000");
    ButtonHealth.text("on Health");
    // ButtonHealth.text("Your button name", "describe");
    ButtonHealth.print("on");
  }
  else if (state == BLINKER_CMD_OFF)
  {
    BLINKER_LOG("buttonHealth off!");
    healthOff();
    //    ButtonHealth.icon("icon_1");
    ButtonHealth.color("#FF0000");
    ButtonHealth.text("off health");
    // ButtonHealth.text("Your button name", "describe");
    ButtonHealth.print("off");
  }
  else
  {
    BLINKER_LOG("Get user setting buttonHealth: ", state);

    //    ButtonHealth.icon("icon_1");
    ButtonHealth.color("#FFFFFF");
    ButtonHealth.text("Your button name or describe");
    //ButtonHealth.text("Your button name", "describe");
    ButtonHealth.print();
  }
}

void setHump_callback(int32_t value)
{
  ledState();
  BLINKER_LOG("get slider setHump value: ", value);
  setDegrees(value);
}

//模式按键触发
void setMode_callback(uint8_t tab_set)
{
  BLINKER_LOG("get setMode tab set: ", tab_set);

  switch (tab_set)
  {
  case BLINKER_CMD_TAB_0:
    tab[0] = true;
    BLINKER_LOG("tab 0 set");
    tab[1] = false;
    tab[2] = false;
    tab[3] = false;
    tab[4] = false;
    //      setModeAuto();
    BLINKER_LOG("");
    break;
  case BLINKER_CMD_TAB_1:
    tab[1] = true;
    BLINKER_LOG("tab 1 set");
    tab[0] = false;
    tab[2] = false;
    tab[3] = false;
    tab[4] = false;
    //      setModeCool();
    break;
  case BLINKER_CMD_TAB_2:
    tab[2] = true;
    BLINKER_LOG("tab 2 set");
    tab[0] = false;
    tab[1] = false;
    tab[3] = false;
    tab[4] = false;
    //      setModeDry();
    break;
  case BLINKER_CMD_TAB_3:
    tab[3] = true;
    BLINKER_LOG("tab 3 set");
    tab[0] = false;
    tab[1] = false;
    tab[2] = false;
    tab[4] = false;
    //      setModeHeat();
    break;
  case BLINKER_CMD_TAB_4:
    tab[4] = true;
    BLINKER_LOG("tab 4 set");
    tab[0] = false;
    tab[1] = false;
    tab[2] = false;
    tab[3] = false;
    //      setModeFan();
    break;
  default:
    break;
  }
  countSetMode++;
  //Serial.print("接收指令次数:");
  //Serial.println(countSetMode);
  tabCountMode();
}
//判断多次开关触发

void tabCountMode()
{

  if (countSetMode == 1)
  {
    for (uint8_t one = 0; one < 5; one++)
    {
      tabSetMode[one] = tab[one];
    }
  }
  else
  {
    for (uint8_t num = 0; num < 5; num++)
    {
      if (tab[num])
      {
        if (lastSetMode == num)
        {
          for (uint8_t one = 0; one < 5; one++)
          {
            tab[one] = tabSetMode[one];
            tabSetMode[one] = false;
          }
        }
      }
    }
  }
}

//模式按键反馈
void setMode_feedback()
{
  for (uint8_t num = 0; num < 5; num++)
  {
    if (tab[num])
    {
      sendMode(num);
      setModeTab.tab(num);
      lastSetMode = num;
      tab[num] = false;
    }
  }
  setModeTab.print();
  countSetMode = 0;
}

//设置风速
void setSpeed_callback(uint8_t tab_set)
{
  BLINKER_LOG("get setMode tab set: ", tab_set);

  switch (tab_set)
  {
  case BLINKER_CMD_TAB_0:
    tab1[0] = true;
    BLINKER_LOG("setFanAuto");
    tab1[1] = false;
    tab1[2] = false;
    tab1[3] = false;
    tab1[4] = false;
    //      setFanAuto();
    break;
  case BLINKER_CMD_TAB_1:
    tab1[1] = true;
    BLINKER_LOG(" setFanMin");
    tab1[0] = false;
    tab1[2] = false;
    tab1[3] = false;
    tab1[4] = false;
    //      setFanMin();
    break;
  case BLINKER_CMD_TAB_2:
    tab1[2] = true;
    BLINKER_LOG("setFanLow");
    tab1[0] = false;
    tab1[1] = false;
    tab1[3] = false;
    tab1[4] = false;
    //      setFanLow();
    break;
  case BLINKER_CMD_TAB_3:
    tab1[3] = true;
    BLINKER_LOG(" setFanMedium");
    tab1[0] = false;
    tab1[1] = false;
    tab1[2] = false;
    tab1[4] = false;
    //      setFanMedium();
    break;
  case BLINKER_CMD_TAB_4:
    tab1[4] = true;
    BLINKER_LOG(" setFanHigh");
    tab1[0] = false;
    tab1[1] = false;
    tab1[2] = false;
    tab1[3] = false;
    //      setFanHigh();
    break;
  default:
    break;
  }

  countFan++;
  //Serial.print("接收指令次数:");
  //Serial.println(countFan);
  tabCountFan();
}

void tabCountFan()
{

  if (countFan == 1)
  {
    for (uint8_t one = 0; one < 5; one++)
    {
      tabSetFan[one] = tab1[one];
    }
  }
  else
  {
    for (uint8_t num = 0; num < 5; num++)
    {
      if (tab1[num])
      {
        if (lastSetFan == num)
        {
          for (uint8_t one = 0; one < 5; one++)
          {
            tab1[one] = tabSetFan[one];
            tabSetFan[one] = false;
          }
        }
      }
    }
  }
}

void setSpeed_feedback()
{
  for (uint8_t num = 0; num < 5; num++)
  {
    if (tab1[num])
    {

      sendFan(num);
      setSpeedTab.tab(num);
      lastSetFan = num;
      tab1[num] = false;
    }
  }
  setSpeedTab.print();
  countFan = 0;
}


void setup()
{
  Serial.begin(115200);
  BLINKER_DEBUG.stream(Serial);

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  // digitalWrite(ledPin, LOW);
  setIntIr();

  Blinker.begin(auth, ssid, pswd);
  Blinker.attachData(dataRead);
  ButtonPower.attach(buttonPower_callback);
  ButtonHealth.attach(buttonHealth_callback);
  Blinker.attachHeartbeat(heartbeat);//附加心跳
  SliderHump.attach(setHump_callback);
  setModeTab.attach(setMode_callback, setMode_feedback);
  setSpeedTab.attach(setSpeed_callback, setSpeed_feedback);
  BlinkerMIOT.attachPowerState(miotPowerState);
  Blinker.attachDataStorage(dataStorage);//附加数据存储  
  dht.begin();
  
    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  Blinker.delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
}

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

  // 显示
  display.clearDisplay();
  // 显示温度
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Temp: ");
  display.setTextSize(2);
  display.setCursor(0,10);
  display.print(t);
  display.print(" ");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print("C");
  // 显示湿度
  display.setTextSize(1);
  display.setCursor(0, 35);
  display.print("Humi: ");
  display.setTextSize(2);
  display.setCursor(0, 45);
  display.print(h);
  display.print(" %"); 
  //刷新显示
   display.display(); 
 }
  Blinker.delay(2000);
    
}   
    
void setFirm()
{
  decode_type_t protocol = (decode_type_t)firm;
  state.protocol = protocol; // Change the protocol used.
}

void sendIR()
{
  ac.sendAc(state, &prev); // Construct and send the message.
  ledState();
}

void ledState()
{
  //  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
  //    // 输出PWM
  //    analogWrite(LED_BUILTIN, fadeValue);
  //    // 等待30ms,以便观察到渐变效果
  //    delay(30);
  //  }
  //
  //  // 从亮到暗,以每次减5的形式逐渐暗下来
  //  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
  //    // 输出PWM
  //    analogWrite(LED_BUILTIN, fadeValue);
  //    // 等待30ms,以便观察到渐变效果
  //    delay(30);
  //  }
  //
  for (int i = 0; i < 6; i++)
  {
    digitalWrite(ledPin, !analogRead(ledPin));
    delay(100);
  }
}

void powerOn()
{
  setFirm();
  state.power = true; // We want to turn on the A/C unit.
  sendIR();
}

void powerOff()
{
  setFirm();
  state.power = false; // We want to turn on the A/C unit.
  sendIR();
}

void healthOn()
{
  setFirm();
  state.mode = stdAc::opmode_t::kAuto;
  sendIR();
}

void healthOff()
{
  setFirm();
  state.mode = stdAc::opmode_t::kHeat;
  ;
  sendIR();
}

void setDegrees(int32_t value)
{
  setFirm();
  state.degrees = value; // We want to turn on the A/C unit.
  sendIR();
}



void setIntIr()
{
  //  state.protocol = decode_type_t::KELVINATOR;  // Set a protocol to use.格力
  state.protocol = decode_type_t::ELECTRA_AC;  // Set a protocol to use.aux
  state.model = 1;                             // Some A/C's have different models. Let's try using just 1.
  state.mode = stdAc::opmode_t::kCool;         // Run in cool mode initially.
  state.celsius = true;                        // Use Celsius for units of temp. False = Fahrenheit
  state.degrees = 25;                          // 25 degrees.
  state.fanspeed = stdAc::fanspeed_t::kMedium; // Start with the fan at medium.
  state.swingv = stdAc::swingv_t::kOff;        // Don't swing the fan up or down.
  state.swingh = stdAc::swingh_t::kOff;        // Don't swing the fan left or right.
  state.light = true;                          // Turn off any LED/Lights/Display that we can.
  state.beep = false;                          // Turn off any beep from the A/C if we can.
  state.econo = false;                         // Turn off any economy modes if we can.
  state.filter = false;                        // Turn off any Ion/Mold/Health filters if we can.
  state.turbo = false;                         // Don't use any turbo/powerful/etc modes.
  state.quiet = false;                         // Don't use any quiet/silent/etc modes.
  state.sleep = -1;                            // Don't set any sleep time or modes.
  state.clean = false;                         // Turn off any Cleaning options if we can.
  state.clock = -1;                            // Don't set any current time if we can avoid it.
  state.power = false;                         // Initially start with the unit off.
  prev = state;                                // Make sure we have a valid previous state.
}
void setModeAuto()
{
  setFirm();
  state.power = true;
  state.mode = stdAc::opmode_t::kAuto;
  sendIR();
}
void setModeCool()
{
  setFirm();
  state.power = true;
  state.mode = stdAc::opmode_t::kCool;
  sendIR();
}
void setModeDry()
{
  setFirm();
  state.power = true;
  state.mode = stdAc::opmode_t::kDry;
  sendIR();
}

void setModeHeat()
{
  setFirm();
  state.power = true;
  state.mode = stdAc::opmode_t::kHeat;
  sendIR();
}

void setModeFan()
{
  setFirm();
  state.mode = stdAc::opmode_t::kFan;
  sendIR();
}
//发射红外
void sendMode(int a)
{
  switch (a)
  {
  case 0:
    setModeAuto();
    break;
  case 1:
    setModeCool();
    break;
  case 2:
    setModeDry();
    break;
  case 3:
    setModeHeat();
    break;
  case 4:
    setModeFan();
    break;
  default:
    break;
  }
}

void setFanAuto()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kAuto;
  sendIR();
}
void setFanMin()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kMin;
  sendIR();
}

void setFanLow()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kLow;
  sendIR();
}

void setFanMedium()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kMedium;
  sendIR();
}
void setFanHigh()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kHigh;
  sendIR();
}
void setFanMax()
{
  setFirm();
  state.fanspeed = stdAc::fanspeed_t::kMax;
  sendIR();
}

void sendFan(int a)
{
  switch (a)
  {
  case 0:
    setFanAuto();
    break;
  case 1:
    setFanLow();
    break;
  case 2:
    setFanMedium();
    break;
  case 3:
    setFanHigh();
    break;
  case 4:
    setFanMax();
    break;
  default:
    break;
  }
}
界面配置
keyboard_arrow_down

{¨config¨{¨headerColor¨¨transparent¨¨headerStyle¨¨dark¨¨background¨{¨img¨¨assets/img/bg/f1.jpg¨¨isFull¨»}}¨dashboard¨|{¨type¨¨btn¨¨ico¨¨fad fa-toggle-off¨¨mode¨Ê¨t0¨´关´¨clr¨¨#076EEF¨¨t1¨¨文本2¨¨bg¨É¨cols¨Ë¨rows¨Ë¨key¨¨powerac¨´x´Í´y´É¨speech¨|¦¨act¨¨cmd¨‡¨on¨¨开启空调¨¨off¨¨关闭空调¨—÷¨lstyle¨Ê¨cus¨¨OFF¨}{ßA¨ran¨ßF¨温度¨ßGßH¨max¨¤U¨min¨¤IßKÉßLÏßMËßN¨sethump¨´x´É´y´ËßP|÷ßWÊ}{ßA¨tex¨ßF¨空调控制¨ßI¨三星 v0.1.0¨ßKÉßC¨fad fa-air-conditioner¨ßLÍßMËßN´´´x´É´y´ÉßP|÷ßWÌßGßH}{ßA¨num¨ßF¨设定温度¨ßC¨fad fa-thermometer-three-quarters¨ßG¨#389BEE¨ßcÉßb¤U¨uni¨´℃´ßKÉßLËßMËßNßd´x´Ï´y´ËßP|÷ßWÉ}{ßA¨tab¨ßKÉßLÑßMËßN¨setspeed¨´x´É´y´ÏßP|÷ßC¨fad fa-fan¨ßF¨自动¨¨ico1¨¨iconfont icon-n1¨¨ico2¨¨iconfont icon-n2¨¨ico3¨¨iconfont icon-n3¨¨ico4¨¨iconfont icon-n4¨ßI¨一档¨´t2´´二档´´t3´´三档´´t4´´四档´ßGßH}{ßAßnßKÉßLÑßMËßN¨setmode¨´x´É´y´ÍßP|÷ßFßqßI´制冷´ßC¨fad fa-chart-network¨ßr¨fad fa-snowflakes¨´t2´´除湿´´t3´´制热´´t4´´通风´ßt¨fad fa-tint¨ßv¨fad fa-sun¨ßx¨fad fa-wind¨ßGßH}{ßAßBßC¨fad fa-flower-tulip¨ßEÊßF´健康´ßIßJßKÉßLËßMËßN¨healthac¨´x´Ï´y´ÉßP|÷ßWÉßG¨#595959¨}{ßAßißF´湿度´ßCß13ßGßlßcÉßb¢1cßm´%´ßKÉßLËßMËßN¨humi¨´x´Ë´y´ÑßP|÷ßWÉ}{ßAßißF¨实际温度¨ßCßkßGßlßcÉßbº0ßm´℃´ßKÉßLËßMËßN¨temp¨´x´É´y´ÑßP|÷ßWÉ}{ßAßeßF¨运行时间¨ßI¨开发板运行时间¨ßKÉßC´´ßLÍßMËßN¨tex-s¨´x´Í´y´ÑßP|÷ßWÌ}{ßA¨cha¨ßKɨsty¨¨line¨ßGßl¨sty1¨ß1H¨clr1¨ßl¨sty2¨ß1H¨clr2¨ßlßLÑßMÌßN¨cha-tep¨´x´É´y´¤AßP|÷¨key1¨¨cha-hum¨ßFßaßI´湿度´}÷¨actions¨|¦ßR¦¨switch¨‡¨text¨‡ßS¨打开?name¨ßU¨关闭?name¨—÷¨triggers¨|{¨source¨ß1Q¨source_zh¨¨开关状态¨¨state¨|ßSßU÷¨state_zh¨|´打开´´关闭´÷}÷}

温湿度传感器+屏幕 接线请看 https://www.coolapk.com/feed/17905213?shareKey=YzIwNjY5N2EyNmM4NWYzNjVhOTE~&shareUid=2370747&shareFrom=com.coolapk.market_10.5

赞赏
本篇文章部分资源来自https://www.arduino.cn/forum.php?mod=viewthread&tid=93385 酷安@仟念 【侵删】

1812z

文章作者

发表评论

textsms
account_circle
email

1812z's blog

ESP8266与空调智能遥控-点灯科技-小爱同学
这篇文章只写主要内容,基础操作自行百度[库安装,开发板设定] 本文分两个版本 原版【只有遥控器】修改版【加入气象站】 Part.0-准备材料 硬件材料 总览 需要…
扫描二维码继续阅读
2020-08-08