/********* Rui Santos Complete project details at https://RandomNerdTutorials.com/esp32-relay-module-ac-web-server/ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Modification GL 01/2022 *********/ // Import required libraries #include "WiFi.h" #include "ESPAsyncWebServer.h" #include #include #include #include "configT.h" // Create AsyncWebServer object on port 80 AsyncWebServer server(80); #include "page_web001.h" // Replaces placeholder with button section in your web page String processor(const String& var){ //Serial.println(var); if(var == "BUTTONPLACEHOLDER"){ String buttons =""; for(int i=1; i<=NUM_RELAYS; i++){ String relayStateValue = relayState(i); buttons+= "

Relay #" + String(i) + " - GPIO " + relayGPIOs[i-1] + "

"; } return buttons; } return String(); } String relayState(int numRelay){ if(RELAY_NO){ if(digitalRead(relayGPIOs[numRelay-1])){ return ""; } else { return "checked"; } } else { if(digitalRead(relayGPIOs[numRelay-1])){ return "checked"; } else { return ""; } } return ""; } void setup(){ #include "setup_relais.h" void loop() { ArduinoOTA.handle(); delay(1000); }