Upload the folders of the code for get data from the sensors and the frontend and backend of the web page

main
Beagle User 1 week ago
commit afc90624b7

@ -0,0 +1 @@
Subproject commit 0a1401e9536e911aaae540bd741341568480bc27

Binary file not shown.

@ -0,0 +1 @@
{ "Temperature" : 25.1 , "Humidity" : 52.50 }

@ -0,0 +1 @@
{"Brightness" : 115.00 }

@ -0,0 +1 @@
{ "Temperature" : 35.4 , "Humidity" : 52.50 }

@ -0,0 +1,55 @@
Directions of service for continuos working
Command for the terminal to move the file to a more safe direction, where
"executable" is the name of the of the program executable in the folder
and "(/usr/ocal/bin/executable)" this are the new direction for the program
"sudo mv executable /usr/local/bin/executable"
After that we create the file of "systemd" with the next Command
"sudo nano /etc/systemd/system/sensor.service"
Now inside these file we put the next code:
[Unit]
Description=Servicio de lectura de sensores HTU21D y BH1750
After=network.target
[Service]
ExecStart=/usr/local/bin/sensor_logger -> changer sensor_logger to the name of the exutable file.
Restart=always
User=debian
WorkingDirectory=/home/debian
StandardOutput=file:/home/debian/sensor.log
StandardError=file:/home/debian/sensor_error.log
[Install]
WantedBy=multi-user.target
after that we allow the service with the next commands
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable sensor.service
sudo systemctl start sensor.service
At the end we check the status of the service with the next commands
sudo systemctl status sensor.service
To eliminate the service we need to enter the next commands
sudo systemctl stop sensor.service
sudo systemctl disable sensor.service
sudo rm /etc/systemd/system/sensor.service
sudo systemctl daemon-reload
in the case in which create files to see the logs enter the next commands
to eliminate the logs.
rm /home/debian/sensor.log
rm /home/debian/sensor_error.log
La dirección puede variaar dependiendo de la cual se haya puesto al principio
de desarrollo.

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Sensor DashBoard </title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="sensor-wrapper">
<div id="Temperature" class="container" >
<h1> HTU21D </h1>
<div class="sensor-title">Temperature</div>
<div class="sensor-value" id="Temp-Value">--</div>
</div>
<div id="Humidity" class="container" >
<h1> HTU21D </h1>
<div class="sensor-title">Humidity</div>
<div class="sensor-value" id="Hum-Value">--</div>
</div>
<div id="Brightness" class="container" >
<h1> BH1750 </h1>
<div class="sensor-title">Brightness</div>
<div class="sensor-value" id="Bright-Value">--</div>
</div>
<button onclick="location.reload()" class="reload-btn">Recargar datos</button>
</body>
<script src='index.js?ver=2'> </script>
</html>

@ -0,0 +1,21 @@
console.log("Hello World !!! ");
async function FetchData(){
try{
const tempResponse = await fetch('./HTU21D.json');
const tempData = await tempResponse.json();
document.getElementById('Temp-Value').textContent = tempData.Temperature.toFixed(1) + '°C';
const tempHumidity = await fetch('./HTU21D.json');
const tempHum = await tempHumidity.json();
document.getElementById('Hum-Value').textContent = tempHum.Humidity.toFixed(1) + '%';
const brightResponse = await fetch('./BH1750.json');
const brightData = await brightResponse.json();
document.getElementById('Bright-Value').textContent = brightData.Brightness.toFixed(1) + 'lux';
} catch (error){
console.log(error);
}
}
FetchData();

@ -0,0 +1,74 @@
body {
margin: 5;
font-family: Arial, sans-serif;
justify-content: center;
align-items: center;
background-color: #004C6D;
color: #121;
display: flex;
height: 400px;
}
.container {
background: white;
padding: 5px;
border-radius: 8px;
box-shadow: 15px 15px 25px rgba(0,0,0);
text-align: center;
width: 40%;
max-width: 240px;
}
h1 {
font-size: 22pt;
margin-bottom: 5px;
}
button {
margin-top: 5px;
font-size: 14pt;
padding: 8px 16px;
background: #007BFF;
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
}
.reload-btn{
display: block;
margin: 20px auto;
padding: 10px 20px;
font-size: 16px;
background-color: #007acc;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.reload-btn:hover {
background-color: #005fa3;
}
.sensor-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
margin-top: 250px;
}
.container {
background-color: white;
padding: 20px;
border-radius: 50px;
text-align: center;
box-shadow: 2px 2px 12px rgba(0,0,0,0.2);
width: 250px;
}
button:hover {
}
Loading…
Cancel
Save