温度传感器测试

silas 发布于 2025-12-27 738 次阅读 试验与杂记


温湿度监测

室内温度: --

室内湿度: --

室外温度: --

室外湿度: --

舒适度: --

async function fetchData(){ try{ const res = await fetch('http://192.168.0.72:5000/latest'); const data = await res.json(); document.getElementById("inTemp").innerText = "室内温度: " + data.indoorT + "°C"; document.getElementById("inHum").innerText = "室内湿度: " + data.indoorH + "%"; document.getElementById("outTemp").innerText = "室外温度: " + data.outdoorT + "°C"; document.getElementById("outHum").innerText = "室外湿度: " + data.outdoorH + "%"; let comfort = "未知"; if(data.indoorT>=20 && data.indoorT=40 && data.indoorH<=60){ comfort = "舒适 :)"; } else if(data.indoorT<20 || data.indoorH26 || data.indoorH>60){ comfort = "热湿 :("; } else { comfort = "一般 :/"; } document.getElementById("comfort").innerText = "舒适度: " + comfort; }catch(e){ console.log("Error:",e); } } setInterval(fetchData,5000); // 每5秒刷新 fetchData();
此作者没有提供个人介绍。
最后更新于 2026-11-13