Remover archivos para interfaz web
parent
fb6c1efba4
commit
c8bdc5469b
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"ppm": 400
|
|
||||||
}
|
|
||||||
Binary file not shown.
@ -1,92 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="es">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Monitor de Calidad del Aire</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
text-align: center;
|
|
||||||
background-color: #f4f4f9;
|
|
||||||
padding-top: 50px;
|
|
||||||
}
|
|
||||||
.panel {
|
|
||||||
background-color: white;
|
|
||||||
border: 2px solid #ccc;
|
|
||||||
padding: 40px;
|
|
||||||
display: inline-block;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0px 4px 8px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
.valor {
|
|
||||||
font-size: 5em;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2c3e50;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.etiqueta {
|
|
||||||
font-size: 1.2em;
|
|
||||||
color: #7f8c8d;
|
|
||||||
}
|
|
||||||
/* Clases para cambiar el color según el nivel de CO2 */
|
|
||||||
.excelente { color: #27ae60; } /* Verde */
|
|
||||||
.regular { color: #f39c12; } /* Naranja */
|
|
||||||
.peligro { color: #e74c3c; } /* Rojo */
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="panel">
|
|
||||||
<h2>Monitoreo de CO₂ (MH-Z19B)</h2>
|
|
||||||
<div class="etiqueta">Concentración actual en el ambiente:</div>
|
|
||||||
|
|
||||||
<div class="valor" id="display_co2">-- ppm</div>
|
|
||||||
|
|
||||||
<div class="etiqueta" id="estado_aire">Calculando estado...</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
async function actualizarPantalla() {
|
|
||||||
try {
|
|
||||||
// 1. Ir a buscar el archivo JSON generado por el código en C
|
|
||||||
const respuesta = await fetch('MHZ19B/Data/MHZ19B.json?nocache=' + Date.now());
|
|
||||||
const datos = await respuesta.json();
|
|
||||||
|
|
||||||
// 2. Extraer el valor de ppm
|
|
||||||
const co2 = datos.ppm;
|
|
||||||
|
|
||||||
// 3. Obtener los elementos HTML
|
|
||||||
const display = document.getElementById('display_co2');
|
|
||||||
const estado = document.getElementById('estado_aire');
|
|
||||||
|
|
||||||
// 4. Actualizar el texto en pantalla
|
|
||||||
display.innerText = co2 + " ppm";
|
|
||||||
|
|
||||||
// 5. Lógica visual: Cambiar colores según la concentración (Estándares típicos)
|
|
||||||
if (co2 < 800) {
|
|
||||||
display.className = "valor excelente";
|
|
||||||
estado.innerText = "Estado: Excelente (Aire Fresco)";
|
|
||||||
} else if (co2 >= 800 && co2 <= 1500) {
|
|
||||||
display.className = "valor regular";
|
|
||||||
estado.innerText = "Estado: Regular (Ventilación recomendada)";
|
|
||||||
} else {
|
|
||||||
display.className = "valor peligro";
|
|
||||||
estado.innerText = "Estado: Peligro (Ventilar inmediatamente)";
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error de conexión:", error);
|
|
||||||
document.getElementById('estado_aire').innerText = "Error: Sensor desconectado";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ejecutar inmediatamente al abrir la página
|
|
||||||
actualizarPantalla();
|
|
||||||
|
|
||||||
// Repetir automáticamente cada 2 segundos
|
|
||||||
setInterval(actualizarPantalla, 2000);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue