![[Imagen: nodemcu.jpg]](http://chujalt.com/1/imagenes/nodemcu.jpg)
![[Imagen: sensoragua.jpg]](http://chujalt.com/1/imagenes/sensoragua.jpg)
<?php
    // this refreshes current page after 5 seconds.
    header( "refresh:5;" );
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Sensor agua</title>
<style>
.normal
    {
        background: green;
        color: yellow;
        border-radius: 1em;
        padding: 1em;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-right: -50%;
        transform: translate(-50%, -50%);
        text-align:center
    }
.anormal
    {
        background: red;
        color: yellow;
        border-radius: 1em;
        padding: 1em;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-right: -50%;
        transform: translate(-50%, -50%);
        text-align:center
    }
</style>
</head>
<body>
<?
$url = 'http://192.168.1.222';
$content = file_get_contents($url);
$doc = new DOMDocument();
$doc->loadHtml($content);
$contenido = explode("\n", trim($doc->getElementById('nivel')->nodeValue))[0];
if ($contenido < 200)
{
echo"<div class='normal'>";
echo"En estos momentos no ocurre nada.<br/>TODO CORRECTO";
echo"</div>";
}
else
{
echo"<div class='anormal'>";
echo"ATENCION.... ATENCION.... ALARMA..... ALARMA<br/>La cosa no va bien";
echo"</div>";
} 
?>
</body>
</html> 
![[Imagen: aguabien.png]](http://chujalt.com/1/imagenes/aguabien.png)
![[Imagen: aguamal.png]](http://chujalt.com/1/imagenes/aguamal.png)
#include <ESP8266WiFi.h>
 const char* ssid = "Tu_ssid";
const char* password = "Tu_contraseña";
IPAddress ip(192,168,1,222);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
const int analogInPin = A0; 
int sensorValue = 0;
WiFiServer server(80);
void setup() {
 WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);
  server.begin(); 
}
void loop() {
 WiFiClient client = server.available();
  if (!client) {
    return;
  }
  while(!client.available()){
    delay(1);
  }
  String request = client.readStringUntil('\r');
  client.flush();
client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("");
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.print("<body>");  
   client.print("<div id='nivel'>");
  client.print(analogRead(analogInPin));
   client.print("</div>");
  client.println("</body>");
  client.println("</html>");
 
  delay(1);
}