Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ESP8266WiFi接続ショートコード
#include <ESP8266WiFi.h>
const char* ssid = "";
const char* password = "";
WiFiServer server(80);
WiFiClient client;
void setup()
{
Serial.begin(115200);
Serial.println("");
// Wifi接続開始
WiFi.begin(ssid, password);
Serial.print("Connecting Wifi");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Complete Connect Wifi!!");
server.begin();
Serial.println("Server started");
Serial.print("local IP : ");
Serial.println(WiFi.localIP());
}
void loop()
{
responseHelloworld();
delay(1);
}
void responseHelloworld()
{
client = server.available();
while(client)
{
if(client.available())
{
Serial.println("client.read");
Serial.println(client.read());
String result = "<html><body>Hello World!!</body></html>";
client.print(result);
delay(10);
client.stop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment