├── ESP8266_WiFiSmartConfigWebServer.ino └── README.md /ESP8266_WiFiSmartConfigWebServer.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | ESP8266WebServer server ( 80 ); 6 | 7 | void handleRoot(); 8 | void handleNotFound(); 9 | void drawGraph(); 10 | 11 | void setup() { 12 | 13 | Serial.begin(115200); 14 | delay(10); 15 | 16 | WiFi.mode(WIFI_STA); 17 | delay(500); 18 | 19 | WiFi.beginSmartConfig(); 20 | 21 | while(WiFi.status() != WL_CONNECTED) { 22 | delay(500); 23 | Serial.print("."); 24 | if(WiFi.smartConfigDone()){ 25 | Serial.println("WiFi Smart Config Done."); 26 | } 27 | } 28 | 29 | Serial.println(""); 30 | Serial.println(""); 31 | 32 | WiFi.printDiag(Serial); 33 | 34 | // Start the server 35 | server.on ( "/", handleRoot ); 36 | server.on ( "/test.svg", drawGraph ); 37 | server.on ( "/inline", []() { 38 | server.send ( 200, "text/plain", "this works as well" ); 39 | } ); 40 | server.onNotFound ( handleNotFound ); 41 | 42 | server.begin(); 43 | MDNS.addService("http", "tcp", 80); 44 | Serial.println ( "HTTP server started" ); 45 | //Serial.printf("Ready! Open http://%s/ in your browser\n", getLocalIPString().c_str()); 46 | 47 | 48 | // Print the IP address 49 | Serial.println(WiFi.localIP()); 50 | } 51 | 52 | void loop() { 53 | // Check if a client has connected 54 | server.handleClient(); 55 | yield(); 56 | } 57 | 58 | void handleRoot() { 59 | char temp[500]; 60 | int sec = millis() / 1000; 61 | int min = sec / 60; 62 | int hr = min / 60; 63 | char *html = R"##( 64 | 65 | 66 | 67 | ESP8266 Demo 68 | 71 | 72 | 73 |

Hello from ESP8266!

74 |

Inline

75 |

Uptime: %02d:%02d:%02d

76 | 77 | 78 | 79 | )##"; 80 | 81 | snprintf ( temp, 500, html, 82 | hr, min % 60, sec % 60 83 | ); 84 | server.send ( 200, "text/html", temp ); 85 | } 86 | 87 | void handleNotFound() { 88 | String message = "File Not Found\n\n"; 89 | message += "URI: "; 90 | message += server.uri(); 91 | message += "\nMethod: "; 92 | message += ( server.method() == HTTP_GET ) ? "GET" : "POST"; 93 | message += "\nArguments: "; 94 | message += server.args(); 95 | message += "\n"; 96 | 97 | for ( uint8_t i = 0; i < server.args(); i++ ) { 98 | message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n"; 99 | } 100 | 101 | server.send ( 404, "text/plain", message ); 102 | } 103 | 104 | void drawGraph() { 105 | String out = ""; 106 | char temp[100]; 107 | out += "\n"; 108 | out += "\n"; 109 | out += "\n"; 110 | int y = rand() % 130; 111 | for (int x = 10; x < 390; x+= 10) { 112 | int y2 = rand() % 130; 113 | sprintf(temp, "\n", x, 140 - y, x + 10, 140 - y2); 114 | out += temp; 115 | y = y2; 116 | } 117 | out += "\n\n"; 118 | 119 | server.send ( 200, "image/svg+xml", out); 120 | } 121 | 122 | 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP8266_WiFiSmartConfig 2 | ESP8266 WiFi SmartConfig Arduino Code using ESP-TOUCH Protocol 3 | 4 | - ESP-TOUCH Android App: https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch 5 | 6 | 7 | Espressif’s ESP-TOUCH protocol implements Smart Config technology to help users connect ESP8266EX-embedded devices to a Wi-Fi network through simple configuration on a smartphone. 8 | 9 | ![ESP-TOUCH Protocol](http://espressif.com/sites/default/files/styles/flexslider_full/public/screen_shot_2016-04-27_at_1.30.27_pm_0.png) 10 | --------------------------------------------------------------------------------