Откат воздуха далеко назад....
parent
d8a09949f6
commit
8ef1f6cdd1
275
M5Atom_airqa.ino
275
M5Atom_airqa.ino
|
@ -17,13 +17,11 @@
|
||||||
24A160474D14
|
24A160474D14
|
||||||
24A160542B80
|
24A160542B80
|
||||||
|
|
||||||
|
|
||||||
Белая 2B80
|
Белая 2B80
|
||||||
Шумная 38CC
|
Шумная 38CC
|
||||||
У вас 23AC
|
У вас 23AC
|
||||||
Офис 5450
|
Офис 5450
|
||||||
Кухня 4D41
|
Кухня 4D14
|
||||||
|
|
||||||
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
@ -56,7 +54,7 @@
|
||||||
#define CCS811_ADDR 0x5B //Default I2C Address
|
#define CCS811_ADDR 0x5B //Default I2C Address
|
||||||
//#define CCS811_ADDR 0x5A //Alternate I2C Address
|
//#define CCS811_ADDR 0x5A //Alternate I2C Address
|
||||||
|
|
||||||
unsigned int VersionSW = 48; //65536 Версия прошивки
|
unsigned int VersionSW = 54; //65536 Версия прошивки
|
||||||
|
|
||||||
//15 - добавлено то, се, забыл вообще дописать что добавлено Serial
|
//15 - добавлено то, се, забыл вообще дописать что добавлено Serial
|
||||||
//19 - вывод в консоль всех действий, ошибки с обновлнеием - починил, прияногое мигание светодиодом, тест для поиска metrics.
|
//19 - вывод в консоль всех действий, ошибки с обновлнеием - починил, прияногое мигание светодиодом, тест для поиска metrics.
|
||||||
|
@ -83,8 +81,11 @@ unsigned int VersionSW = 48; //65536 Версия прошивки
|
||||||
//43 - Больше задержек для чтения i2c
|
//43 - Больше задержек для чтения i2c
|
||||||
//44 - Новая либа твок "maarten-pennings" Спаркфан и Адафрут суки - с ошибками изначально пишут на всех форумах.
|
//44 - Новая либа твок "maarten-pennings" Спаркфан и Адафрут суки - с ошибками изначально пишут на всех форумах.
|
||||||
//46 - Смена локального сервера времени, хрони на одроиде. Установка базовых линий по новой.
|
//46 - Смена локального сервера времени, хрони на одроиде. Установка базовых линий по новой.
|
||||||
//48 - алгоритм фильтрации
|
//48 - алгоритм фильтрации
|
||||||
|
//50 - нахуй хост менеджер, смена качества
|
||||||
|
//52 - убрал базовые линии ЕСО2.
|
||||||
|
//53 - базовые линии вернулись на место. Обновление по старту css811 7 измерений вместо 10
|
||||||
|
|
||||||
WiFiManager wm; // обьект менеджера
|
WiFiManager wm; // обьект менеджера
|
||||||
WiFiManagerParameter custom_field;
|
WiFiManagerParameter custom_field;
|
||||||
Preferences OTApreferences; //Обьект хранения настроек хеша прошивки
|
Preferences OTApreferences; //Обьект хранения настроек хеша прошивки
|
||||||
|
@ -94,7 +95,7 @@ Preferences OTApreferences; //Обьект хранения настроек х
|
||||||
CCS811 ccs811(23);
|
CCS811 ccs811(23);
|
||||||
|
|
||||||
ClosedCube_HDC1080 hdc1080;
|
ClosedCube_HDC1080 hdc1080;
|
||||||
StaticJsonDocument<200> doc;
|
StaticJsonDocument<200> doc;
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
PubSubClient MqttClient(espClient);
|
PubSubClient MqttClient(espClient);
|
||||||
|
@ -104,8 +105,10 @@ PubSubClient MqttClient(espClient);
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 20000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
NTPClient timeClient(ntpUDP, "192.168.89.210", 0, 20000); //Собственно сервер времени смещение и частоат запроса, но он вручную
|
||||||
const PROGMEM char *willmess = "{\"conn\":\"err\"}";
|
const PROGMEM char *willmess = "{\"conn\":\"err\"}";
|
||||||
const char *mqttHostName = "metrics"; //Хостнейм брокера metrics.local cctv.automation.art //192.168.89.210
|
//Хостнейм брокера metrics.local cctv.automation.art //192.168.89.210
|
||||||
unsigned int mqttPort = 1883; //Порт брокера 1883 8889
|
|
||||||
|
IPAddress ipaddrBro(192, 168, 89, 210);
|
||||||
|
unsigned int mqttPort = 1883; //Порт брокера 1883 8889
|
||||||
|
|
||||||
const char *prefArea = "ota-config";
|
const char *prefArea = "ota-config";
|
||||||
|
|
||||||
|
@ -118,7 +121,6 @@ const PROGMEM char *mqttLogin = "AA_Lab", *mqttPass = "automation.art$";
|
||||||
|
|
||||||
char bufTopic[140];
|
char bufTopic[140];
|
||||||
char bufWillTopic[150];
|
char bufWillTopic[150];
|
||||||
|
|
||||||
const char *mqttIPHost;
|
const char *mqttIPHost;
|
||||||
|
|
||||||
RTC_DATA_ATTR byte countOta = 0;
|
RTC_DATA_ATTR byte countOta = 0;
|
||||||
|
@ -133,15 +135,6 @@ unsigned int cntWhile = 4;
|
||||||
bool mqttSendFlag = false;
|
bool mqttSendFlag = false;
|
||||||
bool flagblink = true;
|
bool flagblink = true;
|
||||||
|
|
||||||
|
|
||||||
float k = 0.1;
|
|
||||||
float expRunningAverage(float newVal) {
|
|
||||||
RTC_DATA_ATTR static float filVal = 0;
|
|
||||||
filVal += (newVal - filVal) * k;
|
|
||||||
return filVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ledset(byte color = 0, bool blink = false)
|
void ledset(byte color = 0, bool blink = false)
|
||||||
{
|
{
|
||||||
M5.dis.setBrightness(30); //Половина яркости
|
M5.dis.setBrightness(30); //Половина яркости
|
||||||
|
@ -165,109 +158,27 @@ void ledset(byte color = 0, bool blink = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress str2IP(String str)
|
|
||||||
{
|
|
||||||
IPAddress ret(getIpBlock(0, str), getIpBlock(1, str), getIpBlock(2, str), getIpBlock(3, str));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getIpBlock(int index, String str)
|
|
||||||
{
|
|
||||||
char separator = '.';
|
|
||||||
int found = 0;
|
|
||||||
int strIndex[] = {0, -1};
|
|
||||||
int maxIndex = str.length() - 1;
|
|
||||||
|
|
||||||
for (int i = 0; i <= maxIndex && found <= index; i++)
|
|
||||||
{
|
|
||||||
if (str.charAt(i) == separator || i == maxIndex)
|
|
||||||
{
|
|
||||||
found++;
|
|
||||||
strIndex[0] = strIndex[1] + 1;
|
|
||||||
strIndex[1] = (i == maxIndex) ? i + 1 : i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found > index ? str.substring(strIndex[0], strIndex[1]).toInt() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int setMqttServer(const char *mqttHostNameF, unsigned int mqttPortF)
|
|
||||||
{
|
|
||||||
mdns_init();
|
|
||||||
|
|
||||||
IPAddress ipaddr;
|
|
||||||
OTApreferences.begin("ota-config");
|
|
||||||
|
|
||||||
String keyIpMqtt = OTApreferences.getString("mqttip", "0");
|
|
||||||
//Если нет IP в preferences
|
|
||||||
Serial.print("keyIpMqtt: ");
|
|
||||||
Serial.println(keyIpMqtt);
|
|
||||||
|
|
||||||
if (keyIpMqtt == "0")
|
|
||||||
{
|
|
||||||
//Запрос по хостнейму .local
|
|
||||||
ipaddr = MDNS.queryHost(mqttHostNameF, 4000);
|
|
||||||
//Таймаут 4 секунды
|
|
||||||
//Если не получили по хостнейму МДНС
|
|
||||||
Serial.print("mdns: ");
|
|
||||||
Serial.println(ipaddr);
|
|
||||||
|
|
||||||
if (ipaddr.toString() == "0.0.0.0")
|
|
||||||
{
|
|
||||||
//Запрос к ДНС по адресу сайта
|
|
||||||
int err = WiFi.hostByName(mqttHostNameF, ipaddr);
|
|
||||||
////real internal timeout in lwip library is 14[s]
|
|
||||||
//Если получили по хостнейму
|
|
||||||
if (err == 1)
|
|
||||||
{
|
|
||||||
Serial.print("hostByName: ");
|
|
||||||
Serial.println(ipaddr);
|
|
||||||
MqttClient.setServer(ipaddr, mqttPortF);
|
|
||||||
OTApreferences.putString("mqttip", ipaddr.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.print("All method not FOUND IP");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ //Если все хорошо
|
|
||||||
OTApreferences.putString("mqttip", ipaddr.toString());
|
|
||||||
MqttClient.setServer(ipaddr, mqttPortF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MqttClient.setServer(str2IP(keyIpMqtt), mqttPortF);
|
|
||||||
}
|
|
||||||
|
|
||||||
OTApreferences.end();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Настройки
|
//Настройки
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
pinMode(GPIO_WAK, OUTPUT); //Пин датчика для работы
|
pinMode(GPIO_WAK, OUTPUT); //Пин датчика для работы
|
||||||
digitalWrite(GPIO_WAK, LOW);
|
digitalWrite(GPIO_WAK, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.setDebugOutput(true);
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
M5.begin(true, false, true);
|
M5.begin(true, false, true);
|
||||||
Wire.begin(25, 21); //Пины для I2c на ATOM
|
Wire.begin(25, 21); //Пины для I2c на ATOM
|
||||||
|
|
||||||
pinMode(TRIGGER_PIN, INPUT);
|
|
||||||
|
|
||||||
hdc1080.begin(0x40);
|
hdc1080.begin(0x40);
|
||||||
hdc1080.setResolution(HDC1080_RESOLUTION_11BIT, HDC1080_RESOLUTION_11BIT);
|
hdc1080.setResolution(HDC1080_RESOLUTION_11BIT, HDC1080_RESOLUTION_11BIT);
|
||||||
|
startCcs811(macc);
|
||||||
|
|
||||||
startCcs811(macc);
|
pinMode(TRIGGER_PIN, INPUT);
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
topicTemp.toCharArray(bufTopic, topicTemp.length() + 1);
|
topicTemp.toCharArray(bufTopic, topicTemp.length() + 1);
|
||||||
willTopicTemp.toCharArray(bufWillTopic, willTopicTemp.length() + 1);
|
willTopicTemp.toCharArray(bufWillTopic, willTopicTemp.length() + 1);
|
||||||
|
@ -292,8 +203,11 @@ void setup()
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Запрос IP сервера MQTT и установка сервера
|
//Запрос IP сервера MQTT и установка сервера
|
||||||
setMqttServer(mqttHostName, mqttPort);
|
// MqttClient.setServer(ipaddrBro, mqttPort);
|
||||||
|
|
||||||
if (reqNtpTime() == 1)
|
if (reqNtpTime() == 1)
|
||||||
{
|
{
|
||||||
|
@ -352,7 +266,6 @@ void OTAUpdate()
|
||||||
|
|
||||||
if (httpResponseCode > 0)
|
if (httpResponseCode > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
Serial.println(httpResponseCode);
|
Serial.println(httpResponseCode);
|
||||||
payload = http.getString();
|
payload = http.getString();
|
||||||
|
|
||||||
|
@ -398,7 +311,7 @@ void OTAUpdate()
|
||||||
if (flagOTA == true)
|
if (flagOTA == true)
|
||||||
{
|
{
|
||||||
// flagOTA = false;
|
// flagOTA = false;
|
||||||
disconnectMQTT();
|
disconnectMQTT();
|
||||||
|
|
||||||
ESPhttpUpdate.rebootOnUpdate(true);
|
ESPhttpUpdate.rebootOnUpdate(true);
|
||||||
|
|
||||||
|
@ -441,27 +354,28 @@ String getMacAddress()
|
||||||
|
|
||||||
int startCcs811(String MacThat)
|
int startCcs811(String MacThat)
|
||||||
{
|
{
|
||||||
|
unsigned int coefBaseline = 0;
|
||||||
unsigned int coefBaseline = 0;
|
ccs811.set_i2cdelay(50);
|
||||||
|
bool ok = ccs811.begin();
|
||||||
ccs811.set_i2cdelay(50);
|
delay(100);
|
||||||
bool ok = ccs811.begin();
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
Serial.println("setup: CCS811 begin FAILED");
|
Serial.println("setup: CCS811 begin FAILED");
|
||||||
|
httpSerial("CCS811_failed_begin");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Serial.print("setup: hardware version: ");
|
// Serial.print("setup: hardware version: ");
|
||||||
Serial.println(ccs811.hardware_version(), HEX);
|
// Serial.println(ccs811.hardware_version(), HEX);
|
||||||
Serial.print("setup: bootloader version: ");
|
// Serial.print("setup: bootloader version: ");
|
||||||
Serial.println(ccs811.bootloader_version(), HEX);
|
// Serial.println(ccs811.bootloader_version(), HEX);
|
||||||
Serial.print("setup: application version: ");
|
// Serial.print("setup: application version: ");
|
||||||
Serial.println(ccs811.application_version(), HEX);
|
// Serial.println(ccs811.application_version(), HEX);
|
||||||
|
|
||||||
ok = ccs811.start(CCS811_MODE_1SEC);
|
ok = ccs811.start(CCS811_MODE_1SEC);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
Serial.println("setup: CCS811 start FAILED");
|
Serial.println("setup: CCS811 start FAILED");
|
||||||
|
httpSerial("CCS811_failed_start");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +385,7 @@ int startCcs811(String MacThat)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MacThat == "5002918A38CC")
|
if (MacThat == "5002918A38CC")
|
||||||
{
|
{
|
||||||
coefBaseline = 29814;
|
coefBaseline = 29814;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,11 +406,11 @@ int startCcs811(String MacThat)
|
||||||
|
|
||||||
if (coefBaseline != 0)
|
if (coefBaseline != 0)
|
||||||
{
|
{
|
||||||
ccs811.set_baseline(coefBaseline);
|
ccs811.set_baseline(coefBaseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetCallibrationCoeff(String MacThat)
|
int SetCallibrationCoeff(String MacThat)
|
||||||
{
|
{
|
||||||
|
@ -562,50 +476,50 @@ void reqSensorData()
|
||||||
|
|
||||||
while (ccsflag)
|
while (ccsflag)
|
||||||
{
|
{
|
||||||
delay(1100);
|
|
||||||
ccs811.read(&eco2N, &etvocN, &errstat, &raw);
|
ccs811.read(&eco2N, &etvocN, &errstat, &raw);
|
||||||
ccs811.get_baseline(&baseline);
|
ccs811.get_baseline(&baseline);
|
||||||
|
|
||||||
// Print measurement results based on status
|
// Print measurement results based on status
|
||||||
if (errstat == CCS811_ERRSTAT_OK)
|
// if (errstat == CCS811_ERRSTAT_OK)
|
||||||
{
|
// {
|
||||||
Serial.print("CCS811: ");
|
// // Serial.print("CCS811: ");
|
||||||
Serial.print("eco2=");
|
// // Serial.print("eco2=");
|
||||||
Serial.print(eco2N);
|
// // Serial.print(eco2N);
|
||||||
Serial.print(" ppm ");
|
// // Serial.print(" ppm ");
|
||||||
Serial.print("etvoc=");
|
// // Serial.print("etvoc=");
|
||||||
Serial.print(etvocN);
|
// // Serial.print(etvocN);
|
||||||
Serial.print(" ppb ");
|
// // Serial.print(" ppb ");
|
||||||
|
// // Serial.print(" baseline= ");
|
||||||
|
// // Serial.print(baseline);
|
||||||
|
// // Serial.println();
|
||||||
|
// }
|
||||||
|
|
||||||
Serial.print(" baseline= ");
|
// if (errstat == CCS811_ERRSTAT_OK_NODATA)
|
||||||
Serial.print(baseline);
|
// {
|
||||||
|
// // Serial.println("CCS811: waiting for (new) data");
|
||||||
//Serial.print("raw6="); Serial.print(raw/1024); Serial.print(" uA ");
|
// }
|
||||||
//Serial.print("raw10="); Serial.print(raw%1024); Serial.print(" ADC ");
|
// else
|
||||||
//Serial.print("R="); Serial.print((1650*1000L/1023)*(raw%1024)/(raw/1024)); Serial.print(" ohm");
|
|
||||||
Serial.println();
|
if (errstat & CCS811_ERRSTAT_I2CFAIL)
|
||||||
}
|
|
||||||
else if (errstat == CCS811_ERRSTAT_OK_NODATA)
|
|
||||||
{
|
{
|
||||||
Serial.println("CCS811: waiting for (new) data");
|
httpSerial("CCS811_i2c_error");
|
||||||
}
|
}
|
||||||
else if (errstat & CCS811_ERRSTAT_I2CFAIL)
|
else
|
||||||
{
|
{
|
||||||
Serial.println("CCS811: I2C error");
|
// Serial.print("CCS811: errstat=");
|
||||||
}
|
// Serial.print(errstat, HEX);
|
||||||
else
|
// Serial.print("=");
|
||||||
{
|
// Serial.println();
|
||||||
Serial.print("CCS811: errstat=");
|
httpSerial("errstat="+String(ccs811.errstat_str(errstat)));
|
||||||
Serial.print(errstat, HEX);
|
|
||||||
Serial.print("=");
|
|
||||||
Serial.println(ccs811.errstat_str(errstat));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
counAvail++;
|
counAvail++;
|
||||||
if (counAvail >= 10)
|
if (counAvail >= 8)
|
||||||
{
|
{
|
||||||
ccsflag = false;
|
ccsflag = false;
|
||||||
}
|
}
|
||||||
|
delay(1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
ledset(2, false);
|
ledset(2, false);
|
||||||
|
@ -613,7 +527,6 @@ void reqSensorData()
|
||||||
Eco2Av = eco2N;
|
Eco2Av = eco2N;
|
||||||
TvocAv = etvocN;
|
TvocAv = etvocN;
|
||||||
BaselineTvoc = baseline;
|
BaselineTvoc = baseline;
|
||||||
|
|
||||||
rssi = WiFi.RSSI();
|
rssi = WiFi.RSSI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +543,7 @@ int SendMqttReq(bool sendVal = true, bool sendStatus = true, byte statusConn = 1
|
||||||
|
|
||||||
if (sendVal == true)
|
if (sendVal == true)
|
||||||
{
|
{
|
||||||
doc["t"] = expRunningAverage(TempAv);
|
doc["t"] = TempAv;
|
||||||
doc["h"] = HumAv;
|
doc["h"] = HumAv;
|
||||||
doc["eco"] = (int)Eco2Av;
|
doc["eco"] = (int)Eco2Av;
|
||||||
doc["tvoc"] = (int)TvocAv;
|
doc["tvoc"] = (int)TvocAv;
|
||||||
|
@ -715,26 +628,26 @@ void reconnectMqtt()
|
||||||
while (!MqttClient.connected())
|
while (!MqttClient.connected())
|
||||||
{
|
{
|
||||||
circle++;
|
circle++;
|
||||||
if (circle == 7)
|
if (circle == 4)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String maccrandom = macc + String(random(0xffff), HEX);
|
MqttClient.setServer(ipaddrBro, mqttPort);
|
||||||
const char *clientId = maccrandom.c_str();
|
|
||||||
|
|
||||||
|
const char *clientId = macc.c_str();
|
||||||
if (MqttClient.connect(clientId, mqttLogin, mqttPass, bufWillTopic, 2, true, willmess))
|
if (MqttClient.connect(clientId, mqttLogin, mqttPass, bufWillTopic, 2, true, willmess))
|
||||||
{
|
{
|
||||||
Serial.println("Mqttconnect - OK");
|
Serial.println("Mqttconnect - OK");
|
||||||
|
mqttSendFlag = true;
|
||||||
mqttSendFlag = true;
|
|
||||||
|
|
||||||
SendMqttReq(false, true, 1);
|
SendMqttReq(false, true, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.print("Mqtt.state() = ");
|
Serial.print("Mqtt.state() = ");
|
||||||
Serial.println(MqttClient.state());
|
Serial.println(MqttClient.state());
|
||||||
|
httpSerial("MqttState:" + String(MqttClient.state()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-4 : MQTT_CONNECTION_TIMEOUT - the server didn't respond within the keepalive time
|
-4 : MQTT_CONNECTION_TIMEOUT - the server didn't respond within the keepalive time
|
||||||
-3 : MQTT_CONNECTION_LOST - the network connection was broken
|
-3 : MQTT_CONNECTION_LOST - the network connection was broken
|
||||||
|
@ -753,6 +666,31 @@ void reconnectMqtt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int httpSerial(String serialmess)
|
||||||
|
{
|
||||||
|
|
||||||
|
OTApreferences.begin("ota-config");
|
||||||
|
if (WiFi.status() == WL_CONNECTED)
|
||||||
|
{
|
||||||
|
HTTPClient http;
|
||||||
|
String serverPath = "http://meteosence.s-host.net/serial/log.php?mac=" + macc + "&logmess=" + serialmess;
|
||||||
|
http.begin(serverPath.c_str());
|
||||||
|
int httpResponseCode = http.GET();
|
||||||
|
|
||||||
|
if (httpResponseCode > 0)
|
||||||
|
{
|
||||||
|
// Serial.print("HTTP Response code: ");
|
||||||
|
// Serial.println(httpResponseCode);
|
||||||
|
String payload = http.getString();
|
||||||
|
if (payload == "false")
|
||||||
|
{
|
||||||
|
Serial.println("Failed write to Http.Serial");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//Проверка старта сервера
|
//Проверка старта сервера
|
||||||
|
@ -767,20 +705,22 @@ void loop()
|
||||||
MqttClient.loop();
|
MqttClient.loop();
|
||||||
|
|
||||||
reqSensorData();
|
reqSensorData();
|
||||||
SetCallibrationCoeff(macc);
|
|
||||||
|
SetCallibrationCoeff(macc);
|
||||||
|
|
||||||
SendMqttReq(true, true, 3);
|
SendMqttReq(true, true, 3);
|
||||||
|
|
||||||
if (M5.Btn.pressedFor(1000))
|
if (M5.Btn.pressedFor(1000))
|
||||||
{
|
{
|
||||||
|
httpSerial("Reset_in_button");
|
||||||
ledset(4, true);
|
ledset(4, true);
|
||||||
checkButton();
|
checkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countOta >= 10)
|
if (countOta >= 10)
|
||||||
{
|
{
|
||||||
// reqNtpTime();
|
// reqNtpTime();
|
||||||
countOta = 0;
|
countOta = 0;
|
||||||
|
|
||||||
SendMqttReq(false, true, 4);
|
SendMqttReq(false, true, 4);
|
||||||
OTAUpdate();
|
OTAUpdate();
|
||||||
SendMqttReq(false, true, 1);
|
SendMqttReq(false, true, 1);
|
||||||
|
@ -793,6 +733,7 @@ void loop()
|
||||||
|
|
||||||
int disconnectMQTT()
|
int disconnectMQTT()
|
||||||
{
|
{
|
||||||
|
|
||||||
MqttClient.disconnect();
|
MqttClient.disconnect();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue