-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp-data-c.php
95 lines (81 loc) · 2.67 KB
/
esp-data-c.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<!--
esp-data-c.php
This module is to be inserted into the /var/www/html directory stored on the Raspberry
Pi. Its purpose is to query data from Panel C's database and display it on an HTML
webpage.
Created by UCF Senior Design Spring 2022 - Summer 2022 Group 6
Released on June 30th, 2022
-->
<head>
<title>
Panel C Data
</title>
<script>
function autoRefresh() {
window.location = window.location.href;
}
setInterval('autoRefresh()', 400);
</script>
</head>
<?php
$servername = "localhost";
// REPLACE with your Database name
$dbname = "esp_data_c";
// REPLACE with Database user
$username = "root";
// REPLACE with Database user password
$password = "sdouc";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, sensor, location, value1, value2, value3, value4, value5, reading_time FROM SensorDataC ORDER BY id DESC";
echo '<table cellspacing="5" cellpadding="5">
<tr>
<td>ID</td>
<td>Sensor</td>
<td>Location</td>
<td>Temperature (°C)</td>
<td>Temperature (°F)</td>
<td>Irradiance (W/m^2)</td>
<td>Voltage (V)</td>
<td>Current (A)</td>
<td>Timestamp</td>
</tr>';
if ($result = $conn->query($sql)) {
while ($row = $result->fetch_assoc()) {
$row_id = $row["id"];
$row_sensor = $row["sensor"];
$row_location = $row["location"];
$row_value1 = $row["value1"];
$row_value2 = $row["value2"];
$row_value3 = $row["value3"];
$row_value4 = $row["value4"];
$row_value5 = $row["value5"];
$row_reading_time = $row["reading_time"];
// Uncomment to set timezone to - 1 hour (you can change 1 to any number)
//$row_reading_time = date("Y-m-d H:i:s", strtotime("$row_reading_time - 1 hours"));
// Uncomment to set timezone to + 4 hours (you can change 4 to any number)
//$row_reading_time = date("Y-m-d H:i:s", strtotime("$row_reading_time + 4 hours"));
echo '<tr>
<td>' . $row_id . '</td>
<td>' . $row_sensor . '</td>
<td>' . $row_location . '</td>
<td>' . $row_value1 . '</td>
<td>' . $row_value2 . '</td>
<td>' . $row_value3 . '</td>
<td>' . $row_value4 . '</td>
<td>' . $row_value5 . '</td>
<td>' . $row_reading_time . '</td>
</tr>';
}
$result->free();
}
$conn->close();
?>
</table>
</body>
</html>