Skip to content

Commit

Permalink
add temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Apr 9, 2023
1 parent c835d6f commit 49536ba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
23 changes: 9 additions & 14 deletions src/main.ino → src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/
#include <Arduino.h>

#include "main.h"
#include <ModbusMaster.h>
#include "epregister.h"

Expand Down Expand Up @@ -51,7 +51,6 @@ AsyncWebSocketClient *wsClient;

DNSServer dns;

// const int nodeNum = 2;
ModbusMaster epnode; // instantiate ModbusMaster object

UnixTime uTime(3); // указать GMT (3 для Москвы)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 ());
Expand Down Expand Up @@ -433,8 +430,6 @@ void loop()
{
if(getEpData(i))
{
//getEpData(i);

getJsonData(i);
sendtoMQTT(i); // Update data to MQTT server if we should
}
Expand Down
9 changes: 9 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion src/webpages/htmlCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const char HTML_HEAD[] PROGMEM = R"rawliteral(

const char HTML_FOOT[] PROGMEM = R"rawliteral(
<figure class="text-center">
EPEver to MQTT V0.2.2 By <a href="https://github.com/softwarecrash/" target="_blank">Softwarecrash</a>
EPEver to MQTT V0.2.3 By <a href="https://github.com/softwarecrash/" target="_blank">Softwarecrash</a>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png" /></a>
</figure>
</div>
Expand Down

0 comments on commit 49536ba

Please sign in to comment.