commit afc90624b7f1ed4220e443472a5543746f00c694 Author: Beagle User Date: Wed May 28 13:34:34 2025 +0000 Upload the folders of the code for get data from the sensors and the frontend and backend of the web page diff --git a/7-my-htu21d-driver b/7-my-htu21d-driver new file mode 160000 index 0000000..0a1401e --- /dev/null +++ b/7-my-htu21d-driver @@ -0,0 +1 @@ +Subproject commit 0a1401e9536e911aaae540bd741341568480bc27 diff --git a/8-react-ui-sensors/HTU21D b/8-react-ui-sensors/HTU21D new file mode 100755 index 0000000..feac637 Binary files /dev/null and b/8-react-ui-sensors/HTU21D differ diff --git a/8-react-ui-sensors/data/HTU21D.json b/8-react-ui-sensors/data/HTU21D.json new file mode 100644 index 0000000..f7a3415 --- /dev/null +++ b/8-react-ui-sensors/data/HTU21D.json @@ -0,0 +1 @@ +{ "Temperature" : 25.1 , "Humidity" : 52.50 } diff --git a/8-react-ui-sensors/data/test.json b/8-react-ui-sensors/data/test.json new file mode 100644 index 0000000..e69de29 diff --git a/8-react-ui-sensors/ui/BH1750.json b/8-react-ui-sensors/ui/BH1750.json new file mode 100644 index 0000000..38df5cb --- /dev/null +++ b/8-react-ui-sensors/ui/BH1750.json @@ -0,0 +1 @@ +{"Brightness" : 115.00 } \ No newline at end of file diff --git a/8-react-ui-sensors/ui/HTU21D.json b/8-react-ui-sensors/ui/HTU21D.json new file mode 100644 index 0000000..47f8452 --- /dev/null +++ b/8-react-ui-sensors/ui/HTU21D.json @@ -0,0 +1 @@ +{ "Temperature" : 35.4 , "Humidity" : 52.50 } diff --git a/8-react-ui-sensors/ui/directions.txt b/8-react-ui-sensors/ui/directions.txt new file mode 100644 index 0000000..158f396 --- /dev/null +++ b/8-react-ui-sensors/ui/directions.txt @@ -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. \ No newline at end of file diff --git a/8-react-ui-sensors/ui/index.html b/8-react-ui-sensors/ui/index.html new file mode 100644 index 0000000..8a9ea8e --- /dev/null +++ b/8-react-ui-sensors/ui/index.html @@ -0,0 +1,32 @@ + + + + + + Sensor DashBoard + + + +
+
+

HTU21D

+
Temperature
+
--
+
+
+

HTU21D

+
Humidity
+
--
+
+
+

BH1750

+
Brightness
+
--
+
+ + + + + + + diff --git a/8-react-ui-sensors/ui/index.js b/8-react-ui-sensors/ui/index.js new file mode 100644 index 0000000..5dc6d44 --- /dev/null +++ b/8-react-ui-sensors/ui/index.js @@ -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(); diff --git a/8-react-ui-sensors/ui/style.css b/8-react-ui-sensors/ui/style.css new file mode 100644 index 0000000..88e6456 --- /dev/null +++ b/8-react-ui-sensors/ui/style.css @@ -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 { + +}