物联网红外遥控器

非常遗憾,lua固件的ESP8266陪PWM波频率最高只能1000hz,

红外需要38KHZ,所以不能直接用8266生成载波,需要外置的频率发生器,后期再做吧

lua版本的还没做,先来个arduino版本的充数

程序可以直接下载到esp8266中

参考资料
红外模块:https://www.bilibili.com/video/av31659175?t=2761
dht11:https://github.com/winlinvip/SimpleDHT/blob/master/examples/DHT11Default/DHT11Default.ino
联网模块:https://github.com/bigiot/bigiotArduino/blob/master/examples/ESP8266/ESP8266WIFI/control4/control4.ino
项目的所有代码都在https://github.com/TuShen121/HONG-WAI

联网模块



#include 
#include 
//=============  此处必须修该============
String DEVICEID="xxxx"; // 你的设备编号   ==
String  APIKEY = "xxxxx"; // 设备密码==
//=======================================
unsigned long lastCheckInTime = 0; //记录上次报到时间
const unsigned long postingInterval = 10000; // 每隔40秒向服务器报到一次

const char* ssid     = "dzsjjs-216";//无线名称
const char* password = "dzsjjs216";//无线密码

const char* host = "www.bigiot.net";
const int httpPort = 8181;

void setup() {
  Serial.begin(115200);
  delay(1000);

  WiFi.begin(ssid, password);
}

WiFiClient client;

void loop() {

  while (WiFi.status() != WL_CONNECTED) {//等待连接WiFi
    delay(1000);
    Serial.print(".");
  }

  // Use WiFiClient class to create TCP connections
  if (!client.connected()) {//等待连接服务器
    if (!client.connect(host, httpPort)) {
      Serial.println("connection failed");
      delay(5000);
      return;
    }
  }

  if(millis() - lastCheckInTime > postingInterval || lastCheckInTime==0) {
    checkIn();
  }
  
  // Read all the lines of the reply from server and print them to Serial
  if (client.available()) {
    String inputString = client.readStringUntil('\n');
    inputString.trim();
    Serial.println(inputString);
    int len = inputString.length()+1;
    if(inputString.startsWith("{") && inputString.endsWith("}")){    
 /******************************************************************************************************************/
      int i=inputString.indexOf("\"C\":");
      Serial.println(i);
      if(i>5)
      {
        String rec;
        //Serial.println(inputString.substring(i+5,i+7));
        rec=inputString.substring(i+5,i+7);
        Serial.println(rec);
        switch(rec.toInt())
        {
          case 0:
            Serial.println(0);
            break;
          case 1:
            Serial.println(1);
            break;
          case 2:
            Serial.println(2);
            break;
                  
        }
      }

/***********************************************************************************************************/
    }
  }
}

void checkIn() {
    String msg = "{\"M\":\"checkin\",\"ID\":\"" + DEVICEID + "\",\"K\":\"" + APIKEY + "\"}\n";
    String msg1 = "{\"M\":\"say\",\"ID\":\"U5739\",\"C\":\" hongWai\",\"SIGN\":\" hongWai\"}\n";
    client.print(msg);
    
    client.print(msg1);
    lastCheckInTime = millis(); 
}

void sayToClient(String client_id, String content){
  String msg = "{\"M\":\"say\",\"ID\":\"" + client_id + "\",\"C\":\"" + content + "\"}\n";
  client.print(msg);
  lastCheckInTime = millis();
}
dht11模块
#include 

// for DHT11, 
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);

void setup() {
  Serial.begin(115200);
}

void loop() {
  // start working...
  Serial.println("=================================");
  Serial.println("Sample DHT11...");
  
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);
    return;
  }
  
  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, "); 
  Serial.print((int)humidity); Serial.println(" H");
  
  // DHT11 sampling rate is 1HZ.
  delay(1500);
}

完整版



#include 

#include 
//=================DHT11===================
#include 

int pinDHT11 = 5;//D1
SimpleDHT11 dht11(pinDHT11);

//===============红外头文件======================
     #ifndef UNIT_TEST
     #include 
     #endif
     #include 
     #include 
     const uint16_t kIrLed = 4;  // ESP8266 GPIO pin to use. Recommended: 4 (D2).
     IRsend irsend(kIrLed);  // Set the GPIO to be used to sending the message.
//=============  此处必须修该============
     String DEVICEID="xxxx"; // 你的设备编号   ==
     String  APIKEY = "xxxxx"; // 设备密码==
//=======================================
     unsigned long lastCheckInTime = 0; //记录上次报到时间
     const unsigned long postingInterval = 5000; // 每隔5秒向服务器报到一次
     
     const char* ssid     = "dzsjjs-216";//无线名称
     const char* password = "dzsjjs216";//无线密码
     
     const char* host = "www.bigiot.net";
     const int httpPort = 8181;
//==============================红外代码======================================================================
//开机
uint16_t kaiJi[139] = {8968, 4526,  628, 572,  626, 574,  626, 574,  626, 1694,  624, 576,  624, 574,  624, 1696,  624, 550,  648, 574,  626, 574,  624, 576,  624, 548,  648, 576,  624, 576,  624, 572,  624, 576,  624, 574,  604, 594,  626, 572,  626, 548,  652, 550,  626, 1716,  624, 574,  626, 574,  626, 572,  626, 574,  624, 600,  600, 600,  598, 1694,  624, 574,  626, 1670,  650, 574,  622, 576,  624, 1670,  650, 574,  622, 19990,  628, 1716,  604, 596,  604, 594,  604, 594,  604, 572,  626, 598,  602, 596,  602, 596,  602, 596,  604, 596,  602, 572,  628, 596,  604, 594,  604, 596,  602, 596,  604, 598,  602, 596,  602, 596,  604, 570,  628, 570,  628, 596,  602, 596,  602, 594,  604, 594,  604, 572,  628, 570,  628, 572,  628, 596,  602, 570,  630, 1690,  628, 596,  604, 570,  628};  // GREE
//uint8_t state[8] = {0x48, 0x00, 0x20, 0x50, 0x01, 0x00, 0x00, 0x20};
//关机
uint16_t guanJi[139] = {8970, 4498,  652, 548,  652, 572,  626, 574,  626, 576,  624, 572,  626, 574,  624, 1670,  650, 576,  622, 574,  626, 548,  652, 576,  624, 574,  624, 572,  624, 576,  624, 574,  626, 572,  626, 550,  650, 574,  626, 548,  648, 576,  624, 574,  624, 1672,  650, 574,  624, 600,  598, 574,  626, 550,  650, 576,  624, 574,  626, 1694,  626, 572,  624, 1668,  652, 574,  624, 548,  652, 1668,  650, 576,  624, 19990,  628, 1690,  628, 574,  626, 598,  602, 572,  628, 596,  602, 598,  602, 596,  604, 596,  604, 598,  600, 598,  602, 596,  600, 602,  600, 596,  604, 596,  600, 598,  604, 594,  604, 596,  604, 598,  598, 596,  604, 570,  628, 598,  602, 596,  604, 596,  602, 596,  602, 598,  600, 596,  602, 572,  630, 594,  602, 572,  628, 1690,  628, 596,  602, 1690,  630};  // GREE
//uint8_t state[8] = {0x40, 0x00, 0x20, 0x50, 0x01, 0x00, 0x00, 0xA0};

/************************************************************/

/******************************************************************/
//制冷16
uint16_t leng16[139] = {8972, 4524,  606, 1688,  630, 570,  628, 596,  604, 1688,  630, 596,  602, 596,  602, 1692,  628, 596,  602, 596,  608, 566,  628, 596,  602, 596,  604, 570,  630, 570,  628, 596,  604, 570,  628, 572,  628, 570,  630, 594,  606, 570,  628, 596,  604, 1688,  630, 570,  628, 598,  602, 572,  628, 596,  602, 570,  632, 594,  604, 1688,  628, 570,  630, 1688,  630, 596,  604, 596,  602, 1716,  604, 596,  604, 20012,  626, 1690,  630, 570,  630, 594,  602, 596,  604, 596,  604, 596,  604, 594,  604, 572,  626, 598,  604, 594,  604, 598,  604, 596,  604, 568,  630, 596,  604, 594,  602, 570,  630, 570,  628, 598,  604, 594,  604, 596,  604, 572,  628, 568,  630, 570,  628, 596,  604, 596,  604, 568,  630, 570,  630, 596,  602, 1690,  630, 1688,  630, 570,  628, 598,  602};  // GREE
//uint8_t state[8] = {0x49, 0x00, 0x20, 0x50, 0x01, 0x00, 0x00, 0x30};
//制冷17
uint16_t leng17[139] = {8970, 4526,  602, 1714,  604, 598,  604, 594,  624, 1696,  602, 600,  598, 572,  628, 1690,  652, 574,  624, 1692,  624, 576,  626, 548,  632, 594,  602, 604,  598, 594,  622, 576,  604, 594,  604, 596,  624, 574,  626, 574,  618, 580,  624, 576,  624, 1668,  628, 596,  624, 576,  624, 574,  602, 598,  624, 550,  628, 596,  604, 1716,  624, 574,  604, 1714,  604, 598,  600, 600,  602, 1716,  624, 574,  602, 20010,  630, 1714,  604, 596,  604, 570,  630, 568,  630, 596,  602, 596,  602, 596,  604, 596,  604, 572,  626, 596,  604, 596,  604, 594,  606, 594,  604, 572,  628, 572,  628, 596,  602, 596,  602, 598,  602, 596,  604, 594,  604, 596,  602, 596,  604, 570,  628, 596,  604, 596,  604, 594,  602, 596,  604, 570,  630, 568,  628, 572,  628, 1690,  630, 570,  630};  // GREE
//uint8_t state[8] = {0x49, 0x01, 0x20, 0x50, 0x01, 0x00, 0x00, 0x40};
//制冷18
uint16_t leng18[139] = {8998, 4524,  602, 1718,  602, 596,  602, 596,  602, 1716,  602, 596,  604, 596,  602, 1692,  628, 594,  602, 596,  604, 1716,  604, 594,  604, 596,  602, 570,  630, 596,  602, 598,  602, 596,  604, 596,  602, 594,  604, 596,  602, 596,  602, 598,  602, 1716,  602, 596,  604, 570,  628, 596,  604, 594,  604, 596,  604, 596,  602, 1688,  630, 570,  626, 1718,  602, 598,  604, 596,  604, 1690,  628, 598,  602, 20008,  630, 1692,  628, 596,  604, 596,  602, 596,  604, 596,  604, 596,  604, 568,  630, 596,  602, 574,  626, 598,  602, 570,  628, 596,  604, 594,  606, 596,  600, 598,  600, 572,  628, 572,  628, 596,  602, 596,  602, 596,  602, 596,  604, 594,  604, 598,  600, 596,  604, 570,  628, 596,  602, 598,  602, 572,  628, 1692,  628, 598,  602, 1716,  604, 596,  602};  // GREE
//uint8_t state[8] = {0x49, 0x02, 0x20, 0x50, 0x01, 0x00, 0x00, 0x50};
//制冷19
uint16_t leng19[139] = {8972, 4498,  630, 1688,  630, 570,  630, 596,  602, 1690,  630, 594,  604, 596,  604, 1714,  604, 572,  628, 1690,  630, 1716,  604, 594,  604, 596,  602, 570,  628, 596,  602, 596,  604, 568,  628, 596,  602, 572,  630, 596,  602, 596,  602, 598,  604, 1692,  626, 596,  602, 596,  604, 596,  602, 572,  628, 596,  604, 596,  604, 1688,  630, 596,  602, 1714,  604, 570,  628, 596,  602, 1716,  604, 596,  602, 20036,  600, 1718,  602, 596,  604, 596,  602, 570,  630, 596,  602, 596,  604, 596,  602, 596,  602, 594,  604, 596,  602, 574,  626, 596,  604, 596,  604, 594,  604, 570,  630, 596,  604, 568,  628, 572,  628, 596,  604, 596,  604, 594,  604, 598,  600, 574,  628, 570,  628, 572,  628, 596,  602, 572,  628, 596,  604, 594,  604, 1692,  628, 1692,  628, 598,  600};  // GREE
//uint8_t state[8] = {0x49, 0x03, 0x20, 0x50, 0x01, 0x00, 0x00, 0x60};
//制冷20
uint16_t leng20[139] = {8998, 4524,  602, 1716,  602, 572,  628, 572,  628, 1716,  602, 596,  604, 594,  602, 1716,  604, 596,  602, 596,  604, 596,  602, 1716,  604, 598,  600, 572,  626, 598,  600, 598,  602, 572,  628, 570,  628, 596,  602, 596,  602, 596,  602, 598,  602, 1718,  602, 596,  604, 596,  604, 572,  626, 594,  604, 596,  604, 596,  602, 1716,  604, 596,  602, 1692,  628, 598,  602, 596,  602, 1692,  628, 598,  602, 20008,  630, 1688,  630, 596,  604, 572,  628, 596,  604, 594,  604, 596,  600, 596,  604, 570,  628, 596,  604, 596,  604, 572,  626, 596,  602, 596,  604, 568,  628, 570,  630, 596,  602, 596,  604, 596,  602, 596,  602, 572,  630, 570,  628, 596,  602, 598,  602, 596,  602, 596,  604, 596,  602, 572,  628, 596,  602, 1692,  630, 1688,  630, 1714,  602, 598,  602};  // GREE
//uint8_t state[8] = {0x49, 0x04, 0x20, 0x50, 0x01, 0x00, 0x00, 0x70};
//制冷21
uint16_t leng21[139] = {8996, 4526,  602, 1716,  626, 550,  650, 574,  624, 1696,  600, 598,  624, 574,  602, 1692,  648, 574,  622, 1696,  624, 576,  624, 1694,  626, 548,  652, 548,  650, 576,  624, 576,  624, 576,  624, 574,  626, 574,  624, 574,  626, 574,  626, 548,  634, 1684,  652, 576,  624, 574,  610, 588,  626, 574,  624, 576,  622, 578,  624, 1694,  602, 598,  602, 1716,  602, 598,  624, 574,  626, 1694,  602, 598,  626, 20012,  602, 1692,  630, 596,  602, 596,  602, 598,  604, 570,  628, 570,  628, 596,  602, 572,  626, 598,  600, 574,  628, 594,  602, 598,  602, 598,  602, 570,  630, 596,  602, 598,  604, 594,  604, 596,  604, 596,  604, 596,  602, 596,  604, 570,  628, 596,  604, 598,  602, 596,  602, 598,  604, 596,  602, 598,  600, 598,  602, 584,  616, 572,  628, 1690,  628};  // GREE
//uint8_t state[8] = {0x49, 0x05, 0x20, 0x50, 0x01, 0x00, 0x00, 0x80};
//制冷22
uint16_t leng22[139] = {8996, 4498,  630, 1716,  604, 570,  628, 596,  602, 1718,  602, 596,  604, 570,  628, 1690,  630, 594,  604, 596,  604, 1716,  604, 1690,  628, 572,  628, 598,  602, 596,  602, 596,  602, 598,  604, 596,  602, 598,  602, 596,  602, 598,  604, 596,  602, 1690,  630, 570,  630, 572,  626, 596,  604, 596,  602, 572,  626, 598,  602, 1690,  630, 594,  602, 1716,  604, 596,  602, 596,  602, 1716,  604, 596,  602, 20036,  604, 1690,  630, 570,  628, 574,  626, 598,  600, 598,  602, 596,  604, 596,  604, 594,  602, 572,  628, 572,  628, 596,  604, 596,  602, 596,  604, 570,  628, 572,  628, 570,  630, 570,  628, 596,  600, 598,  602, 598,  602, 572,  626, 596,  606, 594,  602, 596,  602, 594,  604, 596,  602, 596,  604, 596,  604, 1688,  630, 596,  602, 598,  604, 1714,  602};  // GREE
//uint8_t state[8] = {0x49, 0x06, 0x20, 0x50, 0x01, 0x00, 0x00, 0x90};
//制冷23
uint16_t leng23[139] = {8970, 4526,  602, 1714,  622, 578,  602, 572,  626, 1716,  602, 574,  626, 572,  626, 1692,  628, 596,  622, 1696,  624, 1670,  630, 1692,  636, 588,  622, 552,  650, 550,  628, 596,  624, 574,  626, 574,  602, 570,  628, 572,  628, 598,  600, 598,  602, 1716,  602, 598,  602, 598,  600, 596,  604, 598,  600, 598,  604, 594,  604, 1716,  602, 596,  604, 1716,  602, 598,  624, 600,  580, 1688,  628, 598,  602, 20010,  630, 1690,  630, 596,  604, 594,  604, 570,  630, 596,  602, 570,  630, 570,  628, 596,  602, 572,  630, 592,  606, 570,  628, 570,  630, 570,  628, 570,  628, 596,  604, 570,  628, 570,  628, 572,  626, 596,  604, 570,  630, 572,  626, 598,  602, 596,  604, 596,  604, 594,  606, 594,  604, 594,  604, 570,  630, 570,  630, 1714,  604, 594,  604, 1716,  604};  // GREE
//uint8_t state[8] = {0x49, 0x07, 0x20, 0x50, 0x01, 0x00, 0x00, 0xA0};
//制冷24
uint16_t leng24[139] = {9000, 4494,  654, 1668,  650, 572,  604, 596,  604, 1714,  626, 574,  602, 596,  626, 1692,  628, 570,  628, 572,  604, 596,  626, 572,  626, 1692,  626, 572,  628, 546,  652, 572,  628, 572,  626, 572,  604, 596,  624, 550,  654, 570,  602, 598,  626, 1666,  652, 574,  628, 544,  654, 570,  604, 594,  628, 572,  628, 544,  654, 1666,  650, 574,  628, 1666,  630, 596,  604, 570,  652, 1692,  626, 572,  628, 19986,  656, 1664,  654, 548,  652, 570,  628, 546,  628, 572,  626, 598,  602, 598,  604, 594,  628, 570,  624, 574,  626, 576,  626, 572,  626, 572,  604, 572,  628, 596,  602, 596,  602, 594,  628, 572,  604, 596,  626, 572,  602, 598,  626, 546,  630, 596,  604, 596,  602, 570,  630, 570,  652, 546,  650, 574,  602, 1718,  602, 1716,  604, 572,  650, 1692,  602};  // GREE
//uint8_t state[8] = {0x49, 0x08, 0x20, 0x50, 0x01, 0x00, 0x00, 0xB0};
//制冷25
uint16_t leng25[139] = {8970, 4526,  602, 1716,  602, 596,  604, 596,  602, 1716,  602, 572,  628, 572,  628, 1716,  624, 576,  622, 1670,  648, 602,  600, 546,  650, 1670,  650, 550,  640, 584,  608, 590,  624, 576,  602, 596,  604, 596,  602, 598,  606, 592,  614, 586,  624, 1694,  624, 576,  602, 570,  650, 576,  624, 550,  628, 572,  650, 576,  624, 1668,  626, 598,  600, 1716,  628, 546,  652, 574,  602, 1716,  624, 550,  650, 20014,  602, 1716,  606, 596,  602, 594,  604, 570,  628, 598,  602, 596,  602, 572,  628, 596,  602, 596,  604, 596,  604, 596,  604, 570,  628, 572,  628, 572,  626, 596,  604, 596,  602, 596,  604, 570,  628, 598,  604, 568,  632, 568,  630, 596,  604, 596,  602, 596,  604, 594,  604, 596,  604, 594,  604, 570,  628, 598,  604, 568,  630, 1690,  628, 1692,  626};  // GREE
//uint8_t state[8] = {0x49, 0x09, 0x20, 0x50, 0x01, 0x00, 0x00, 0xC0};
//制冷26
uint16_t leng26[139] = {8972, 4526,  602, 1718,  604, 568,  628, 572,  628, 1698,  622, 594,  604, 598,  602, 1716,  602, 598,  602, 598,  602, 1716,  604, 596,  604, 1716,  604, 594,  602, 596,  604, 596,  602, 596,  602, 598,  602, 594,  604, 596,  604, 594,  602, 570,  630, 1716,  602, 598,  602, 596,  602, 596,  604, 596,  604, 594,  604, 596,  602, 1718,  602, 594,  604, 1716,  604, 596,  602, 598,  602, 1716,  602, 596,  602, 20010,  630, 1716,  602, 598,  602, 596,  604, 596,  602, 572,  630, 596,  602, 596,  602, 596,  602, 596,  604, 596,  602, 596,  604, 596,  602, 598,  602, 598,  602, 594,  604, 596,  602, 570,  628, 596,  604, 596,  604, 594,  604, 596,  602, 598,  602, 570,  628, 572,  628, 598,  602, 594,  606, 594,  602, 598,  602, 1716,  606, 596,  602, 1690,  628, 1692,  628};  // GREE
//uint8_t state[8] = {0x49, 0x0A, 0x20, 0x50, 0x01, 0x00, 0x00, 0xD0};
//制冷27
uint16_t leng27[139] = {8970, 4526,  600, 1692,  652, 572,  602, 596,  626, 1692,  628, 544,  628, 570,  652, 1666,  652, 548,  650, 1668,  626, 1718,  624, 550,  652, 1692,  624, 550,  650, 572,  604, 596,  604, 596,  602, 598,  624, 574,  630, 568,  624, 576,  626, 548,  628, 1692,  626, 572,  628, 570,  628, 598,  624, 574,  624, 576,  624, 574,  624, 1670,  626, 598,  606, 1714,  628, 546,  628, 570,  652, 1692,  624, 574,  602, 20010,  630, 1718,  602, 598,  626, 546,  628, 570,  630, 596,  604, 570,  628, 570,  628, 572,  628, 598,  602, 570,  630, 596,  600, 598,  604, 568,  630, 570,  628, 574,  650, 574,  602, 596,  604, 598,  602, 596,  628, 546,  654, 572,  600, 598,  604, 594,  602, 596,  602, 596,  604, 568,  654, 544,  630, 598,  602, 594,  604, 1690,  632, 1712,  604, 1716,  628};  // GREE
//uint8_t state[8] = {0x49, 0x0B, 0x20, 0x50, 0x01, 0x00, 0x00, 0xE0};
//制冷28
uint16_t leng28[139] = {8942, 4554,  598, 1696,  624, 576,  624, 578,  620, 1698,  624, 576,  622, 576,  626, 1694,  624, 602,  598, 600,  600, 548,  650, 1692,  624, 1694,  626, 552,  646, 552,  650, 600,  596, 578,  624, 576,  624, 574,  624, 576,  622, 552,  648, 600,  600, 1692,  626, 574,  626, 550,  648, 576,  624, 574,  624, 552,  648, 576,  624, 1668,  648, 576,  624, 1694,  624, 574,  624, 576,  626, 1696,  622, 576,  624, 20014,  622, 1670,  650, 574,  624, 574,  626, 576,  622, 578,  622, 576,  622, 576,  624, 552,  648, 550,  650, 550,  648, 576,  624, 576,  624, 576,  622, 550,  650, 574,  624, 574,  624, 574,  626, 576,  624, 576,  624, 576,  622, 576,  624, 576,  622, 576,  624, 578,  622, 574,  624, 574,  624, 574,  624, 574,  624, 1670,  650, 1668,  650, 1670,  648, 1696,  624};  // GREE
//uint8_t state[8] = {0x49, 0x0C, 0x20, 0x50, 0x01, 0x00, 0x00, 0xF0};
//制冷29
uint16_t leng29[139] = {8970, 4498,  630, 1716,  604, 596,  602, 596,  604, 1688,  630, 598,  602, 570,  628, 1692,  628, 596,  602, 1718,  602, 598,  602, 1718,  604, 1690,  628, 596,  602, 572,  628, 572,  626, 574,  628, 594,  602, 570,  630, 596,  602, 598,  602, 570,  626, 1716,  604, 574,  626, 596,  602, 598,  600, 572,  628, 570,  626, 572,  628, 1692,  626, 596,  604, 1690,  628, 596,  604, 572,  626, 1694,  626, 572,  628, 20036,  602, 1718,  624, 574,  622, 552,  648, 600,  600, 576,  622, 550,  646, 576,  626, 574,  622, 578,  624, 574,  614, 586,  624, 600,  600, 574,  604, 598,  624, 574,  626, 572,  626, 572,  626, 574,  626, 576,  600, 596,  624, 550,  648, 576,  624, 552,  650, 574,  616, 582,  626, 572,  602, 572,  652, 572,  626, 548,  652, 548,  648, 576,  624, 574,  624};  // GREE
//uint8_t state[8] = {0x49, 0x0D, 0x20, 0x50, 0x01, 0x00, 0x00, 0x00};
//制冷30
uint16_t leng30[139] = {8940, 4554,  598, 1668,  650, 574,  626, 572,  624, 1668,  650, 578,  624, 576,  622, 1696,  622, 578,  622, 574,  626, 1694,  624, 1696,  624, 1668,  650, 600,  598, 576,  624, 576,  624, 552,  648, 548,  650, 600,  598, 602,  596, 574,  626, 600,  598, 1696,  624, 600,  598, 548,  652, 574,  624, 602,  598, 574,  624, 576,  624, 1694,  626, 574,  624, 1694,  624, 552,  648, 548,  650, 1698,  624, 600,  600, 19988,  650, 1668,  652, 548,  650, 578,  622, 574,  624, 602,  598, 576,  622, 576,  624, 574,  626, 600,  598, 602,  596, 576,  624, 548,  652, 600,  598, 576,  622, 602,  598, 574,  622, 602,  600, 548,  652, 574,  622, 602,  596, 576,  624, 576,  622, 602,  598, 574,  624, 574,  626, 600,  598, 600,  600, 548,  650, 1694,  624, 578,  622, 574,  626, 574,  622};  // GREE
//uint8_t state[8] = {0x49, 0x0E, 0x20, 0x50, 0x01, 0x00, 0x00, 0x10};
/********************************************************************************/




/**************************************************************************************/
//制热16
uint16_t re16[139] = {8998, 4522,  604, 572,  630, 594,  602, 1690,  630, 1714,  604, 570,  630, 572,  628, 1690,  628, 596,  604, 596,  602, 598,  602, 596,  604, 570,  628, 572,  626, 570,  628, 570,  630, 596,  604, 570,  628, 596,  604, 572,  628, 570,  628, 596,  602, 1692,  628, 570,  628, 570,  630, 570,  628, 596,  602, 570,  630, 572,  628, 1716,  602, 596,  604, 1692,  626, 596,  602, 572,  628, 1688,  630, 568,  628, 20010,  630, 1716,  606, 594,  602, 570,  628, 570,  628, 570,  628, 596,  604, 572,  628, 596,  604, 594,  604, 596,  602, 596,  602, 598,  602, 596,  602, 596,  602, 596,  604, 570,  626, 596,  606, 592,  606, 570,  628, 572,  630, 594,  606, 568,  628, 572,  628, 596,  604, 596,  602, 572,  628, 596,  604, 570,  628, 570,  628, 1690,  630, 1716,  602, 572,  626};  // GREE
//uint8_t state[8] = {0x4C, 0x00, 0x20, 0x50, 0x01, 0x00, 0x00, 0x60};
//制热17
uint16_t re17[139] = {8972, 4524,  604, 594,  604, 598,  600, 1718,  602, 1690,  626, 598,  602, 596,  604, 1714,  602, 596,  604, 1718,  602, 598,  600, 572,  628, 594,  604, 572,  628, 596,  604, 574,  624, 598,  602, 594,  604, 570,  628, 598,  602, 596,  602, 574,  628, 1692,  628, 596,  600, 598,  602, 596,  604, 596,  604, 570,  628, 596,  602, 1716,  602, 598,  600, 1690,  630, 572,  628, 594,  604, 1716,  602, 596,  602, 20010,  628, 1718,  602, 596,  602, 570,  630, 596,  602, 596,  602, 598,  604, 594,  602, 596,  604, 594,  604, 570,  630, 596,  602, 570,  628, 574,  626, 596,  602, 598,  602, 596,  602, 572,  626, 572,  628, 598,  602, 596,  602, 594,  604, 598,  602, 596,  602, 596,  602, 594,  604, 598,  602, 596,  602, 596,  602, 1692,  628, 1716,  604, 1690,  628, 596,  604};  // GREE
//uint8_t state[8] = {0x4C, 0x01, 0x20, 0x50, 0x01, 0x00, 0x00, 0x70};
//制热18
uint16_t re18[139] = {8996, 4502,  626, 570,  628, 596,  604, 1716,  604, 1690,  628, 572,  626, 598,  600, 1694,  626, 596,  628, 572,  602, 1716,  604, 596,  600, 598,  626, 572,  604, 594,  626, 574,  602, 598,  604, 594,  626, 574,  626, 574,  624, 572,  614, 560,  628, 1718,  626, 548,  652, 574,  602, 598,  624, 574,  602, 598,  624, 548,  654, 1690,  604, 598,  602, 1718,  604, 596,  626, 572,  626, 1694,  624, 576,  626, 19986,  630, 1716,  604, 594,  604, 596,  604, 570,  628, 598,  600, 596,  604, 596,  630, 570,  602, 596,  602, 572,  628, 596,  604, 594,  602, 596,  626, 546,  630, 594,  604, 570,  630, 596,  602, 596,  604, 594,  604, 570,  654, 546,  628, 574,  626, 574,  626, 596,  604, 596,  604, 596,  602, 598,  602, 596,  604, 570,  630, 596,  602, 596,  602, 1716,  606};  // GREE
//uint8_t state[8] = {0x4C, 0x02, 0x20, 0x50, 0x01, 0x00, 0x00, 0x80};
//制热19
uint16_t re19[139] = {8966, 4554,  598, 574,  626, 548,  650, 1696,  624, 1694,  626, 576,  624, 548,  650, 1692,  624, 576,  626, 1720,  598, 1696,  622, 576,  626, 600,  598, 550,  650, 574,  626, 548,  650, 548,  650, 576,  624, 574,  626, 576,  624, 550,  648, 576,  622, 1670,  652, 574,  622, 576,  624, 576,  624, 574,  624, 576,  622, 550,  650, 1670,  650, 602,  598, 1694,  622, 576,  624, 576,  624, 1668,  648, 602,  596, 20016,  624, 1698,  622, 574,  624, 574,  624, 574,  624, 552,  648, 602,  598, 600,  596, 602,  598, 602,  598, 550,  648, 600,  598, 576,  622, 600,  598, 576,  624, 550,  648, 550,  648, 576,  622, 552,  648, 576,  624, 576,  624, 580,  620, 550,  650, 600,  600, 600,  596, 552,  650, 548,  650, 574,  624, 602,  598, 1668,  650, 552,  648, 600,  598, 1670,  650};  // GREE
//uint8_t state[8] = {0x4C, 0x03, 0x20, 0x50, 0x01, 0x00, 0x00, 0x90};
//制热20
uint16_t re20[139] = {8968, 4526,  624, 574,  626, 574,  624, 1668,  652, 1694,  626, 574,  626, 550,  648, 1694,  626, 572,  626, 574,  624, 550,  650, 1668,  650, 574,  624, 550,  648, 576,  624, 574,  626, 572,  626, 550,  650, 572,  626, 600,  598, 578,  624, 574,  626, 1692,  628, 574,  626, 548,  650, 574,  624, 548,  650, 574,  624, 574,  626, 1694,  624, 574,  628, 1668,  652, 574,  624, 600,  600, 1692,  626, 572,  626, 20014,  602, 1692,  628, 570,  630, 572,  626, 598,  602, 596,  604, 596,  602, 570,  630, 594,  604, 598,  602, 598,  600, 598,  602, 570,  630, 594,  606, 594,  604, 570,  628, 572,  628, 596,  602, 596,  604, 594,  606, 572,  626, 596,  602, 570,  628, 570,  628, 596,  604, 596,  602, 598,  604, 596,  602, 598,  600, 596,  604, 1716,  604, 596,  604, 1716,  602};  // GREE
//uint8_t state[8] = {0x4C, 0x04, 0x20, 0x50, 0x01, 0x00, 0x00, 0xA0};
//制热21
uint16_t re21[139] = {8942, 4528,  624, 600,  598, 574,  626, 1720,  598, 1694,  624, 574,  626, 548,  650, 1720,  598, 574,  622, 1672,  648, 576,  624, 1694,  622, 576,  624, 548,  648, 552,  648, 550,  648, 576,  622, 550,  650, 574,  624, 576,  626, 576,  624, 550,  650, 1670,  648, 576,  624, 600,  600, 574,  624, 576,  624, 550,  650, 552,  646, 1672,  648, 548,  650, 1696,  624, 574,  626, 574,  624, 1670,  648, 602,  596, 20016,  624, 1696,  624, 574,  624, 574,  624, 574,  626, 548,  648, 552,  648, 576,  624, 552,  646, 602,  596, 578,  622, 576,  622, 578,  622, 602,  598, 552,  650, 600,  598, 576,  622, 576,  624, 574,  624, 602,  598, 576,  624, 574,  624, 576,  622, 548,  652, 576,  624, 550,  650, 574,  624, 576,  622, 576,  622, 1694,  624, 1722,  598, 602,  596, 1722,  598};  // GREE
//uint8_t state[8] = {0x4C, 0x05, 0x20, 0x50, 0x01, 0x00, 0x00, 0xB0};
//制热22
uint16_t re22[139] = {8970, 4500,  628, 572,  628, 596,  602, 1692,  628, 1690,  628, 596,  604, 570,  628, 1716,  602, 598,  602, 596,  602, 1718,  602, 1692,  626, 572,  626, 572,  628, 596,  604, 596,  604, 596,  602, 570,  628, 574,  626, 596,  602, 596,  604, 572,  626, 1690,  628, 598,  600, 598,  600, 570,  628, 596,  604, 572,  626, 598,  602, 1694,  626, 598,  600, 1692,  628, 574,  626, 596,  602, 1716,  602, 596,  602, 20036,  604, 1692,  628, 596,  606, 592,  604, 570,  628, 570,  628, 572,  628, 596,  602, 596,  604, 596,  602, 596,  604, 570,  628, 596,  604, 596,  604, 570,  628, 596,  602, 596,  602, 596,  604, 594,  604, 572,  626, 572,  630, 594,  604, 570,  628, 596,  604, 594,  604, 574,  626, 570,  630, 596,  604, 596,  604, 594,  604, 596,  604, 1714,  604, 1690,  630};  // GREE
//uint8_t state[8] = {0x4C, 0x06, 0x20, 0x50, 0x01, 0x00, 0x00, 0xC0};
//制热23
uint16_t re23[139] = {8972, 4496,  630, 596,  604, 596,  604, 1690,  630, 1716,  604, 596,  602, 596,  604, 1688,  630, 572,  626, 1716,  604, 1716,  604, 1714,  602, 598,  602, 596,  602, 568,  630, 570,  630, 596,  604, 570,  628, 572,  626, 596,  604, 596,  604, 568,  630, 1690,  628, 598,  602, 596,  602, 596,  602, 596,  604, 596,  602, 598,  602, 1716,  602, 598,  602, 1690,  628, 596,  602, 598,  604, 1716,  602, 594,  606, 20010,  628, 1716,  604, 596,  602, 596,  602, 596,  602, 596,  604, 598,  602, 568,  630, 570,  630, 596,  602, 596,  600, 598,  604, 596,  602, 596,  602, 570,  630, 570,  628, 596,  602, 570,  628, 570,  628, 596,  602, 572,  628, 596,  604, 596,  604, 596,  602, 596,  602, 598,  602, 596,  604, 596,  602, 596,  604, 1716,  602, 570,  628, 1692,  628, 1690,  630};  // GREE
//uint8_t state[8] = {0x4C, 0x07, 0x20, 0x50, 0x01, 0x00, 0x00, 0xD0};
//制热24
uint16_t re24[139] = {9022, 4476,  650, 572,  606, 594,  604, 1716,  604, 1716,  628, 572,  602, 598,  624, 1692,  604, 596,  604, 598,  624, 572,  626, 574,  624, 1692,  626, 574,  628, 572,  626, 548,  652, 546,  628, 598,  602, 598,  624, 572,  626, 574,  602, 598,  626, 1692,  628, 572,  626, 546,  652, 548,  652, 572,  602, 596,  628, 572,  628, 1690,  628, 574,  600, 1718,  600, 598,  626, 572,  628, 1690,  604, 596,  630, 19986,  652, 1694,  624, 574,  628, 572,  602, 570,  630, 596,  604, 596,  628, 572,  624, 548,  650, 576,  628, 544,  656, 544,  654, 572,  626, 574,  602, 596,  626, 572,  630, 570,  628, 544,  656, 546,  626, 600,  600, 572,  652, 570,  604, 596,  602, 594,  604, 594,  628, 572,  602, 598,  624, 574,  626, 574,  602, 570,  628, 1692,  628, 1690,  630, 1692,  626};  // GREE
//uint8_t state[8] = {0x4C, 0x08, 0x20, 0x50, 0x01, 0x00, 0x00, 0xE0};
//制热25
uint16_t re25[139] = {8994, 4500,  650, 574,  626, 574,  626, 1692,  624, 1670,  628, 598,  600, 598,  600, 1720,  622, 576,  624, 1668,  652, 572,  626, 550,  648, 1694,  624, 574,  624, 576,  624, 574,  626, 576,  624, 574,  624, 578,  622, 574,  624, 576,  622, 576,  622, 1696,  624, 574,  622, 574,  624, 576,  624, 548,  650, 550,  648, 578,  624, 1692,  604, 596,  602, 1718,  624, 572,  626, 550,  650, 1694,  626, 572,  626, 19990,  626, 1718,  602, 570,  628, 574,  626, 598,  600, 572,  628, 570,  628, 598,  602, 596,  602, 598,  602, 570,  628, 570,  628, 600,  602, 596,  602, 596,  602, 572,  628, 596,  602, 596,  602, 574,  628, 568,  630, 596,  604, 594,  602, 596,  604, 596,  602, 596,  604, 596,  604, 598,  602, 594,  604, 570,  630, 1716,  602, 1716,  604, 1716,  602, 1718,  600};  // GREE
//uint8_t state[8] = {0x4C, 0x09, 0x20, 0x50, 0x01, 0x00, 0x00, 0xF0};
//制热26
uint16_t re26[139] = {8994, 4500,  652, 546,  654, 572,  602, 1716,  628, 1692,  602, 598,  602, 598,  626, 1694,  626, 546,  652, 572,  602, 1692,  652, 574,  626, 1692,  628, 574,  624, 546,  652, 546,  652, 574,  626, 572,  602, 598,  626, 572,  626, 574,  628, 572,  626, 1692,  624, 574,  628, 572,  624, 572,  626, 574,  626, 572,  628, 572,  602, 1694,  626, 572,  650, 1692,  626, 572,  628, 570,  628, 1690,  628, 548,  628, 20012,  628, 1688,  632, 596,  602, 596,  626, 574,  626, 574,  602, 598,  624, 574,  626, 572,  626, 574,  626, 572,  602, 596,  626, 572,  628, 574,  626, 574,  624, 572,  628, 546,  652, 572,  604, 594,  628, 572,  626, 572,  604, 596,  604, 594,  628, 572,  630, 544,  652, 548,  652, 574,  626, 546,  652, 572,  602, 598,  626, 572,  626, 570,  630, 546,  628};  // GREE
//uint8_t state[8] = {0x4C, 0x0A, 0x20, 0x50, 0x01, 0x00, 0x00, 0x00};
//制热27
uint16_t re27[139] = {8994, 4502,  626, 598,  600, 598,  604, 1690,  630, 1716,  602, 596,  604, 596,  602, 1716,  602, 598,  604, 1692,  626, 1716,  604, 572,  626, 1716,  604, 594,  602, 598,  600, 598,  600, 598,  602, 596,  602, 596,  604, 570,  628, 574,  628, 598,  602, 1690,  630, 596,  602, 596,  602, 596,  604, 572,  624, 574,  626, 600,  600, 1718,  600, 598,  602, 1716,  602, 596,  604, 598,  600, 1718,  604, 594,  604, 20010,  630, 1690,  630, 594,  602, 598,  604, 568,  630, 596,  602, 598,  602, 572,  628, 570,  628, 596,  602, 572,  630, 594,  604, 596,  604, 594,  604, 570,  630, 570,  628, 598,  602, 594,  606, 594,  604, 594,  604, 596,  602, 596,  602, 596,  602, 596,  606, 594,  604, 568,  630, 570,  628, 596,  602, 598,  602, 1714,  606, 568,  632, 594,  604, 594,  604};  // GREE
//uint8_t state[8] = {0x4C, 0x0B, 0x20, 0x50, 0x01, 0x00, 0x00, 0x10};
//制热28
uint16_t re28[139] = {8972, 4498,  630, 596,  604, 596,  602, 1694,  626, 1690,  632, 594,  602, 572,  628, 1716,  604, 596,  602, 574,  626, 598,  602, 1714,  602, 1718,  602, 574,  626, 594,  602, 598,  602, 596,  604, 596,  604, 596,  602, 594,  604, 596,  604, 594,  604, 1692,  626, 572,  630, 572,  626, 596,  604, 596,  602, 596,  602, 596,  604, 1716,  604, 596,  602, 1692,  628, 570,  628, 596,  604, 1690,  628, 572,  626, 20012,  628, 1690,  632, 568,  630, 570,  628, 570,  628, 596,  604, 572,  626, 572,  628, 570,  630, 594,  604, 572,  628, 570,  630, 596,  600, 574,  626, 596,  604, 596,  602, 596,  602, 570,  630, 572,  624, 598,  602, 570,  630, 570,  628, 572,  626, 598,  602, 572,  628, 570,  628, 572,  626, 598,  602, 596,  602, 598,  602, 1716,  604, 596,  604, 594,  604};  // GREE
//uint8_t state[8] = {0x4C, 0x0C, 0x20, 0x50, 0x01, 0x00, 0x00, 0x20};
//制热29
uint16_t re29[139] = {8996, 4500,  630, 596,  602, 570,  628, 1690,  630, 1716,  602, 596,  602, 598,  602, 1690,  628, 596,  602, 1718,  602, 574,  626, 1716,  602, 1716,  604, 596,  600, 598,  602, 570,  628, 596,  602, 596,  602, 598,  602, 598,  604, 594,  602, 570,  630, 1716,  602, 598,  600, 572,  628, 594,  604, 596,  602, 596,  602, 572,  630, 1716,  604, 598,  602, 1714,  604, 572,  628, 596,  602, 1718,  600, 600,  602, 20008,  628, 1718,  602, 596,  604, 598,  602, 596,  604, 596,  604, 598,  602, 596,  602, 570,  630, 596,  602, 572,  628, 598,  602, 596,  604, 594,  602, 572,  628, 568,  628, 598,  602, 596,  604, 594,  604, 598,  604, 596,  602, 596,  604, 596,  604, 596,  602, 598,  602, 594,  604, 596,  604, 596,  602, 596,  602, 1716,  602, 1716,  604, 570,  628, 572,  630};  // GREE
//uint8_t state[8] = {0x4C, 0x0D, 0x20, 0x50, 0x01, 0x00, 0x00, 0x30};
//制热30
uint16_t re30[139] = {8996, 4526,  604, 594,  604, 594,  604, 1716,  604, 1716,  602, 570,  630, 596,  604, 1716,  602, 572,  626, 596,  604, 1716,  602, 1716,  604, 1716,  602, 596,  604, 596,  602, 572,  628, 596,  604, 596,  604, 568,  630, 596,  602, 572,  630, 596,  604, 1690,  628, 596,  602, 570,  630, 596,  604, 596,  604, 594,  604, 596,  602, 1716,  604, 596,  602, 1690,  628, 598,  602, 572,  630, 1716,  604, 572,  628, 20012,  626, 1716,  604, 570,  628, 570,  628, 596,  604, 570,  628, 596,  602, 572,  630, 594,  604, 596,  604, 596,  602, 570,  628, 572,  628, 596,  602, 570,  630, 570,  630, 570,  628, 570,  626, 596,  604, 570,  628, 572,  630, 594,  604, 596,  602, 594,  604, 596,  604, 596,  604, 596,  602, 570,  630, 572,  628, 570,  630, 570,  628, 1690,  630, 594,  604};  // GREE
//uint8_t state[8] = {0x4C, 0x0E, 0x20, 0x50, 0x01, 0x00, 0x00, 0x40};


//========================================================================================================
void setup() {
 Serial.begin(115200);
 irsend.begin();
 delay(1000);
 WiFi.begin(ssid, password);
}

WiFiClient client;

void loop() {

 while (WiFi.status() != WL_CONNECTED) {//等待连接WiFi
   delay(1000);
   Serial.print(".");
 }

 // Use WiFiClient class to create TCP connections
 if (!client.connected()) {//等待连接服务器
   if (!client.connect(host, httpPort)) {
     Serial.println("connection failed");
     delay(5000);
     return;
   }
 }

 if(millis() - lastCheckInTime > postingInterval || lastCheckInTime==0) {
   checkIn();
 }
 
 // Read all the lines of the reply from server and print them to Serial
 if (client.available()) {
   String inputString = client.readStringUntil('\n');
   inputString.trim();
   Serial.println(inputString);
   int len = inputString.length()+1;
   if(inputString.startsWith("{") && inputString.endsWith("}")){    
//====================================================================================================================================
     int i=inputString.indexOf("\"C\":");
     Serial.println(i);
     if(i>5)
     {
       String rec;
       int key;
 
       rec=inputString.substring(i+5,i+7);
       Serial.println(rec);
       
       key=rec.toInt();
       
       if(rec.charAt(0)=='p')
       {
         Serial.println("打开空调");
         key=1;
       }else if(rec.charAt(0)=='s')
       {
         Serial.println("关闭空调");
         key=0;
       }
       switch(key)
       {
         case 0:
           Serial.println("关机");
          irsend.sendRaw(guanJi, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 1:
           Serial.println("开机");
           irsend.sendRaw(kaiJi, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 2:
           Serial.println("冷16");
           irsend.sendRaw(leng16, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 3:
           Serial.println("冷17");
           irsend.sendRaw(leng17, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 4:
           Serial.println("冷18");
           irsend.sendRaw(leng18, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 5:
           Serial.println("冷19");
           irsend.sendRaw(leng19, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 6:
           Serial.println("冷20");
           irsend.sendRaw(leng20, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 7:
           Serial.println("冷21");
           irsend.sendRaw(leng21, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 8:
           Serial.println("冷22");
           irsend.sendRaw(leng22, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 9:
           Serial.println("冷23");
           irsend.sendRaw(leng23, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 10:
           Serial.println("leng24");
           irsend.sendRaw(leng24, 139, 38);  // Send a raw data capture at 38kHz.
           break;   
         case 11:
           Serial.println("冷25");
           irsend.sendRaw(leng25, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 12:
           Serial.println("冷26");
           irsend.sendRaw(leng26, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 13:
           Serial.println("冷27");
           irsend.sendRaw(leng27, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 14:
           Serial.println("冷28");
           irsend.sendRaw(leng28, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 15:
           Serial.println("冷29");
           irsend.sendRaw(leng29, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 16:
           Serial.println("冷30");
          irsend.sendRaw(leng30, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 17:
           Serial.println("热16");
           irsend.sendRaw(re16, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 18:
           Serial.println("热17");
           irsend.sendRaw(re17, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 19:
           Serial.println("热18");
           irsend.sendRaw(re18, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 20:
           Serial.println("热19");
           irsend.sendRaw(re19, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 21:
           Serial.println("热20");
           irsend.sendRaw(re20, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 22:
           Serial.println("热21");
           irsend.sendRaw(re21, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 23:
           Serial.println("热22");
           irsend.sendRaw(re22, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 24:
           Serial.println("热23");
           irsend.sendRaw(re23, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 25:
           Serial.println("热24");
           irsend.sendRaw(re24, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 26:
           Serial.println("热25");
           irsend.sendRaw(re25, 139, 38);  // Send a raw data capture at 38kHz.
           break;   
         case 27:
           Serial.println("热26");
           irsend.sendRaw(re26, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 28:
           Serial.println("热27");
           irsend.sendRaw(re27, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 29:
           Serial.println("热28");
           irsend.sendRaw(re28, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 30:
           Serial.println("热29");
           irsend.sendRaw(re29, 139, 38);  // Send a raw data capture at 38kHz.
           break;
         case 31:
           Serial.println("热30");
           irsend.sendRaw(re30, 139, 38);  // Send a raw data capture at 38kHz.
           break;









                    
                 
       }
     }

//========================================================================================================================/
   }
 }
}

void checkIn() {
   byte temperature = 0;
   byte humidity = 0;
   int err = SimpleDHTErrSuccess;
   if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
     Serial.print("Read DHT11 failed, err="); 
      String msg1 = "{\"M\":\"say\",\"ID\":\"U1673\",\"C\":\"readDHT11_err\",\"SIGN\":\" hongWai\"}\n";
      client.print(msg1);
   }else
   {   

     Serial.print("Sample OK: ");
     Serial.print((int)temperature); Serial.print(" *C, "); 
     Serial.print((int)humidity); Serial.println(" H");
     String msg1 = "{\"M\":\"update\",\"ID\":\"8281\",\"V\":{\"1983\":\""+String((int)temperature)+"\",\"1985\":\""+String((int)humidity)+"\"}}\n";
      client.print(msg1);
   }
   String msg = "{\"M\":\"checkin\",\"ID\":\"" + DEVICEID + "\",\"K\":\"" + APIKEY + "\"}\n";
   
   client.print(msg);
   
  //
   lastCheckInTime = millis(); 
}

void sayToClient(String client_id, String content){
 String msg = "{\"M\":\"say\",\"ID\":\"" + client_id + "\",\"C\":\"" + content + "\"}\n";
 client.print(msg);
 lastCheckInTime = millis();
}

你可能感兴趣的:(物联网红外遥控器)