-
-
Save Nikolay-Kha/a98697964748bcee9e57a18cb4cfc620 to your computer and use it in GitHub Desktop.
Si7021 example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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