Difference between revisions of "Note to mitul(eastern)"
From Wiki2
(Created page with "===notes on esp8266=== Hi Mitul, My best esp8266 code is in https://github.com/mckennatim/demiot. A couple of notes on it. You can always get it online by hard coding your S...") |
|||
| Line 6: | Line 6: | ||
You can always get it online by hard coding your SSID info ala... | You can always get it online by hard coding your SSID info ala... | ||
#include <ESP8266WiFi.h> | |||
#include <ESP8266WebServer.h> | |||
const char *ssid = "street_no_vale2"; | |||
const char *pwd = "jjjjjjjj"; | |||
ESP8266WebServer server(80); | |||
void handleRoot() { | |||
server.send(200, "text/html", "<h1>root of espAPsb AP server</h1>"); | |||
} | |||
void getOnline(){ | |||
WiFi.begin(ssid, pwd); | |||
int tries =0; | |||
int success=1; | |||
while (WiFi.status() != WL_CONNECTED ) { | |||
delay(500); | |||
Serial.print("."); | |||
tries++; | |||
if (tries==15){ | |||
success=0; | |||
scan(); | |||
setupAP(); | |||
break; | |||
} | |||
} | |||
if (success){ | |||
Serial.println(""); | |||
Serial.println("WiFi connected"); | |||
Serial.print("IP address: "); | |||
Serial.println(WiFi.localIP()); | |||
} | |||
} | |||
void setup(){ | |||
Serial.begin(115200); | |||
Serial.println(); | |||
Serial.println("--------------------------"); | |||
Serial.println("ESP8266 webconfig"); | |||
Serial.println("--------------------------"); | |||
getOnline(); | |||
} | |||
void loop(){ | |||
server.handleClient(); | |||
} | |||
Revision as of 08:53, 5 May 2016
notes on esp8266
Hi Mitul,
My best esp8266 code is in https://github.com/mckennatim/demiot. A couple of notes on it.
You can always get it online by hard coding your SSID info ala...
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char *ssid = "street_no_vale2";
const char *pwd = "jjjjjjjj";
ESP8266WebServer server(80);
void handleRoot() {
server.send(200, "text/html", "
root of espAPsb AP server
");
}
void getOnline(){
WiFi.begin(ssid, pwd);
int tries =0;
int success=1;
while (WiFi.status() != WL_CONNECTED ) {
delay(500);
Serial.print(".");
tries++;
if (tries==15){
success=0;
scan();
setupAP();
break;
}
}
if (success){
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
}
void setup(){
Serial.begin(115200);
Serial.println();
Serial.println("--------------------------");
Serial.println("ESP8266 webconfig");
Serial.println("--------------------------");
getOnline();
}
void loop(){
server.handleClient();
}