feat: intégration capteur CO2 MH-Z19

- Scripts MH-Z19/get_data.py (lecture standalone) et write_data.py (écriture SQLite)
- Table data_MHZ19, config MHZ19, cleanup et service systemd (120s)
- Web UI : carte test sensors, checkbox admin, boutons database + CSV download
- SARA_send_data_v2.py non modifié (sera fait dans un second temps)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-02-17 11:04:45 +01:00
parent ea2642685c
commit 198836fa13
10 changed files with 264 additions and 7 deletions

View File

@@ -285,6 +285,36 @@ function getNoise_values(){
});
}
function getMHZ19_values(){
console.log("Data from MH-Z19 CO2 sensor:");
$("#loading_mhz19").show();
$.ajax({
url: 'launcher.php?type=mhz19',
dataType: 'json',
method: 'GET',
success: function(response) {
console.log(response);
const tableBody = document.getElementById("data-table-body_mhz19");
tableBody.innerHTML = "";
$("#loading_mhz19").hide();
if (response.CO2 !== undefined) {
$("#data-table-body_mhz19").append(`
<tr>
<td>CO2</td>
<td>${response.CO2} ppm</td>
</tr>
`);
}
},
error: function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
$("#loading_mhz19").hide();
}
});
}
function getBME280_values(){
console.log("Data from I2C BME280:");
$("#loading_BME280").show();
@@ -462,6 +492,29 @@ error: function(xhr, status, error) {
container.innerHTML += i2C_HTML; // Add the I2C card if condition is met
}
//creates MH-Z19 CO2 card
if (config.MHZ19) {
const MHZ19_HTML = `
<div class="col-sm-3">
<div class="card">
<div class="card-header">
Port UART 4
</div>
<div class="card-body">
<h5 class="card-title">MH-Z19 CO2</h5>
<p class="card-text">Capteur de dioxyde de carbone.</p>
<button class="btn btn-primary mb-1" onclick="getMHZ19_values()" data-i18n="common.getData">Get Data</button>
<div id="loading_mhz19" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
<table class="table table-striped-columns">
<tbody id="data-table-body_mhz19"></tbody>
</table>
</div>
</div>
</div>`;
container.innerHTML += MHZ19_HTML;
}
//Si on a des SONDES ENVEA connectée il faut faire un deuxième call dans la table envea_sondes_table
//creates ENVEA debug card
if (config.envea) {