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

@@ -542,7 +542,7 @@ if ($type == "db_table_stats") {
$fileSizeMB = round($fileSizeBytes / (1024 * 1024), 2);
// Sensor data tables to inspect
$tables = ['data_NPM', 'data_NPM_5channels', 'data_BME280', 'data_envea', 'data_WIND', 'data_MPPT', 'data_NOISE'];
$tables = ['data_NPM', 'data_NPM_5channels', 'data_BME280', 'data_envea', 'data_WIND', 'data_MPPT', 'data_NOISE', 'data_MHZ19'];
$tableStats = [];
foreach ($tables as $tableName) {
@@ -589,7 +589,7 @@ if ($type == "download_full_table") {
$table = $_GET['table'] ?? '';
// Whitelist of allowed tables
$allowedTables = ['data_NPM', 'data_NPM_5channels', 'data_BME280', 'data_envea', 'data_WIND', 'data_MPPT', 'data_NOISE'];
$allowedTables = ['data_NPM', 'data_NPM_5channels', 'data_BME280', 'data_envea', 'data_WIND', 'data_MPPT', 'data_NOISE', 'data_MHZ19'];
if (!in_array($table, $allowedTables)) {
header('Content-Type: application/json');
@@ -605,7 +605,8 @@ if ($type == "download_full_table") {
'data_envea' => 'TimestampUTC,NO2,H2S,NH3,CO,O3,SO2',
'data_WIND' => 'TimestampUTC,Wind_speed_kmh,Wind_direction_V',
'data_MPPT' => 'TimestampUTC,Battery_voltage,Battery_current,Solar_voltage,Solar_power,Charger_status',
'data_NOISE' => 'TimestampUTC,Current_LEQ,DB_A_value'
'data_NOISE' => 'TimestampUTC,Current_LEQ,DB_A_value',
'data_MHZ19' => 'TimestampUTC,CO2_ppm'
];
try {
@@ -741,6 +742,12 @@ if ($type == "BME280") {
echo $output;
}
if ($type == "mhz19") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/MH-Z19/get_data.py ttyAMA4';
$output = shell_exec($command);
echo $output;
}
if ($type == "table_mesure") {
$table=$_GET['table'];
@@ -1276,6 +1283,10 @@ if ($type == "get_systemd_services") {
'description' => 'Get Data from noise sensor',
'frequency' => 'Every minute'
],
'nebuleair-mhz19-data.timer' => [
'description' => 'Reads CO2 concentration from MH-Z19 sensor',
'frequency' => 'Every 2 minutes'
],
'nebuleair-db-cleanup-data.timer' => [
'description' => 'Cleans up old data from database',
'frequency' => 'Daily'
@@ -1341,6 +1352,7 @@ if ($type == "restart_systemd_service") {
'nebuleair-sara-data.timer',
'nebuleair-bme280-data.timer',
'nebuleair-mppt-data.timer',
'nebuleair-mhz19-data.timer',
'nebuleair-db-cleanup-data.timer'
];
@@ -1401,6 +1413,7 @@ if ($type == "toggle_systemd_service") {
'nebuleair-sara-data.timer',
'nebuleair-bme280-data.timer',
'nebuleair-mppt-data.timer',
'nebuleair-mhz19-data.timer',
'nebuleair-db-cleanup-data.timer'
];