// Stand Alone Offline AP Controller #1 #include String ssid="ESP02"; String password="abcdefgh"; WiFiServer server(80); //------------------------------ void setup() { //------------------------------ Serial.begin(115200); WiFi.softAP(ssid, password); IPAddress espIP = WiFi.softAPIP(); Serial.println(""); Serial.println("SSID: "+ssid); Serial.println("Password: "+password); Serial.print("IP address: "); Serial.println(espIP); server.begin(); Serial.println("ESP-01 Web Server ready..."); Serial.println(); //Setting pins 1 or 3 for output will disable the // Serial Monitor pinMode(0, OUTPUT); pinMode(2, OUTPUT); //pinMode(1, OUTPUT); //pinMode(3, OUTPUT); digitalWrite(0, LOW); digitalWrite(2, LOW); //digitalWrite(1, LOW); //digitalWrite(3, LOW); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) {return;} // Read the first line of GET containing request command String request = client.readStringUntil('\r'); client.flush(); // Check command string and perform request int value; if (request.indexOf("/gpio0/0") != -1){ digitalWrite(0, LOW); value = LOW; Serial.println("GP0 set to 0"); } if (request.indexOf("/gpio0/1") != -1) { digitalWrite(0, HIGH); value = HIGH; Serial.println("GP0 set to 1"); } if (request.indexOf("/gpio1/0") != -1){ digitalWrite(1, LOW); value = LOW; Serial.println("GP1 set to 0"); } if (request.indexOf("/gpio1/1") != -1) { digitalWrite(1, HIGH); value = HIGH; Serial.println("GP1 set to 1"); } if (request.indexOf("/gpio2/0") != -1){ digitalWrite(2, LOW); value = LOW; Serial.println("GP2 set to 0"); } if (request.indexOf("/gpio2/1") != -1) { digitalWrite(2, HIGH); value = HIGH; Serial.println("GP2 set to 1"); } if (request.indexOf("/gpio3/0") != -1){ digitalWrite(3, LOW); value = LOW; Serial.println("GP3 set to 0"); } if (request.indexOf("/gpio3/1") != -1) { digitalWrite(3, HIGH); value = HIGH; Serial.println("GP3 set to 1"); } //------------------------------ //ESP-01 Root Web Page //------------------------------ // Header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // header end marker client.println(""); client.println(""); client.println(""); client.println(""); // Content client.println("
"); client.println("

"+ssid+"

"); client.println("

"); client.println("Pin0 = "+String(digitalRead(0))+"
"); //client.println("Pin1 = "+String(digitalRead(1))+"
"); client.println("Pin2 = "+String(digitalRead(2))+"
"); //client.println("Pin3 = "+String(digitalRead(3))+"
"); client.println("

"); client.println("TURN ON 0
"); client.println("TURN OFF 0
"); client.println("
"); //client.println("TURN ON 1
"); //client.println("TURN OFF 1
"); //client.println("
"); client.println("TURN ON 2
"); client.println("TURN OFF 2
"); client.println("
"); //client.println("TURN ON 3
"); //client.println("TURN OFF 3
"); //client.println("
"); client.println("

"); client.println(""); delay(1); }