From afc90624b7f1ed4220e443472a5543746f00c694 Mon Sep 17 00:00:00 2001 From: Beagle User Date: Wed, 28 May 2025 13:34:34 +0000 Subject: [PATCH] Upload the folders of the code for get data from the sensors and the frontend and backend of the web page --- 7-my-htu21d-driver | 1 + 8-react-ui-sensors/HTU21D | Bin 0 -> 8896 bytes 8-react-ui-sensors/data/HTU21D.json | 1 + 8-react-ui-sensors/data/test.json | 0 8-react-ui-sensors/ui/BH1750.json | 1 + 8-react-ui-sensors/ui/HTU21D.json | 1 + 8-react-ui-sensors/ui/directions.txt | 55 ++++++++++++++++++++ 8-react-ui-sensors/ui/index.html | 32 ++++++++++++ 8-react-ui-sensors/ui/index.js | 21 ++++++++ 8-react-ui-sensors/ui/style.css | 74 +++++++++++++++++++++++++++ 10 files changed, 186 insertions(+) create mode 160000 7-my-htu21d-driver create mode 100755 8-react-ui-sensors/HTU21D create mode 100644 8-react-ui-sensors/data/HTU21D.json create mode 100644 8-react-ui-sensors/data/test.json create mode 100644 8-react-ui-sensors/ui/BH1750.json create mode 100644 8-react-ui-sensors/ui/HTU21D.json create mode 100644 8-react-ui-sensors/ui/directions.txt create mode 100644 8-react-ui-sensors/ui/index.html create mode 100644 8-react-ui-sensors/ui/index.js create mode 100644 8-react-ui-sensors/ui/style.css 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 0000000000000000000000000000000000000000..feac63784eefef5e39170c573c4d4e2dbe3eb55b GIT binary patch literal 8896 zcmeHNYiwM_6`tL7V#hd%^B|Z!(2Zjt754f;fDoXylg&C0JK7aHbl9gSAivD# z9ayKtn|&VldDiFWgCCDg(M668vx&T1h|9_0IYEw%Rs}u}cGcwA3vFKdH5@7%+I48g&@Dq1Baa`tp%R_{%`LB2|Mu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L#R(Zg4NBctT6~(BkH@BAm{6ZWs|G+})qV zcfe%a&uUw_w!w3Hh14aSd_sid18MkE+{-D=m2NK2Z#vS<2R3v$H${6TWK*69%aIFv zZUHj)7gQO!u)=K@c7`z}@q!4u3AMSDx!PCCT+49k^d)1cFat-*0T!kRV^{NrO-Of+ z=jD>!{T^b#=TCfJ=8=GpCBBD|z}|9Mwni zD?ofFrybu5N%fF*z04c{&r2pNwvS!M@pNSlDQKR|geu-&&? z2|k2O(l*Gnb-h3F?KmzxcaZ7`{G{#f1BSos_2A~;Axtl^dq~;I@#8s{q=HDZX`FUW{H~aqzh~pyb z<$}UuO9AV|I!S*8X*-_(Qm~tB{N92c^XZT0BoB6GKj?$$A0Wz21W2?yRf+PKI?@Lq z_{z#m{M-S%(=`Cs{>Y7K63@b}6%FD3|0alSK$cv~vagVtsu2tp8x7R{cs4fenipX$ JYbA7A{5NGcoiP9a literal 0 HcmV?d00001 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 { + +}