From 49536baf511ec07c3bff05183b9d759db1e474db Mon Sep 17 00:00:00 2001 From: Softwarecrash Date: Sun, 9 Apr 2023 13:27:29 +0200 Subject: [PATCH] add temperature --- platformio.ini | 4 ++-- src/{main.ino => main.cpp} | 23 +++++++++-------------- src/main.h | 9 +++++++++ src/webpages/htmlCase.h | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) rename src/{main.ino => main.cpp} (98%) create mode 100644 src/main.h diff --git a/platformio.ini b/platformio.ini index 8e92ba3..718fa52 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,9 +12,9 @@ platform = espressif8266 board = d1_mini framework = arduino -upload_port = COM4 -monitor_port = COM4 monitor_speed = 115200 +monitor_filters = esp8266_exception_decoder, default, time, printable, colorize +upload_speed = 921600 lib_extra_dirs = /lib lib_deps = diff --git a/src/main.ino b/src/main.cpp similarity index 98% rename from src/main.ino rename to src/main.cpp index f7742ab..b10a35c 100644 --- a/src/main.ino +++ b/src/main.cpp @@ -3,7 +3,7 @@ * */ #include - +#include "main.h" #include #include "epregister.h" @@ -51,7 +51,6 @@ AsyncWebSocketClient *wsClient; DNSServer dns; -// const int nodeNum = 2; ModbusMaster epnode; // instantiate ModbusMaster object UnixTime uTime(3); // указать GMT (3 для Москвы) @@ -182,8 +181,8 @@ void setup() AsyncWiFiManagerParameter custom_mqtt_pass("mqtt_pass", "MQTT Password", NULL, 32); AsyncWiFiManagerParameter custom_mqtt_topic("mqtt_topic", "MQTT Topic", NULL, 32); AsyncWiFiManagerParameter custom_mqtt_port("mqtt_port", "MQTT Port", NULL, 6); - AsyncWiFiManagerParameter custom_mqtt_refresh("mqtt_refresh", "MQTT Send Interval", NULL, 4); - AsyncWiFiManagerParameter custom_device_name("device_name", "Device Name", NULL, 32); + AsyncWiFiManagerParameter custom_mqtt_refresh("mqtt_refresh", "MQTT Send Interval", "300", 4); + AsyncWiFiManagerParameter custom_device_name("device_name", "Device Name", "EPEver2MQTT", 32); AsyncWiFiManagerParameter custom_device_quantity("device_name", "Device Quantity", NULL, 2); wm.addParameter(&custom_mqtt_server); @@ -319,27 +318,25 @@ void setup() if(request->arg("post_mqttjson") != "true") _settings._mqttJson = false; Serial.print(_settings._mqttServer); _settings.save(); - //delay(500); - //_settings.load(); }); server.on("/set", HTTP_GET, [](AsyncWebServerRequest *request) { AsyncWebParameter *p = request->getParam(0); - + /* if (p->name() == "cleanerrorstate") { updateProgress = true; - if (p->value().toInt() != 0) - { - epnode.setSlaveId(p->value().toInt()); - epnode.writeSingleCoil(0x16, true); //0101 ?? + for (size_t i = 1; i < ((size_t)_settings._deviceQuantity+1); i++) + { + epnode.setSlaveId(i); + epnode.writeSingleCoil(0x0100, true); //0101 ?? //not finishd yet, move to main page and only display a unlock button when a error is avaible //https://forum.iobroker.net/assets/uploads/files/1667825519362-up-hi-communication-protocol-v8.5.pdf } updateProgress = false; } - + */ if (p->name() == "datetime") { uint8_t rtcSetY = atoi (request->getParam("datetime")->value().substring(0, 2).c_str ()); @@ -433,8 +430,6 @@ void loop() { if(getEpData(i)) { - //getEpData(i); - getJsonData(i); sendtoMQTT(i); // Update data to MQTT server if we should } diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..8b80aff --- /dev/null +++ b/src/main.h @@ -0,0 +1,9 @@ + + +bool getEpData(int invNum); + +bool getJsonData(int invNum); + +void callback(char *top, byte *payload, unsigned int length); + +bool sendtoMQTT(int invNum); \ No newline at end of file diff --git a/src/webpages/htmlCase.h b/src/webpages/htmlCase.h index a96b0e7..2b30ddb 100644 --- a/src/webpages/htmlCase.h +++ b/src/webpages/htmlCase.h @@ -17,7 +17,7 @@ const char HTML_HEAD[] PROGMEM = R"rawliteral( const char HTML_FOOT[] PROGMEM = R"rawliteral(
-EPEver to MQTT V0.2.2 By Softwarecrash +EPEver to MQTT V0.2.3 By Softwarecrash Creative Commons License