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() { }
0 Comments
Newer
Older
GSM + GPS Based Vehicle Location Tracking System
Smart Shopping Cart using RFID and NodeMCU
Build Your Own Gps Tracking System using Arduino
Sign Language to Speech Conversion using Arduino With Flex Sensor
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
RFID Based Automated Toll Collection System Using Arduino
Ultrasonic Sensor as a Counter with Arduino
Car Parking System Using Arduino
ESP32 And Fingerprint Sensor Based Biometric Door Lock Security System
Automatic Fan Controlled Using Temperature Sensor
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
0 Comments