diff --git a/src/InfluxDBModule.cpp b/src/InfluxDBModule.cpp index 88cea22..92e291f 100644 --- a/src/InfluxDBModule.cpp +++ b/src/InfluxDBModule.cpp @@ -8,7 +8,7 @@ bool InfluxDBModule::connectToInfluxDB() { return client.validateConnection(); } -bool InfluxDBModule::sendData(float current, float busVoltage, float power, float avgPower, float totalEnergy, int relay1State, int relay2State) { +bool InfluxDBModule::sendData(float current, float busVoltage, float power, float avgPower, float totalEnergy, int relay1State, int relay2State, int relay3State, int relay4State) { Point sensorData("sensor_data"); sensorData.addTag("device", "ESP32"); sensorData.addField("current", current); @@ -18,6 +18,8 @@ bool InfluxDBModule::sendData(float current, float busVoltage, float power, floa sensorData.addField("totalEnergy", totalEnergy); sensorData.addField("relay1StateINT", relay1State); sensorData.addField("relay2StateINT", relay2State); + sensorData.addField("relay3StateINT", relay3State); + sensorData.addField("relay4StateINT", relay4State); return client.writePoint(sensorData); } \ No newline at end of file diff --git a/src/InfluxDBModule.h b/src/InfluxDBModule.h index 0c028b7..2154968 100644 --- a/src/InfluxDBModule.h +++ b/src/InfluxDBModule.h @@ -9,7 +9,7 @@ class InfluxDBModule { public: InfluxDBModule(String url, String org, String bucket, String token); bool connectToInfluxDB(); - bool sendData(float current, float busVoltage, float power, float avgPower, float totalEnergy, int relay1State, int relay2State); + bool sendData(float current, float busVoltage, float power, float avgPower, float totalEnergy, int relay1State, int relay2State, int relay3State, int relay4State); private: InfluxDBClient client; }; diff --git a/src/WebServerModule.h b/src/WebServerModule.h index 955ca54..1f03bbd 100644 --- a/src/WebServerModule.h +++ b/src/WebServerModule.h @@ -31,7 +31,7 @@ private: bool fourthRelayState; int _relayPin; int _secondRelayPin; - int _thirdrelayPin; + int _thirdRelayPin; int _fourthRelayPin; void handleRoot(AsyncWebServerRequest *request); diff --git a/src/WebserverModule.cpp b/src/WebserverModule.cpp index d24612a..44a4268 100644 --- a/src/WebserverModule.cpp +++ b/src/WebserverModule.cpp @@ -3,14 +3,14 @@ WebServerModule::WebServerModule(INA219Module& inaModule, int relayPin, int secondRelayPin, int thirdRelayPin, int fourthRelayPin) : _inaModule(inaModule), _server(80), _relayPin(relayPin), _secondRelayPin(secondRelayPin), - _thirdrelayPin(thirdRelayPin), _fourthRelayPin(fourthRelayPin), relayState(false), secondRelayState(false), + _thirdRelayPin(thirdRelayPin), _fourthRelayPin(fourthRelayPin), relayState(false), secondRelayState(false), thirdrelayState(false), fourthRelayState(false) {} void WebServerModule::begin() { // Configure pins for relays as outputs pinMode(_relayPin, OUTPUT); pinMode(_secondRelayPin, OUTPUT); - pinMode(_thirdrelayPin, OUTPUT); + pinMode(_thirdRelayPin, OUTPUT); pinMode(_fourthRelayPin, OUTPUT); // Configure server endpoints @@ -108,48 +108,74 @@ void WebServerModule::handleRoot(AsyncWebServerRequest *request) { html += "

Leistung: W

"; html += "

Durchschnittliche Leistung: W

"; html += "

Gesamtenergie: Wh

"; - // JavaScript-Code für die Werteaktualisierung und Schaltersteuerung (unchanged) - html += ""; + + // JavaScript-Code für die Werteaktualisierung und Schaltersteuerung + html += ""; - // Schalter 1 (K1) to Schalter 4 (K4) (unchanged) + + + // Schalter 1 (K1) html += "
"; html += ""; html += ""; html += "
"; + + // Schalter 2 (K2) html += "
"; html += ""; html += ""; html += "
"; + + // Schalter 3 (K3) html += "
"; html += ""; html += ""; html += "
"; + + // Schalter 4 (K4) html += "
"; html += ""; html += ""; html += "
"; + // JavaScript-Code für die Schaltersteuerung (unchanged) html += "