Si7021 example
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<title>Climate</title> | |
<script src="libs.js"></script> | |
<script> | |
function read_sensor() { | |
send_command("devices/si7021/read", | |
{"SDA": 12, "SCL":14, "address":"0x80"}, null, | |
function (err, res) { | |
if(err) { | |
document.getElementById("t").innerHTML = "ERROR: " + res; | |
document.getElementById("h").innerHTML = ""; | |
} else { | |
document.getElementById("t").innerHTML = res["temperature"].toFixed(2); | |
document.getElementById("h").innerHTML = res["humidity"].toFixed(2); | |
} | |
setTimeout(read_sensor, 1000); | |
}); | |
} | |
</script> | |
</head> | |
<body onload="read_sensor()"> | |
<div class="header"> | |
<a href="/"><div class="devecihive-logo-text"></div></a> | |
</div> | |
<div class="content"> | |
<h1> | |
<div style="display: inline-block; float: left"> | |
<div>Temperature:</div> | |
<div>Humidity:</div> | |
</div> | |
<div style="display: inline-block; padding-left: 20px"> | |
<div id="t"></div> | |
<div id="h"></div> | |
</div> | |
</h1> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment