本帖最后由 myself1820 于 2021-3-21 18:47 编辑
程序来了
#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <Blinker.h>
#include <OneWire.h>
#include <DallasTemperature.h>
BlinkerNumber TEMP("temp"); //定义温度数据键名
// 初始连接在单总线上的单总线设备
#define ONE_WIRE_BUS 0 //GPIO0,接DS18B20
float temp_read;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
uint32_t read_time = 0;
char auth[] = "1111";//这里面填写设备的密钥
char ssid[] = "2222";//这里填写你的wifi名字
char pswd[] = "3333";//这里填写你的WiFi密码
//定义红外发射的管脚
const uint16_t kIrLed = 3; // GPIO3(RX)接红外发光二极管
IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
/*美的空调红外键值读取*/
//空调开:26度,环保
uint16_t power_on[199] = {4470, 4400, 592, 1592, 594, 500, 592, 1590, 592, 1592, 592, 500, 592, 500, 592, 1592, 594, 500, 592, 500, 592, 1592, 592, 500, 592, 500, 592, 1592, 594, 1590, 592, 500, 590, 1592, 592, 1592, 592, 500, 590, 1592, 592, 1594, 592, 1592, 592, 1592, 592, 1592, 594, 1590, 592, 500, 592, 1592, 592, 500, 590, 500, 592, 500, 592, 500, 590, 500, 592, 502, 590, 1592, 592, 1592, 592, 500, 588, 1596, 592, 502, 590, 500, 568, 524, 592, 500, 590, 502, 590, 502, 586, 1596, 592, 500, 590, 1592, 568, 1616, 592, 1592, 568, 1616, 592, 5234, 4494, 4402, 592, 1592, 592, 500, 590, 1592, 592, 1592, 592, 502, 590, 500, 592, 1592, 592, 500, 590, 502, 590, 1592, 592, 500, 590, 502, 592, 1592, 592, 1592, 592, 502, 590, 1592, 592, 1592, 592, 502, 590, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 590, 1594, 590, 502, 590, 1592, 592, 502, 590, 502, 590, 502, 590, 502, 590, 502, 588, 502, 590, 1594, 590, 1594, 592, 500, 590, 1592, 592, 502, 590, 502, 590, 502, 590, 502, 590, 502, 588, 502, 590, 1594, 590, 502, 590, 1594, 590, 1594, 590, 1594, 590, 1594, 590}; // UNKNOWN 1C03CDD8
//空调关
uint16_t power_off[199] = {4392, 4478, 514, 1664, 520, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 1670, 514, 580, 510, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 1672, 512, 580, 512, 1670, 514, 580, 510, 1672, 548, 1636, 512, 1670, 514, 1672, 514, 580, 512, 1670, 514, 1672, 512, 1670, 514, 580, 512, 580, 510, 580, 512, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 1670, 514, 580, 512, 580, 512, 580, 510, 580, 512, 576, 516, 580, 512, 580, 512, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1672, 512, 1672, 512, 5314, 4414, 4480, 514, 1670, 514, 580, 510, 1670, 514, 1672, 514, 580, 510, 580, 512, 1670, 514, 580, 510, 580, 512, 1670, 514, 582, 510, 580, 510, 1670, 514, 1672, 514, 580, 512, 1670, 514, 580, 510, 1672, 512, 1672, 514, 1672, 512, 1670, 514, 580, 512, 1670, 512, 1670, 514, 1672, 512, 582, 510, 582, 510, 580, 510, 582, 510, 1670, 514, 582, 510, 582, 510, 1670, 514, 1670, 514, 1670, 514, 580, 510, 580, 510, 582, 510, 580, 510, 582, 510, 582, 510, 582, 510, 582, 510, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514}; // COOLIX B27BE0
//自动模式
uint16_t Mode_Auto[199] = {4390, 4478, 514, 1672, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 578, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 1670, 514, 580, 512, 580, 512, 580, 512, 1670, 514, 1670, 514, 1664, 660, 1528, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 580, 510, 580, 512, 580, 512, 580, 512, 580, 512, 1670, 514, 1672, 512, 580, 512, 1670, 514, 1670, 514, 580, 510, 582, 510, 582, 510, 580, 512, 580, 512, 1670, 514, 580, 510, 580, 512, 1670, 514, 1670, 514, 1670, 514, 5312, 4416, 4480, 512, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 510, 1670, 514, 580, 510, 580, 512, 1670, 514, 580, 510, 582, 510, 1670, 514, 1670, 514, 582, 510, 1672, 512, 580, 512, 580, 510, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1664, 512, 1678, 514, 582, 510, 580, 510, 580, 512, 580, 510, 582, 510, 1670, 514, 1670, 514, 582, 538, 1644, 512, 1670, 540, 554, 538, 554, 538, 552, 540, 552, 540, 552, 538, 1644, 540, 552, 540, 552, 540, 1642, 542, 1642, 542, 1642, 542};
//制冷
uint16_t Mode_Cool[199] = {4470, 4400, 594, 1590, 594, 498, 594, 1590, 594, 1590, 594, 498, 592, 500, 592, 1590, 594, 498, 594, 498, 594, 1590, 594, 500, 592, 498, 594, 1590, 594, 1590, 594, 498, 592, 1590, 594, 1592, 594, 498, 592, 1590, 594, 1590, 594, 1590, 592, 1592, 594, 1590, 594, 1590, 594, 500, 592, 1592, 594, 498, 592, 500, 592, 500, 592, 498, 592, 500, 592, 500, 590, 1592, 592, 1592, 594, 498, 594, 1590, 592, 500, 592, 500, 590, 500, 592, 500, 592, 500, 592, 500, 592, 1590, 594, 500, 592, 1590, 594, 1590, 594, 1592, 592, 1592, 592, 5234, 4496, 4400, 594, 1590, 592, 500, 590, 1592, 592, 1592, 592, 500, 592, 500, 592, 1592, 592, 500, 592, 500, 594, 1590, 594, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 592, 1592, 592, 1590, 592, 1592, 592, 1592, 592, 500, 592, 1592, 594, 500, 592, 500, 590, 500, 592, 500, 568, 524, 588, 504, 592, 1592, 568, 1616, 592, 500, 592, 1592, 568, 524, 590, 502, 590, 502, 568, 524, 590, 502, 568, 526, 566, 1616, 592, 500, 590, 1592, 592, 1592, 592, 1592, 592, 1592, 592};
//制热
uint16_t Mode_Heat[199] = {4434, 4436, 558, 1626, 558, 536, 512, 1670, 558, 1626, 558, 532, 584, 514, 510, 1670, 558, 536, 512, 580, 510, 1670, 558, 536, 510, 582, 510, 1670, 558, 1626, 558, 538, 512, 1670, 550, 1634, 556, 538, 510, 1670, 558, 1626, 514, 1670, 514, 1670, 514, 1670, 556, 1628, 514, 580, 510, 1670, 514, 582, 510, 580, 510, 582, 510, 580, 510, 582, 510, 580, 510, 1672, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 1670, 636, 458, 510, 582, 510, 584, 508, 582, 510, 1670, 514, 580, 510, 580, 510, 582, 510, 1670, 514, 1672, 512, 5306, 4422, 4480, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 582, 510, 580, 510, 1670, 514, 580, 510, 580, 512, 1672, 512, 574, 508, 588, 512, 1670, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1672, 512, 1672, 512, 1672, 514, 582, 510, 1670, 514, 582, 510, 580, 512, 580, 510, 580, 536, 556, 536, 556, 536, 1644, 514, 1670, 540, 556, 538, 1644, 540, 1646, 540, 1644, 540, 554, 538, 554, 538, 554, 538, 552, 538, 1644, 540, 554, 538, 554, 538, 552, 538, 1644, 542, 1644, 540};
//除湿
uint16_t Mode_Dry[199] = {4468, 4402, 568, 1616, 590, 502, 582, 1602, 568, 1616, 568, 524, 568, 524, 568, 1616, 568, 524, 568, 524, 568, 1616, 568, 524, 568, 524, 568, 1616, 568, 1616, 568, 524, 566, 1618, 566, 524, 568, 524, 566, 524, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 524, 566, 524, 568, 524, 568, 524, 568, 524, 568, 1616, 568, 1616, 568, 524, 568, 1616, 568, 524, 566, 1616, 568, 526, 566, 524, 590, 502, 566, 524, 590, 1592, 568, 524, 590, 1594, 568, 524, 592, 1592, 592, 1592, 592, 5234, 4494, 4402, 592, 1592, 592, 500, 590, 1592, 592, 1592, 592, 502, 590, 502, 590, 1592, 592, 502, 590, 500, 590, 1592, 592, 502, 590, 502, 590, 1592, 592, 1592, 590, 502, 590, 1594, 592, 502, 590, 502, 590, 500, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 500, 590, 502, 590, 500, 592, 500, 592, 500, 590, 1592, 592, 1592, 592, 500, 592, 1592, 592, 500, 592, 1592, 592, 500, 590, 502, 592, 498, 592, 500, 592, 1592, 592, 502, 590, 1592, 592, 500, 590, 1592, 592, 1592, 592};
//送风
uint16_t Mode_Wind[199] = {4434, 4436, 558, 1626, 558, 536, 512, 1670, 558, 1626, 558, 532, 584, 514, 510, 1670, 558, 536, 512, 580, 510, 1670, 558, 536, 510, 582, 510, 1670, 558, 1626, 558, 538, 512, 1670, 550, 1634, 556, 538, 510, 1670, 558, 1626, 514, 1670, 514, 1670, 514, 1670, 556, 1628, 514, 580, 510, 1670, 514, 582, 510, 580, 510, 582, 510, 580, 510, 582, 510, 580, 510, 1672, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 1670, 636, 458, 510, 582, 510, 584, 508, 582, 510, 1670, 514, 580, 510, 580, 510, 582, 510, 1670, 514, 1672, 512, 5306, 4422, 4480, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 582, 510, 580, 510, 1670, 514, 580, 510, 580, 512, 1672, 512, 574, 508, 588, 512, 1670, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1672, 512, 1672, 512, 1672, 514, 582, 510, 1670, 514, 582, 510, 580, 512, 580, 510, 580, 536, 556, 536, 556, 536, 1644, 514, 1670, 540, 556, 538, 1644, 540, 1646, 540, 1644, 540, 554, 538, 554, 538, 554, 538, 552, 538, 1644, 540, 554, 538, 554, 538, 552, 538, 1644, 542, 1644, 540};
//静音风速
uint16_t fan_Fixed[199] = {4458, 4412, 584, 1600, 560, 534, 556, 1624, 560, 1624, 560, 534, 556, 536, 556, 1626, 560, 536, 556, 536, 556, 1626, 560, 534, 556, 536, 556, 1626, 560, 1626, 558, 536, 556, 1626, 560, 1624, 560, 1624, 560, 1626, 558, 1624, 560, 1624, 560, 1626, 558, 1626, 558, 1626, 558, 538, 554, 538, 554, 538, 512, 580, 510, 582, 510, 582, 510, 580, 510, 580, 512, 1670, 560, 1624, 558, 538, 510, 1670, 558, 538, 510, 582, 510, 582, 510, 580, 510, 582, 510, 580, 510, 1670, 558, 538, 512, 1672, 512, 1670, 514, 1670, 514, 1670, 514, 5312, 4416, 4480, 514, 1672, 512, 582, 510, 1670, 514, 1670, 514, 580, 510, 582, 510, 1670, 514, 582, 510, 580, 510, 1670, 514, 582, 510, 582, 510, 1670, 514, 1670, 514, 582, 510, 1670, 514, 1670, 514, 1672, 512, 1672, 514, 1670, 514, 1670, 514, 1670, 514, 1672, 514, 1670, 514, 580, 510, 582, 510, 580, 510, 582, 512, 580, 510, 580, 510, 576, 516, 582, 510, 1670, 514, 1670, 514, 580, 510, 1670, 514, 580, 510, 582, 510, 582, 510, 580, 510, 582, 510, 580, 510, 1672, 514, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1670, 514};
//低风速
uint16_t fan_Min[199] = {4470, 4400, 594, 1592, 594, 498, 592, 1590, 594, 1590, 594, 498, 592, 500, 592, 1590, 594, 500, 592, 498, 592, 1592, 592, 500, 592, 498, 592, 1592, 594, 1590, 594, 498, 592, 1592, 594, 1590, 594, 500, 592, 500, 592, 1590, 594, 1592, 594, 1590, 594, 1590, 594, 1590, 594, 500, 592, 1592, 594, 1590, 594, 500, 592, 500, 592, 498, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1590, 592, 500, 592, 502, 590, 500, 592, 500, 592, 500, 592, 500, 590, 1592, 592, 500, 592, 1580, 604, 1592, 592, 1592, 592, 1592, 592, 5234, 4496, 4400, 594, 1590, 594, 500, 592, 1592, 592, 1592, 592, 500, 592, 500, 592, 1592, 592, 500, 592, 500, 590, 1592, 594, 500, 592, 500, 592, 1592, 592, 1592, 568, 524, 590, 1592, 592, 1592, 592, 500, 568, 524, 568, 1616, 590, 1594, 592, 1592, 592, 1592, 590, 1596, 592, 500, 568, 1616, 590, 1594, 592, 500, 588, 504, 590, 500, 592, 502, 590, 500, 592, 1592, 592, 1592, 592, 500, 590, 1592, 592, 502, 590, 500, 592, 500, 592, 500, 592, 502, 590, 500, 590, 1592, 592, 502, 590, 1592, 592, 1592, 592, 1592, 592, 1592, 592};
//中风速
uint16_t fan_Med[201] = {4390, 4480, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 1670, 514, 578, 512, 580, 512, 1670, 514, 580, 512, 578, 514, 1670, 514, 1670, 514, 580, 512, 1670, 514, 580, 512, 1670, 514, 580, 512, 1670, 514, 1672, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 580, 512, 1672, 514, 580, 512, 580, 512, 580, 514, 578, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 1672, 514, 580, 512, 580, 512, 580, 512, 580, 512, 580, 512, 578, 512, 1672, 514, 578, 512, 1670, 514, 1672, 514, 1670, 514, 1670, 514, 5314, 4414, 1152, 474, 2854, 514, 1672, 512, 580, 536, 1646, 514, 1670, 540, 554, 540, 550, 542, 1642, 542, 550, 542, 550, 542, 1642, 542, 550, 542, 550, 542, 1642, 542, 1642, 544, 550, 542, 1642, 542, 552, 564, 1618, 566, 528, 566, 1618, 566, 1618, 566, 1618, 568, 1616, 568, 1618, 568, 1616, 568, 526, 566, 1616, 568, 524, 568, 524, 590, 500, 592, 502, 590, 502, 592, 1592, 592, 1592, 592, 502, 590, 1592, 592, 502, 590, 500, 590, 502, 590, 502, 590, 502, 590, 502, 590, 1592, 592, 502, 590, 1594, 592, 1592, 592, 1592, 590, 1594, 592};
//高风速
uint16_t fan_Max[199] = {4470, 4400, 592, 1592, 592, 500, 592, 1592, 592, 1592, 594, 500, 592, 500, 592, 1592, 568, 524, 592, 500, 592, 1590, 568, 526, 590, 500, 590, 1592, 568, 1616, 568, 524, 570, 1614, 568, 524, 568, 524, 566, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1616, 568, 1608, 618, 1574, 568, 524, 568, 524, 568, 524, 568, 524, 568, 526, 566, 526, 590, 1592, 568, 1616, 568, 524, 586, 1598, 568, 524, 566, 524, 592, 500, 590, 502, 590, 500, 590, 502, 588, 1594, 592, 500, 592, 1592, 592, 1594, 592, 1592, 592, 1594, 592, 5234, 4494, 4402, 592, 1592, 592, 502, 590, 1592, 592, 1592, 592, 502, 590, 500, 592, 1592, 568, 524, 592, 500, 590, 1592, 592, 500, 590, 500, 588, 1596, 592, 1592, 568, 524, 590, 1592, 592, 502, 590, 500, 590, 1592, 568, 1616, 592, 1594, 590, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 500, 592, 500, 590, 502, 590, 500, 592, 500, 592, 492, 592, 1598, 592, 1592, 592, 500, 590, 1592, 592, 500, 590, 500, 592, 500, 590, 502, 590, 500, 592, 500, 590, 1592, 592, 502, 590, 1592, 592, 1592, 592, 1592, 592, 1592, 592};
//自动风速
uint16_t fan_Auto[199] = {4460, 4410, 594, 1590, 594, 498, 594, 1590, 594, 1590, 594, 498, 594, 498, 592, 1590, 594, 500, 592, 500, 592, 1590, 594, 498, 594, 498, 594, 1590, 594, 1590, 594, 498, 592, 1592, 592, 1590, 594, 498, 592, 1590, 594, 1590, 594, 1592, 594, 1590, 594, 1590, 594, 1590, 594, 500, 592, 1590, 594, 500, 592, 500, 592, 500, 592, 500, 592, 498, 592, 500, 592, 1590, 594, 1590, 594, 500, 592, 1590, 594, 500, 592, 498, 592, 500, 592, 500, 590, 500, 592, 500, 592, 1590, 594, 498, 592, 1592, 594, 1590, 594, 1590, 594, 1592, 592, 5234, 4494, 4402, 594, 1590, 594, 500, 592, 1584, 600, 1590, 594, 500, 592, 500, 592, 1592, 592, 500, 590, 502, 590, 1592, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1594, 592, 1592, 592, 500, 568, 1616, 592, 500, 590, 500, 592, 500, 592, 502, 590, 500, 568, 524, 592, 1592, 594, 1592, 592, 500, 588, 1596, 592, 500, 592, 500, 590, 500, 592, 500, 568, 524, 568, 524, 566, 1616, 592, 500, 590, 1592, 592, 1594, 592, 1592, 592, 1592, 592};
//制冷20度
uint16_t temp_20[199] = {4458, 4412, 558, 1626, 558, 534, 558, 1624, 560, 1626, 584, 508, 582, 510, 558, 1624, 560, 534, 558, 534, 582, 1602, 584, 508, 580, 512, 558, 1626, 582, 1602, 582, 510, 558, 1626, 558, 1626, 584, 510, 558, 534, 558, 1624, 558, 1626, 582, 1602, 582, 1602, 558, 1626, 558, 534, 558, 1626, 558, 1626, 558, 534, 558, 534, 558, 534, 556, 536, 604, 478, 592, 508, 582, 510, 558, 1626, 558, 534, 558, 1626, 558, 1626, 558, 534, 558, 534, 580, 1602, 560, 1626, 580, 512, 558, 1626, 558, 536, 580, 510, 556, 1626, 558, 1626, 558, 5268, 4460, 4436, 558, 1626, 582, 510, 558, 1626, 558, 1626, 558, 534, 558, 534, 580, 1604, 558, 534, 556, 536, 556, 1626, 558, 534, 556, 536, 558, 1626, 558, 1626, 558, 536, 556, 1626, 558, 1626, 582, 512, 556, 530, 562, 1626, 558, 1626, 558, 1626, 558, 1626, 558, 1626, 558, 534, 556, 1626, 558, 1626, 558, 534, 558, 534, 556, 534, 554, 538, 556, 536, 556, 534, 558, 534, 558, 1626, 558, 534, 556, 1626, 558, 1618, 566, 536, 556, 534, 582, 1602, 558, 1626, 558, 534, 556, 1626, 558, 538, 554, 536, 556, 1628, 558, 1626, 558};
//制冷21度
uint16_t temp_21[199] = {4390, 4480, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 510, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 582, 580, 510, 512, 1670, 514, 1670, 514, 580, 512, 1672, 514, 1670, 514, 580, 510, 582, 510, 1670, 514, 1670, 514, 1668, 516, 1670, 514, 1666, 552, 550, 508, 1670, 514, 1670, 514, 580, 512, 580, 512, 580, 510, 580, 512, 580, 510, 580, 512, 1670, 514, 1672, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 1672, 512, 582, 510, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 5312, 4416, 4478, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 510, 1672, 512, 580, 512, 580, 538, 1644, 514, 580, 540, 552, 540, 1642, 540, 1644, 542, 552, 540, 1642, 542, 1642, 542, 552, 540, 552, 540, 1642, 542, 1642, 542, 1642, 542, 1642, 542, 1642, 542, 552, 540, 1642, 542, 1642, 542, 552, 564, 528, 564, 522, 506, 592, 562, 528, 564, 526, 566, 1618, 566, 1618, 566, 528, 564, 1618, 566, 1618, 566, 528, 564, 528, 564, 1618, 566, 528, 564, 526, 566, 1616, 568, 526, 564, 528, 564, 1618, 566, 1618, 566};
//制冷22度
uint16_t temp_22[199] = {4434, 4436, 558, 1626, 556, 538, 512, 1670, 558, 1628, 544, 550, 512, 580, 512, 1670, 558, 536, 512, 580, 512, 1670, 514, 580, 510, 580, 512, 1670, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 1672, 514, 1670, 514, 1670, 514, 574, 578, 1610, 514, 1670, 514, 580, 510, 580, 512, 580, 512, 580, 512, 580, 512, 580, 512, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 580, 512, 580, 512, 1670, 514, 580, 512, 580, 510, 582, 510, 580, 512, 580, 512, 1670, 514, 1670, 514, 5312, 4416, 4480, 514, 1670, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 510, 1672, 512, 582, 510, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 510, 1672, 514, 1670, 514, 1670, 514, 1672, 512, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 580, 512, 580, 512, 572, 508, 590, 512, 1670, 514, 1670, 514, 1670, 514, 1670, 514, 1670, 542, 552, 540, 552, 540, 1642, 542, 552, 540, 552, 540, 550, 540, 552, 540, 552, 540, 1642, 542, 1642, 542};
//制冷23度
uint16_t temp_23[199] = {4390, 4480, 514, 1670, 514, 578, 512, 1672, 512, 1672, 514, 580, 512, 580, 512, 1670, 514, 580, 512, 578, 512, 1670, 514, 580, 512, 580, 512, 1672, 512, 1670, 514, 580, 512, 1670, 514, 1670, 514, 578, 512, 580, 576, 1606, 554, 1630, 514, 1670, 514, 1672, 512, 1670, 514, 580, 512, 1672, 554, 1630, 558, 536, 556, 536, 512, 580, 510, 580, 514, 578, 512, 580, 512, 1670, 558, 536, 512, 1670, 514, 1670, 514, 1670, 514, 580, 512, 580, 512, 1672, 512, 580, 550, 1634, 514, 580, 512, 578, 512, 580, 512, 1670, 514, 1670, 514, 5312, 4416, 4480, 514, 1670, 514, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 1670, 514, 580, 512, 578, 512, 1672, 512, 582, 512, 580, 512, 1670, 514, 1670, 514, 580, 540, 1642, 512, 1672, 514, 580, 542, 550, 542, 1640, 542, 1636, 518, 1670, 544, 1642, 506, 1678, 542, 550, 566, 1616, 544, 1642, 542, 550, 566, 526, 566, 524, 568, 524, 566, 526, 566, 524, 568, 1616, 542, 550, 566, 1616, 510, 1674, 568, 1616, 568, 526, 568, 524, 568, 1616, 568, 526, 590, 1594, 568, 524, 590, 502, 590, 500, 590, 1594, 566, 1618, 536};
//制冷24度
uint16_t temp_24[199] = {4472, 4398, 594, 1590, 594, 498, 594, 1590, 594, 1590, 594, 498, 594, 498, 594, 1590, 594, 500, 592, 498, 592, 1590, 594, 498, 592, 498, 594, 1590, 594, 1590, 594, 500, 592, 1590, 594, 1590, 594, 498, 594, 498, 592, 1590, 594, 1590, 594, 1590, 594, 1592, 594, 1590, 594, 498, 592, 1590, 594, 1590, 594, 498, 592, 500, 592, 500, 592, 500, 592, 500, 592, 500, 592, 1590, 594, 500, 592, 500, 592, 1592, 594, 1590, 594, 498, 592, 500, 592, 1590, 594, 500, 592, 1592, 594, 1590, 594, 500, 592, 500, 592, 1590, 594, 1592, 592, 5234, 4494, 4402, 592, 1592, 592, 500, 592, 1584, 588, 1604, 592, 500, 592, 500, 592, 1592, 592, 500, 592, 500, 592, 1590, 594, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 594, 500, 590, 500, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 1592, 592, 500, 590, 1592, 592, 1594, 590, 500, 592, 500, 592, 500, 590, 500, 590, 502, 592, 500, 592, 1590, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 590, 500, 592, 1592, 592, 500, 590, 1592, 592, 1592, 592, 500, 590, 502, 590, 1592, 590, 1594, 592};
//制冷25度
uint16_t temp_25[199] = {4390, 4480, 512, 1672, 514, 580, 512, 1670, 514, 1672, 514, 578, 512, 580, 512, 1670, 514, 580, 512, 580, 512, 1670, 514, 580, 512, 580, 512, 1672, 514, 1670, 514, 580, 512, 1672, 514, 1672, 512, 580, 512, 580, 512, 1670, 514, 1670, 514, 1672, 512, 1672, 514, 1670, 514, 580, 534, 1648, 536, 1648, 536, 556, 512, 580, 536, 556, 536, 554, 536, 556, 536, 1646, 538, 1648, 536, 556, 536, 556, 536, 1646, 540, 1646, 538, 554, 536, 554, 538, 554, 538, 554, 538, 1646, 540, 1644, 540, 554, 538, 554, 538, 1646, 538, 1646, 540, 5286, 4442, 4454, 564, 1622, 540, 552, 538, 1644, 540, 1644, 540, 552, 562, 530, 562, 1620, 564, 530, 538, 552, 562, 1620, 564, 530, 564, 528, 564, 1620, 564, 1620, 564, 528, 564, 1620, 564, 1620, 566, 528, 564, 526, 564, 1620, 564, 1620, 564, 1620, 564, 1620, 566, 1618, 566, 528, 564, 1618, 566, 1618, 566, 528, 588, 504, 564, 528, 564, 528, 564, 526, 564, 1620, 588, 1596, 564, 528, 564, 528, 564, 1620, 566, 1618, 588, 504, 564, 528, 564, 528, 564, 528, 560, 1622, 566, 1620, 588, 504, 586, 506, 588, 1596, 588, 1596, 566};
//制冷26度
uint16_t temp_26[199] = {4470, 4400, 594, 1592, 594, 498, 592, 1590, 594, 1590, 594, 498, 592, 500, 592, 1590, 594, 498, 592, 500, 592, 1590, 594, 500, 592, 456, 624, 1604, 592, 1592, 594, 498, 592, 1590, 594, 1592, 592, 500, 592, 500, 592, 1592, 594, 1590, 594, 1590, 594, 1590, 594, 1592, 592, 500, 592, 1592, 592, 1592, 592, 500, 592, 500, 592, 500, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 502, 590, 1592, 592, 1592, 594, 1590, 592, 502, 592, 498, 592, 500, 592, 500, 592, 1590, 592, 500, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 5234, 4496, 4400, 592, 1592, 592, 500, 562, 1622, 592, 1592, 592, 500, 590, 502, 590, 1592, 592, 500, 590, 502, 592, 1592, 592, 500, 592, 500, 592, 1592, 592, 1592, 592, 500, 590, 1594, 582, 1534, 648, 512, 590, 502, 588, 1594, 590, 1594, 592, 1592, 592, 1592, 592, 1592, 592, 500, 590, 1592, 592, 1490, 694, 494, 598, 500, 590, 502, 590, 500, 590, 500, 592, 1592, 592, 1592, 592, 500, 592, 1592, 592, 1592, 592, 1592, 592, 500, 590, 502, 560, 532, 590, 494, 598, 1594, 590, 502, 590, 502, 590, 500, 590, 1592, 592, 1592, 592};
//制冷27度
uint16_t temp_27[199] = {4440, 4350, 644, 1622, 562, 532, 560, 1622, 562, 1622, 562, 530, 562, 530, 560, 1622, 562, 530, 560, 532, 562, 1620, 564, 530, 560, 532, 560, 1622, 562, 1622, 562, 532, 560, 1622, 562, 1622, 562, 532, 560, 532, 560, 1622, 562, 1622, 562, 1624, 560, 1624, 560, 1624, 560, 532, 534, 1648, 560, 1624, 560, 534, 512, 580, 530, 562, 512, 580, 512, 580, 512, 1670, 558, 536, 512, 580, 512, 1672, 512, 1670, 514, 1670, 514, 580, 510, 580, 512, 580, 512, 1670, 514, 1670, 514, 580, 512, 580, 512, 580, 512, 1670, 514, 1672, 512, 5312, 4416, 4482, 512, 1670, 514, 580, 512, 1670, 514, 1672, 512, 580, 512, 574, 506, 1682, 514, 580, 510, 582, 510, 1670, 514, 580, 512, 580, 512, 1670, 514, 1670, 514, 582, 510, 1672, 512, 1672, 512, 580, 512, 580, 512, 1670, 514, 1670, 514, 1590, 594, 1670, 514, 1672, 512, 582, 510, 1670, 514, 1670, 514, 580, 510, 580, 512, 582, 510, 580, 512, 580, 512, 1670, 514, 580, 510, 582, 510, 1670, 514, 1670, 514, 1670, 514, 582, 510, 582, 510, 582, 510, 1670, 512, 1670, 514, 580, 510, 580, 536, 556, 536, 1648, 536, 1644, 542};
//制冷28度
uint16_t temp_28[199] = {4470, 4400, 594, 1590, 594, 498, 594, 1590, 594, 1590, 594, 500, 592, 500, 592, 1590, 594, 498, 592, 498, 592, 1590, 594, 500, 592, 498, 594, 1590, 594, 1590, 594, 498, 592, 1592, 594, 1590, 594, 498, 592, 500, 592, 1590, 594, 1590, 594, 1590, 594, 1590, 592, 1592, 594, 498, 592, 1590, 594, 1592, 594, 500, 592, 500, 582, 502, 600, 498, 592, 500, 592, 1592, 594, 500, 592, 500, 592, 500, 592, 1592, 594, 1590, 594, 500, 592, 500, 592, 500, 592, 1592, 592, 1592, 594, 1590, 594, 500, 592, 500, 592, 1592, 592, 1592, 592, 5234, 4494, 4402, 592, 1592, 592, 500, 592, 1592, 592, 1592, 594, 500, 590, 500, 592, 1590, 594, 500, 592, 500, 592, 1592, 592, 500, 592, 500, 592, 1592, 592, 1592, 594, 500, 592, 1592, 594, 1590, 594, 500, 590, 500, 592, 1592, 592, 1592, 592, 1592, 590, 1594, 592, 1550, 634, 500, 592, 1592, 592, 1592, 568, 524, 568, 524, 590, 500, 592, 500, 592, 500, 566, 1616, 592, 500, 592, 500, 590, 500, 592, 1592, 592, 1592, 588, 504, 586, 506, 590, 500, 592, 1592, 592, 1592, 592, 1592, 592, 502, 590, 500, 590, 1592, 594, 1590, 592};
// 新建Blinker组件对象
BlinkerButton Button1("btn-pwron");//空调开
BlinkerButton Button2("btn-pwroff");//空调关
BlinkerButton Button3("btn-auto");//自动模式
BlinkerButton Button4("btn-cool");//制冷模式
BlinkerButton Button5("btn-heat");//制热模式
BlinkerButton Button6("btn-dry");//除湿模式
BlinkerButton Button7("btn-wind");//送风模式
BlinkerSlider Slider1("ran-coolTemp");//制冷温度
BlinkerSlider Slider2("ran-fan");//空调风速
void setup()
{
//初始化串口
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
//注册回调函数/
Button1.attach(Button1_callback);
Button2.attach(Button2_callback);
Button3.attach(Button3_callback);
Button4.attach(Button4_callback);
Button5.attach(Button5_callback);
Button6.attach(Button6_callback);
Button7.attach(Button7_callback);
Slider1.attach(slider1_callback);
Slider2.attach(slider2_callback);
//配网步骤:WIFI接入
Blinker.begin(auth,ssid,pswd);
//红外初始化
irsend.begin();
Blinker.attachData(dataRead);
Blinker.attachHeartbeat(heartbeat);
DS18B20.begin();
temp_read=0.0;
}
void loop()
{
Blinker.run();
DS18B20.requestTemperatures(); //发送命令获取温度
if (read_time == 0 || (millis() - read_time) >= 2000)
{
read_time = millis();
float t = DS18B20.getTempCByIndex(0);
temp_read = t-6.1; //修正温度值
BLINKER_LOG("Temperature: ", t, " *C");
}
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void heartbeat()
{
TEMP.print(temp_read); //给blinkerapp回传温度数据
}
//回调函数
void Button1_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到普通按钮按下(btn-pwron)
if (state == BLINKER_CMD_BUTTON_TAP)
{
//发送红外指令
irsend.sendRaw(power_on, 199, 38); // Send a raw data capture at 38kHz.
Button1.print("空调开");
}
}
//回调函数
void Button2_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(power_off, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("空调关");
}
}
//回调函数
void Button3_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(Mode_Auto, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("自动模式");
}
}
void Button4_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(Mode_Cool, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷模式");
}
}
void Button5_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(Mode_Heat, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制热模式");
}
}
void Button6_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(Mode_Dry, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("除湿模式");
}
}
void Button7_callback(const String &state)
{
BLINKER_LOG("get button state: ", state);
//检测到btn-pwroff按钮按下
if (state == BLINKER_CMD_BUTTON_TAP)
{
irsend.sendRaw(Mode_Wind, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("送风模式");
}
}
void slider1_callback(int32_t value)
{
BLINKER_LOG("get slider value: ", value);
int num_temp=value;
switch (num_temp)
{
case 20:
irsend.sendRaw(temp_20, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷20度");
break;
case 21:
irsend.sendRaw(temp_21, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷21度");
break;
case 22:
irsend.sendRaw(temp_22, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷22度");
break;
case 23:
irsend.sendRaw(temp_23, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷23度");
break;
case 24:
irsend.sendRaw(temp_24, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷24度");
break;
case 25:
irsend.sendRaw(temp_25, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷25度");
break;
case 26:
irsend.sendRaw(temp_26, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷26度");
break;
case 27:
irsend.sendRaw(temp_27, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷27度");
break;
case 28:
irsend.sendRaw(temp_28, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("制冷28度");
break;
}
}
void slider2_callback(int32_t value)
{
BLINKER_LOG("get slider value: ", value);
int num_mode=value;
switch (num_mode)
{
case 1:
irsend.sendRaw(fan_Fixed, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("静音风速");
break;
case 2:
irsend.sendRaw(fan_Min, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("低风速");
break;
case 3:
irsend.sendRaw(fan_Med, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("中风速");
break;
case 4:
irsend.sendRaw(fan_Max, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("高风速");
break;
case 5:
irsend.sendRaw(fan_Auto, 199, 38); // Send a raw data capture at 38kHz.
Button2.print("自动风速");
break;
}
}
|