Commit 6a448f46 authored by B.Nagasuman's avatar B.Nagasuman

Add new file

parent c084190f
#include <ESP8266WiFi.h>
#include <dht.h>
dht DHT;
#define DHT11_PIN D5
const char* ssid = "vivo 1807";
const char* password = "pavansai";
WiFiServer server(80);
void setup()
{
wifi_connect();
Serial.begin(115200);
server.begin();
Serial.println("Web Server Started");
Serial.print("Connect to the Server:");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println();
Serial.println();
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
int STATUS;
DHT.read11(DHT11_PIN);
Serial.print(DHT.humidity,1);
Serial.print("/n");
Serial.print(DHT.temperature,1);
delay(1000);
client.flush();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<style>");
client.println("<head>");
client.println("<meta http-equiv=\"refresh\"content=\"3\"/>");
client.println("body {background-color: #8baee8;}");
client.println("</style>");
client.print("<h1><b>&nbsp tempearture and humidity STATUS </b></h1>");
client.println("<br><br><br>");
client.println("<meta http-equiv=\"refresh\"content=\"3\"/>");
client.println(DHT.temperature);
client.println(DHT.humidity);
client.println("</html>");
delay(3000);
}
void wifi_connect(void)
{
Serial.begin(115200);
delay(1000);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment