# Hello
#include <ESP8266WiFi.h>
const char* ssid = ""; const char* password = ""; const int sensorPin = A0;
WiFiServer server(80);
void setup() {
Serial.begin(9600);
Serial.println(); Serial.print("Connecting to "); Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println(""); Serial.println("WiFi connected");
// Start the server server.begin(); Serial.println("Server started");
// Print the IP address Serial.print("Use this URL to connect: "); Serial.print("http://"); Serial.print(WiFi.localIP()); Serial.println("/");
}
void loop() { WiFiClient client = server.available(); if (!client) { return; }
// Read the first line of the request String request = client.readStringUntil('\r'); Serial.println(request); client.flush();
int sensorVal = analogRead(sensorPin); Serial.print("Sensor value: "); Serial.print(sensorVal);
float voltage = (sensorVal / 1024.0) * 3.3; Serial.print(", Volts: "); Serial.print(voltage); Serial.print(", degrees C: ");
float temperature = (voltage - .5) * 100;
Serial.println(temperature);
// Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println(""); client.println(""); client.print("degrees C: "); client.print(temperature); client.println(""); }