Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
IoT Based Small Extension Board
Just Do Electronics
May 19, 2020
IoT Based Small Extension Board
Circuit Diagram :-
Local Page :-
Code :-
//Prateek //www.prateeks.in #include
#include
#include
#include
#include
const char* ssid = "justDo"; const char* password = "pratik123"; const char* PARAM_INPUT_1 = "state"; const char* PARAM_INPUT_2 = "value"; const int output = 5; String timerSliderValue = "20"; AsyncWebServer server(80); const char index_html[] PROGMEM = R"rawliteral(
ESP Web Server
ESP Web Server
%TIMERVALUE%
s
%BUTTONPLACEHOLDER% )rawliteral"; // Replaces placeholder with button section in your web page String processor(const String& var){ //Serial.println(var); if(var == "BUTTONPLACEHOLDER"){ String buttons = ""; String outputStateValue = outputState(); buttons+= "
"; return buttons; } else if(var == "TIMERVALUE"){ return timerSliderValue; } return String(); } String outputState(){ if(digitalRead(output)){ return "checked"; } else { return ""; } return ""; } void setup(){ // Serial port for debugging purposes Serial.begin(115200); pinMode(output, OUTPUT); digitalWrite(output, LOW); // Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } // Print ESP Local IP Address Serial.println(WiFi.localIP()); // Route for root / web page server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", index_html, processor); }); // Send a GET request to
/update?state=
server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessage; // GET input1 value on
/update?state=
if (request->hasParam(PARAM_INPUT_1)) { inputMessage = request->getParam(PARAM_INPUT_1)->value(); digitalWrite(output, inputMessage.toInt()); } else { inputMessage = "No message sent"; } Serial.println(inputMessage); request->send(200, "text/plain", "OK"); }); // Send a GET request to
/slider?value=
server.on("/slider", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessage; // GET input1 value on
/slider?value=
if (request->hasParam(PARAM_INPUT_2)) { inputMessage = request->getParam(PARAM_INPUT_2)->value(); timerSliderValue = inputMessage; } else { inputMessage = "No message sent"; } Serial.println(inputMessage); request->send(200, "text/plain", "OK"); }); // Start server server.begin(); } void loop() { }
1 Comments
Anonymous
21 October 2024 at 07:37
Can I set it for 2hours
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer
Older
ESP32 Interfacing With LDR Sensor
ESP32 Led Blink With Push Button
IoT Based Patient Health Monitoring System Using Blynk App
Ultrasonic Sensor as a Counter with Arduino
Esp32 Cam Based Face Unlock
MLX90614 Non-Contact Infrared Thermometer With Arduino
Measure CO2 Level in Air Using Arduino
Sign Language to Speech Conversion using Arduino With Flex Sensor
ESP32 Interfacing Potentiometer
How to Make a Conveyor Belt System | Counter Machine
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
1 Comments
Can I set it for 2hours
ReplyDelete