v1.11.0: CCS811 en daemon + fix filtrage + I2C 10kHz requis

Vérif terrain sur pro100 : à 100 kHz le CCS811 renvoie des valeurs corrompues
0x8000 (32768) par clock-stretching, et le modèle oneshot-reset-toutes-les-10s
ne donne que le 1er échantillon post-init (garbage). Refonte :

- CCS811/daemon.py: service long-running (Type=simple, Restart=always). Init 1x,
  boucle lecture/écriture 10s, filtre eCO2 dans [400,8192], re-init auto sur
  erreurs I2C répétées. Remplace write_data.py (supprimé).
- CCS811/get_data.py: lit la dernière ligne data_CCS811 au lieu du capteur
  (évite la collision I2C avec le daemon -> corruption observée).
- setup_services.sh: service daemon + self-heal suppression de l'ancien .timer;
  activation hors boucle timers.
- launcher.php: .timer -> .service (map statut + allowedServices x2).
- update_firmware.sh: redémarre le daemon à l'OTA.
- doc: README (archi daemon + I2C 10kHz confirmé requis), CLAUDE.md, changelog.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-06-02 16:08:03 +02:00
parent 46c73acb7e
commit 13c266d694
10 changed files with 240 additions and 211 deletions

View File

@@ -269,15 +269,19 @@ AccuracySec=1s
WantedBy=timers.target
EOL
# Create service and timer files for CCS811 air-quality (eCO2/TVOC) Data
# CCS811 air-quality (eCO2/TVOC) — long-running DAEMON, not a oneshot timer.
# The CCS811 must be initialised once and read continuously (a 10s reset cycle
# yields garbage right after each init and never lets its baseline build up).
cat > /etc/systemd/system/nebuleair-ccs811-data.service << 'EOL'
[Unit]
Description=NebuleAir CCS811 Air-Quality (eCO2/TVOC) Data Collection Service
Description=NebuleAir CCS811 Air-Quality (eCO2/TVOC) Daemon
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/CCS811/write_data.py
Type=simple
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/CCS811/daemon.py
Restart=always
RestartSec=10
User=root
WorkingDirectory=/var/www/nebuleair_pro_4g
StandardOutput=append:/var/www/nebuleair_pro_4g/logs/ccs811_service.log
@@ -287,19 +291,13 @@ StandardError=append:/var/www/nebuleair_pro_4g/logs/ccs811_service_errors.log
WantedBy=multi-user.target
EOL
cat > /etc/systemd/system/nebuleair-ccs811-data.timer << 'EOL'
[Unit]
Description=Run NebuleAir CCS811 Air-Quality Data Collection every 10 seconds
Requires=nebuleair-ccs811-data.service
[Timer]
OnBootSec=10s
OnUnitActiveSec=10s
AccuracySec=1s
[Install]
WantedBy=timers.target
EOL
# Self-heal: remove the obsolete oneshot timer from CCS811 v1.10.x (now a daemon).
if [ -f /etc/systemd/system/nebuleair-ccs811-data.timer ]; then
systemctl stop nebuleair-ccs811-data.timer 2>/dev/null
systemctl disable nebuleair-ccs811-data.timer 2>/dev/null
rm -f /etc/systemd/system/nebuleair-ccs811-data.timer
echo "Removed obsolete nebuleair-ccs811-data.timer (CCS811 is now a daemon)"
fi
# Create service and timer files for Database Cleanup
cat > /etc/systemd/system/nebuleair-db-cleanup-data.service << 'EOL'
@@ -434,12 +432,18 @@ systemctl daemon-reload
# Enable and start all timers
echo "Enabling and starting all services..."
for service in npm envea sara bme280 mppt mhz19 s88 ccs811 db-cleanup noise; do
for service in npm envea sara bme280 mppt mhz19 s88 db-cleanup noise; do
systemctl enable nebuleair-$service-data.timer
systemctl start nebuleair-$service-data.timer
echo "Started nebuleair-$service-data timer"
done
# CCS811 is a long-running daemon (service, not timer)
systemctl daemon-reload
systemctl enable nebuleair-ccs811-data.service
systemctl restart nebuleair-ccs811-data.service
echo "Started nebuleair-ccs811-data service (daemon)"
# Enable and start WiFi power save timer (separate naming convention)
systemctl enable nebuleair-wifi-powersave.timer
systemctl start nebuleair-wifi-powersave.timer