- Nouveau script sound_meter/read.py pour lecture à la demande (JSON) - launcher.php: appel du script Python au lieu de l'ancien binaire C - sensors.html: carte USB, suppression boutons start/stop, affichage JSON - Traductions fr/en: I2C → USB, NSRT MK4 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
849 B
Python
35 lines
849 B
Python
'''
|
|
____ ___ _ _ _ _ ____
|
|
/ ___| / _ \| | | | \ | | _ \
|
|
\___ \| | | | | | | \| | | | |
|
|
___) | |_| | |_| | |\ | |_| |
|
|
|____/ \___/ \___/|_| \_|____/
|
|
|
|
python3 /var/www/nebuleair_pro_4g/sound_meter/read.py
|
|
|
|
Read current values from NSRT MK4 Sound Level Meter (USB /dev/ttyACM0)
|
|
Used by the web interface "Get Data" button via launcher.php
|
|
'''
|
|
|
|
import json
|
|
import nsrt_mk3_dev
|
|
|
|
try:
|
|
nsrt = nsrt_mk3_dev.NsrtMk3Dev('/dev/ttyACM0')
|
|
|
|
leq_level = nsrt.read_leq()
|
|
weighted_level = nsrt.read_level()
|
|
weighting = nsrt.read_weighting()
|
|
time_constant = nsrt.read_tau()
|
|
|
|
data = {
|
|
"LEQ": round(leq_level, 2),
|
|
"dBA": round(weighted_level, 2),
|
|
"weighting": str(weighting),
|
|
"tau": time_constant
|
|
}
|
|
print(json.dumps(data))
|
|
|
|
except Exception as e:
|
|
print(json.dumps({"error": str(e)}))
|