Skip to content

Instantly share code, notes, and snippets.

@Nikolay-Kha

Nikolay-Kha/index.html Secret

Last active Feb 27, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.