You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
860 B
JavaScript

function updateBMP180() {
fetch('BMP180.json')
.then(res => res.json())
.then(data => {
document.getElementById('temperature').textContent = `Temperature: ${data.temperature.toFixed(2)} °C`;
document.getElementById('pressure').textContent = `Pressure: ${data.pressure.toFixed(2)} hPa`;
})
.catch(err => console.error("Error BMP180:", err));
}
function updateHTU21D() {
fetch('HTU21D.json')
.then(res => res.json())
.then(data => {
document.getElementById('humidity').textContent = `Humidity: ${data.humidity.toFixed(1)} %`;
document.getElementById('tempHTU').textContent = `Temperature: ${data.temperature.toFixed(1)} °C`;
})
.catch(err => console.error("Error HTU21D:", err));
}
setInterval(() => {
updateBMP180();
updateHTU21D();
}, 3000);
// Carga inicial
updateBMP180();
updateHTU21D();