adds website for rpi
This commit is contained in:
70
web/index.html
Normal file
70
web/index.html
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<script src="https://cdn.plot.ly/plotly-latest.min.js" charset="utf-8"></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
<title>Climate-Measuring-Box</title>
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- Make a new header with a navigation bar -->
|
||||||
|
<header>
|
||||||
|
<nav class="navbar">
|
||||||
|
<ul>
|
||||||
|
<li><a href="climate-monitor.html">Monitoring</a></li>
|
||||||
|
<li><a href="Map.html">Map</a></li>
|
||||||
|
<li><a onclick="serialConnect()" class="navRight">Connect to port</a></li>
|
||||||
|
<li><a onclick="disconnect()" class="navRight">Disconnect from port</a></li>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Make a new flex container for the live data -->
|
||||||
|
<div class="flex-LiveData">
|
||||||
|
<div>
|
||||||
|
<div>Temperatuur: <p id="temperature">Not connected</p>
|
||||||
|
</div>
|
||||||
|
<div class="statusElement">
|
||||||
|
<p class="statusText" id="tempStatus">Not connected</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>Luchtvochtigheid: <p id="humidity">Not connected</p>
|
||||||
|
</div>
|
||||||
|
<div class="statusElement">
|
||||||
|
<p class="statusText" id="humidStatus">Not connected</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>Lichtintensiteit: <p id="lightIntensity">Not connected</p>
|
||||||
|
</div>
|
||||||
|
<div class="statusElement">
|
||||||
|
<p class="statusText" id="lightIntensityStatus">Not connected</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Make a new flexcontainer for the graphs and API request time -->
|
||||||
|
<div class="flex-graph">
|
||||||
|
<div>
|
||||||
|
<p>Live graph:</p>
|
||||||
|
<div id="liveGraph"></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>Time until POST request to API:<p id="cnt">Connect to port</p></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>API data:</p>
|
||||||
|
<div id="apiGraph"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Include the js file -->
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</body>
|
||||||
|
<html>
|
63
web/main.js
Normal file
63
web/main.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// Make lines in the graph of the live data
|
||||||
|
Plotly.plot("liveGraph", [
|
||||||
|
{
|
||||||
|
x: timeArray, // Use timeArray as x values
|
||||||
|
y: newArrayTemp,
|
||||||
|
mode: "lines",
|
||||||
|
line: { color: "#80CAF6" },
|
||||||
|
name: "Temperature",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: timeArray, // Use timeArray as x values
|
||||||
|
y: newArrayHumid,
|
||||||
|
mode: "lines",
|
||||||
|
line: { color: "#FFA500" },
|
||||||
|
name: "Humidity",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: timeArray, // Use timeArray as x values
|
||||||
|
y: newArrayLight,
|
||||||
|
mode: "lines",
|
||||||
|
line: { color: "#00FF00" },
|
||||||
|
name: "Light / 100",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
let cnt = 0;
|
||||||
|
|
||||||
|
// Update the graph every 1 ms
|
||||||
|
let interval = setInterval(function () {
|
||||||
|
var time = new Date();
|
||||||
|
|
||||||
|
var update = {
|
||||||
|
x: [[time]],
|
||||||
|
y: [[newArrayTemp], [newArrayHumid], [newArrayLight]],
|
||||||
|
};
|
||||||
|
|
||||||
|
var olderTime = time.setMinutes(time.getMinutes() - 1);
|
||||||
|
var futureTime = time.setMinutes(time.getMinutes() + 1);
|
||||||
|
|
||||||
|
var minuteView = {
|
||||||
|
xaxis: {
|
||||||
|
type: "date",
|
||||||
|
range: [olderTime, futureTime],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Plotly.relayout("liveGraph", minuteView);
|
||||||
|
|
||||||
|
apiGraph = document.getElementById("apiGraph");
|
||||||
|
Plotly.newPlot(
|
||||||
|
apiGraph,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
x: dateArray,
|
||||||
|
y: valueArray,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{
|
||||||
|
margin: { t: 0 },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cnt === 100) clearInterval(interval);
|
||||||
|
}, 1);
|
128
web/styles.css
Normal file
128
web/styles.css
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
body {
|
||||||
|
background-color: white;
|
||||||
|
align-content: center;
|
||||||
|
text-align: center;
|
||||||
|
font-family: "inter", sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
opacity: 0.8;
|
||||||
|
color: black;
|
||||||
|
margin: auto;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
color: black;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
p1 {
|
||||||
|
color: solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.liveGraph{
|
||||||
|
width: 90%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.divCnt{
|
||||||
|
text-align: begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apiGraph{
|
||||||
|
height: 100%;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusElement{
|
||||||
|
display:inline-block;
|
||||||
|
border: solid #1f82d3 2px;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusText{
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-LiveData {
|
||||||
|
display: flex;
|
||||||
|
align-content: begin;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-LiveData > div {
|
||||||
|
border: solid #1f82d3 2px;
|
||||||
|
padding: 15px 0;
|
||||||
|
font-size: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
height: fit-content;
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-graph {
|
||||||
|
display: flex;
|
||||||
|
align-content: begin;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-graph > div {
|
||||||
|
position: relative;
|
||||||
|
border: solid #1f82d3 2px;
|
||||||
|
padding: 15px 0;
|
||||||
|
font-size: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
flex-basis: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 850px) {
|
||||||
|
.flex-LiveData>div {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
a{
|
||||||
|
padding: 10px;
|
||||||
|
color: black;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
li{
|
||||||
|
display: inline-block;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 0 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
.navbar a:hover {
|
||||||
|
background-color: #196bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user