diff --git a/html/launcher.php b/html/launcher.php index e862de0..d77cbd2 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -177,6 +177,12 @@ if ($type == "npm") { echo $output; } +if ($type == "mhz19") { + $command = '/usr/bin/python3 /var/www/moduleair_pro_4g/MH-Z19/get_data.py ttyAMA4'; + $output = shell_exec($command); + echo $output; +} + if ($type == "envea") { $port=$_GET['port']; $name=$_GET['name']; diff --git a/html/sensors.html b/html/sensors.html index 695e263..eadfeec 100755 --- a/html/sensors.html +++ b/html/sensors.html @@ -213,7 +213,48 @@ function getNoise_values(){ } }); } + + + function getco2_values() { + console.log("Data from UART 4:"); + $("#loading_co2").show(); + + $.ajax({ + url: 'launcher.php?type=mhz19', + dataType: 'JSON', + method: 'GET', + success: function(data) { // No need to parse JSON manually + console.log(data); // Debugging: Check if data is received correctly + + const tableBody = document.getElementById("data-table-body_co2"); + tableBody.innerHTML = ""; // Clear previous data + $("#loading_co2").hide(); + + // Ensure "CO2" exists in the response + if (data.hasOwnProperty("CO2")) { + const value = data["CO2"]; + const unit = "ppm"; // CO2 is always in ppm + + // Append the data row to the table + $("#data-table-body_co2").append(` +
Capteur gas.
- - -Capteur de Dioxyde de carbone
+ +