#define Led_Pin 14 //Введите свой пин на светодиод
#include <IRsend.h>
#include <GyverPortal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <IRremoteESP8266.h>
#define ONE_WIRE_BUS D2
// Настройка объекта oneWire для связи с любыми устройствами OneWire
OneWire oneWire(ONE_WIRE_BUS);
// Передаем ссылку на объект oneWire объекту Dallas Temperature.
DallasTemperature sensors(&oneWire);
uint8_t sensor1[8] = { 0x28, 0xAE, 0x46, 0x79, 0x97, 0x02, 0x03, 0x3E };
const uint16_t kIrLed = 12; // D5, рекомендованный ПИН ИК передатчика
IRsend irsend(kIrLed);
uint16_t rawData_on[243] = {8446, 4152, 594, 504, 540, 1570, 596, 1544, 570, 530, 538, 1570, 566, 530, 566, 1544, 594, 504, 540, 530, 566, 504, 564, 504, 540, 526, 540, 1576, 590, 1546, 568, 1570, 570, 526, 538, 530, 564, 506, 564, 504, 540, 530, 564, 504, 540, 530, 538, 530, 538, 526, 540, 530, 538, 532, 564, 504, 566, 504, 564, 504, 540, 530, 540, 530, 538, 526, 542, 526, 540, 530, 566, 504, 538, 530, 540, 530, 540, 1570, 564, 530, 564, 504, 566, 504, 564, 506, 538, 530, 540, 524, 540, 530, 538, 530, 564, 504, 564, 504, 566, 504, 538, 526, 540, 530, 566, 504, 564, 504, 564, 504, 536, 530, 538, 530, 566, 504, 540, 530, 564, 504, 540, 530, 536, 530, 566, 504, 566, 504, 538, 530, 540, 530, 564, 504, 536, 530, 540, 530, 564, 504, 564, 504, 540, 530, 564, 504, 540, 526, 540, 530, 566, 504, 564, 504, 538, 530, 540, 530, 540, 530, 540, 530, 534, 530, 538, 530, 540, 530, 538, 530, 564, 504, 566, 504, 538, 530, 538, 532, 534, 530, 540, 530, 540, 530, 540, 530, 566, 504, 538, 530, 540, 530, 534, 530, 540, 530, 538, 530, 538, 530, 540, 530, 536, 530, 540, 530, 540, 530, 564, 504, 540, 530, 540, 530, 538, 530, 534, 534, 534, 530, 564, 504, 566, 504, 566, 504, 538, 530, 538, 532, 538, 1574, 560, 530, 566, 1548, 590, 504, 538, 530, 540, 530, 536};
uint16_t rawData_off[243] = {8424, 4182, 590, 504, 566, 1548, 564, 1574, 562, 528, 564, 1574, 540, 530, 564, 1548, 564, 530, 540, 530, 540, 530, 540, 526, 542, 526, 538, 1600, 538, 1562, 578, 1600, 564, 504, 538, 530, 538, 530, 538, 526, 538, 530, 540, 530, 566, 504, 540, 530, 540, 530, 540, 530, 538, 530, 540, 530, 540, 530, 540, 530, 540, 530, 534, 530, 538, 530, 538, 530, 540, 530, 540, 530, 538, 530, 538, 530, 538, 1574, 566, 530, 564, 504, 540, 530, 538, 530, 534, 530, 538, 530, 540, 530, 540, 530, 538, 1576, 590, 1548, 590, 504, 564, 504, 538, 530, 538, 530, 538, 530, 534, 530, 538, 530, 538, 530, 538, 530, 540, 530, 540, 530, 564, 504, 564, 504, 564, 504, 564, 504, 538, 530, 564, 504, 538, 530, 538, 530, 534, 534, 534, 530, 538, 530, 538, 530, 540, 530, 564, 504, 540, 530, 564, 504, 540, 530, 540, 530, 538, 530, 538, 532, 534, 530, 540, 530, 540, 530, 566, 504, 538, 530, 540, 530, 540, 530, 538, 530, 536, 530, 540, 530, 566, 504, 538, 530, 538, 530, 540, 530, 540, 526, 538, 530, 538, 530, 564, 506, 564, 504, 540, 530, 540, 530, 540, 530, 536, 530, 540, 530, 540, 530, 538, 530, 540, 530, 538, 530, 538, 530, 538, 530, 534, 530, 538, 530, 564, 504, 538, 530, 540, 530, 538, 530, 536, 534, 534, 530, 564, 1548, 594, 474, 566, 530, 540};
uint16_t rawData_19[243] = {8450, 4150, 594, 474, 596, 1540, 568, 1572, 594, 474, 594, 1546, 568, 500, 570, 1566, 568, 500, 594, 1544, 594, 1544, 570, 1566, 596, 1544, 570, 500, 570, 1566, 570, 1570, 594, 474, 568, 500, 568, 500, 564, 500, 596, 474, 570, 500, 594, 474, 570, 500, 570, 500, 570, 500, 566, 504, 564, 500, 594, 474, 568, 500, 594, 474, 568, 502, 564, 506, 564, 500, 594, 474, 594, 474, 568, 500, 596, 474, 570, 1566, 568, 500, 594, 474, 594, 474, 594, 476, 568, 500, 570, 500, 568, 500, 564, 500, 568, 500, 594, 474, 568, 500, 594, 474, 594, 474, 570, 500, 566, 504, 590, 474, 594, 474, 594, 474, 594, 474, 568, 500, 568, 502, 568, 500, 564, 504, 564, 500, 594, 474, 570, 500, 596, 474, 570, 500, 568, 500, 566, 504, 590, 474, 594, 474, 570, 500, 570, 500, 568, 500, 564, 504, 564, 500, 596, 474, 568, 500, 594, 474, 568, 500, 564, 506, 590, 474, 596, 474, 568, 500, 568, 500, 564, 504, 590, 474, 594, 474, 594, 474, 594, 474, 568, 500, 564, 504, 590, 480, 590, 474, 594, 474, 594, 474, 570, 500, 594, 476, 568, 500, 564, 504, 590, 474, 594, 474, 594, 474, 594, 474, 570, 500, 590, 478, 564, 500, 594, 476, 568, 500, 568, 500, 568, 500, 566, 504, 564, 504, 590, 474, 596, 1544, 594, 474, 570, 500, 564, 504, 590, 1544, 570, 500, 594, 474, 568};
uint16_t rawData_18[243] = {8418, 4182, 564, 504, 564, 1570, 594, 1544, 596, 474, 596, 1544, 568, 500, 564, 1570, 594, 474, 594, 474, 568, 1570, 564, 1570, 594, 1544, 596, 474, 570, 1570, 570, 1566, 594, 478, 590, 478, 590, 474, 594, 474, 568, 500, 596, 474, 568, 500, 566, 504, 590, 478, 590, 474, 594, 474, 594, 474, 594, 476, 568, 500, 568, 500, 566, 504, 566, 504, 590, 478, 590, 474, 596, 474, 570, 500, 596, 474, 568, 1570, 564, 504, 590, 478, 590, 474, 596, 474, 596, 474, 596, 474, 570, 500, 568, 500, 568, 500, 564, 504, 564, 504, 564, 504, 564, 504, 590, 474, 594, 474, 594, 474, 570, 500, 570, 500, 568, 500, 564, 504, 564, 504, 590, 480, 590, 474, 568, 500, 594, 474, 570, 500, 566, 504, 564, 506, 564, 504, 590, 474, 594, 474, 568, 500, 594, 474, 568, 500, 564, 506, 564, 504, 590, 478, 590, 474, 594, 474, 570, 500, 594, 474, 570, 500, 568, 500, 568, 500, 564, 504, 564, 504, 566, 504, 590, 478, 590, 474, 594, 474, 570, 500, 570, 500, 564, 504, 564, 504, 566, 504, 564, 504, 590, 480, 590, 474, 594, 474, 570, 500, 568, 500, 568, 500, 564, 504, 590, 478, 590, 478, 590, 478, 564, 500, 594, 474, 568, 500, 568, 500, 564, 504, 566, 504, 590, 478, 590, 478, 590, 1544, 570, 500, 568, 500, 568, 500, 568, 500, 568, 1570, 564, 504, 590, 478, 564};
uint16_t rawData_17[243] = {8420, 4182, 538, 530, 564, 1570, 570, 1570, 568, 500, 538, 1600, 540, 530, 566, 1574, 566, 504, 564, 1570, 568, 500, 544, 1596, 540, 1600, 564, 504, 564, 1570, 570, 1570, 540, 530, 538, 530, 564, 504, 564, 504, 564, 504, 566, 504, 566, 500, 570, 500, 540, 530, 540, 530, 564, 504, 564, 504, 564, 504, 564, 504, 564, 500, 570, 500, 540, 530, 566, 504, 566, 504, 566, 504, 564, 500, 568, 500, 544, 1596, 538, 530, 564, 504, 564, 504, 564, 504, 566, 500, 570, 500, 540, 530, 538, 530, 564, 504, 564, 504, 566, 504, 564, 500, 544, 526, 564, 504, 566, 504, 566, 504, 564, 504, 566, 500, 544, 526, 540, 530, 564, 504, 566, 504, 564, 504, 564, 500, 568, 500, 540, 530, 564, 504, 566, 504, 564, 504, 564, 504, 564, 500, 568, 500, 538, 530, 566, 504, 564, 506, 564, 504, 564, 500, 542, 528, 564, 504, 564, 504, 566, 504, 566, 504, 566, 500, 544, 526, 540, 530, 564, 504, 566, 504, 566, 504, 566, 500, 544, 526, 566, 504, 566, 504, 566, 504, 564, 504, 564, 504, 540, 526, 544, 524, 564, 504, 566, 504, 564, 506, 564, 504, 564, 504, 540, 526, 544, 526, 566, 504, 564, 504, 564, 504, 564, 504, 564, 506, 538, 530, 540, 526, 538, 530, 564, 504, 564, 504, 564, 504, 566, 504, 540, 530, 540, 524, 540, 530, 564, 1574, 564, 504, 564, 504, 564};
uint16_t rawData_16[243] = {8414, 4214, 530, 540, 556, 1578, 560, 1578, 560, 508, 530, 1608, 556, 512, 532, 1604, 534, 534, 530, 538, 530, 540, 556, 1582, 530, 1604, 534, 534, 530, 1608, 530, 1604, 536, 534, 560, 510, 534, 534, 560, 508, 534, 534, 532, 538, 556, 512, 556, 512, 556, 510, 534, 534, 560, 508, 534, 534, 560, 508, 536, 534, 556, 512, 532, 538, 556, 508, 560, 508, 560, 508, 534, 536, 530, 538, 530, 538, 556, 1582, 556, 512, 530, 536, 534, 534, 534, 534, 560, 508, 536, 534, 530, 538, 530, 538, 530, 540, 556, 512, 532, 534, 560, 508, 560, 508, 534, 534, 534, 534, 556, 514, 530, 538, 556, 514, 556, 514, 530, 534, 534, 534, 534, 534, 530, 538, 556, 514, 530, 540, 556, 508, 536, 534, 530, 538, 530, 538, 556, 514, 556, 514, 556, 514, 556, 508, 530, 538, 556, 512, 530, 540, 556, 512, 556, 512, 556, 508, 556, 512, 556, 512, 530, 538, 530, 538, 530, 538, 530, 534, 556, 514, 556, 512, 556, 512, 556, 514, 530, 538, 530, 538, 530, 534, 530, 538, 532, 538, 530, 538, 530, 538, 556, 508, 534, 534, 534, 534, 530, 538, 556, 514, 530, 538, 530, 538, 530, 534, 530, 538, 532, 538, 530, 538, 530, 538, 530, 538, 556, 514, 528, 534, 530, 538, 530, 538, 532, 538, 530, 1608, 530, 1604, 534, 1604, 556, 1582, 530, 1608, 530, 538, 556, 512, 556, 510, 556};
uint16_t rawData_swingON[243] = {8422, 4178, 570, 500, 594, 1544, 596, 1544, 568, 500, 570, 1566, 570, 500, 570, 1570, 596, 474, 594, 474, 568, 500, 568, 1566, 568, 1570, 596, 474, 568, 1570, 570, 1566, 568, 502, 594, 474, 596, 474, 596, 474, 568, 500, 568, 500, 568, 500, 564, 500, 594, 474, 596, 474, 594, 474, 568, 500, 594, 474, 570, 500, 570, 500, 570, 500, 564, 504, 566, 500, 594, 474, 596, 474, 596, 474, 568, 500, 594, 1544, 568, 500, 570, 500, 564, 504, 566, 1570, 594, 474, 596, 474, 568, 502, 568, 500, 570, 500, 570, 500, 566, 504, 564, 504, 590, 474, 594, 474, 594, 474, 570, 500, 594, 474, 570, 500, 564, 504, 590, 478, 590, 478, 590, 474, 594, 476, 594, 474, 594, 474, 568, 500, 568, 500, 564, 504, 564, 504, 566, 500, 594, 474, 596, 474, 570, 500, 594, 474, 568, 500, 592, 478, 590, 480, 590, 474, 594, 474, 596, 474, 570, 500, 566, 504, 590, 478, 590, 474, 568, 500, 570, 500, 570, 500, 570, 500, 590, 478, 590, 476, 594, 474, 568, 500, 568, 500, 570, 500, 564, 504, 590, 478, 566, 500, 570, 500, 570, 500, 594, 474, 568, 500, 564, 504, 590, 478, 566, 500, 594, 474, 568, 500, 568, 500, 590, 478, 590, 478, 590, 478, 566, 500, 594, 474, 568, 500, 568, 500, 570, 1570, 566, 504, 592, 478, 590, 478, 590, 474, 568, 1570, 566, 504, 590, 480, 590};
uint16_t rawData_swingOFF[243] = {8418, 4182, 568, 500, 568, 1570, 564, 1574, 564, 504, 564, 1570, 568, 504, 564, 1570, 568, 500, 568, 500, 568, 500, 568, 1570, 564, 1574, 564, 504, 564, 1570, 568, 1572, 564, 504, 564, 504, 564, 504, 564, 504, 566, 504, 564, 500, 570, 500, 568, 500, 566, 504, 564, 504, 564, 504, 564, 506, 564, 500, 568, 500, 568, 500, 568, 500, 564, 504, 566, 504, 564, 504, 564, 504, 566, 504, 564, 500, 570, 1570, 566, 504, 564, 506, 564, 504, 566, 504, 564, 504, 566, 498, 570, 500, 568, 500, 564, 506, 564, 506, 564, 504, 566, 504, 566, 500, 570, 500, 570, 500, 564, 504, 564, 504, 566, 504, 566, 504, 566, 504, 564, 500, 568, 500, 564, 504, 564, 504, 564, 504, 564, 504, 566, 504, 564, 504, 566, 500, 564, 504, 566, 504, 566, 504, 566, 504, 564, 504, 564, 504, 566, 500, 564, 504, 564, 504, 564, 504, 564, 504, 564, 506, 564, 506, 564, 500, 564, 504, 564, 504, 564, 504, 564, 504, 564, 504, 564, 504, 564, 506, 564, 500, 568, 500, 564, 504, 564, 504, 564, 504, 564, 504, 564, 504, 564, 500, 570, 500, 564, 504, 564, 504, 564, 504, 564, 504, 564, 504, 564, 506, 564, 504, 564, 500, 568, 500, 564, 504, 566, 504, 564, 504, 564, 504, 564, 504, 564, 504, 566, 1574, 564, 1570, 568, 1570, 566, 1574, 564, 1574, 564, 504, 564, 504, 564, 500, 570};
GyverPortal portal;
float tempSensor1 = sensors.getTempC(sensor1);
// конструктор страницы
void build() {
BUILD_BEGIN();
GP.THEME(GP_DARK);
GP.AJAX_UPDATE("val");
GP.TITLE("Primer");
GP.LABEL("Value: ");
GP.LABEL("NAN", "val");
GP.HR();
GP.BUTTON("btn_on", "Включить");
GP.BUTTON("btn_off", "Выключить");
GP.BUTTON("btn_onkond", "Включить кондиционер");
GP.BUTTON("btn_offkond", "Выключить кондиционер");
BUILD_END();
}
void setup() {
sensors.begin();
irsend.begin(); // Инициализируем ИК передатчик
Serial.begin(115200);
pinMode(Led_Pin,OUTPUT);
WiFi.mode(WIFI_STA);
WiFi.begin(AP_SSID, AP_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(WiFi.localIP());
// подключаем конструктор и запускаем
portal.attachBuild(build);
portal.attach(action);
portal.update();
portal.start();
}
void action() {
tempSensor1 = sensors.getTempC(sensor1); // Получить значение температуры
if (portal.update("val")) portal.answer(tempSensor1);
// был клик по компоненту
if (portal.click()) {
// проверяем компоненты и обновляем переменные
if (portal.click("btn_on")) digitalWrite(Led_Pin, 0);
if (portal.click("btn_off")) digitalWrite(Led_Pin, 1);
if (portal.click("btn_onkond")) digitalWrite(IRsend, uint16_t rawData_on);
if (portal.click("btn_offkond")) digitalWrite(Led_Pin, 1);
}
}
void loop() {
sensors.requestTemperatures();
portal.tick();
Serial.println(tempSensor1);
}