update
This commit is contained in:
@@ -12,10 +12,11 @@ CSV PAYLOAD (AirCarto Servers)
|
||||
/pro_4G/data.php?sensor_id={device_id}
|
||||
|
||||
ATTENTION : do not change order !
|
||||
CSV size: 18
|
||||
{PM1},{PM25},{PM10},{temp},{hum},{press},{avg_noise},{max_noise},{min_noise},{envea_no2},{envea_h2s},{envea_o3},{4g_signal_quality}
|
||||
0 -> PM1
|
||||
1 -> PM25
|
||||
2 -> PM10
|
||||
0 -> PM1 (μg/m3)
|
||||
1 -> PM25 (μg/m3)
|
||||
2 -> PM10 (μg/m3)
|
||||
3 -> temp
|
||||
4 -> hum
|
||||
5 -> press
|
||||
@@ -25,7 +26,12 @@ CSV PAYLOAD (AirCarto Servers)
|
||||
9 -> envea_no2
|
||||
10 -> envea_h2s
|
||||
11 -> envea_o3
|
||||
12 -> 4G signal quality
|
||||
12 -> 4G signal quality,
|
||||
13 -> PM 0.2μm to 0.5μm quantity (Nb/L)
|
||||
14 -> PM 0.5μm to 1.0μm quantity (Nb/L)
|
||||
15 -> PM 1.0μm to 2.5μm quantity (Nb/L)
|
||||
16 -> PM 2.5μm to 5.0μm quantity (Nb/L)
|
||||
17 -> PM 5.0μm to 10μm quantity (Nb/L)
|
||||
|
||||
JSON PAYLOAD (Micro-Spot Servers)
|
||||
Same as NebuleAir wifi
|
||||
@@ -178,6 +184,7 @@ bme_280_config = config.get('i2c_BME', False) #présence du BME280
|
||||
i2C_sound_config = config.get('i2C_sound', False) #présence du capteur son
|
||||
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.nebuleair.fr)
|
||||
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
||||
npm_5channel = config.get('NextPM_5channels', False) #5 canaux du NPM
|
||||
|
||||
envea_sondes = config.get('envea_sondes', [])
|
||||
connected_envea_sondes = [sonde for sonde in envea_sondes if sonde.get('connected', False)]
|
||||
@@ -307,7 +314,45 @@ try:
|
||||
payload_json["sensordatavalues"].append({"value_type": "BME280_humidity", "value": f"{round(bme280.humidity, 2)}"})
|
||||
payload_json["sensordatavalues"].append({"value_type": "BME280_pressure", "value": f"{round(bme280.pressure, 2)}"})
|
||||
|
||||
|
||||
# NPM sur 5 cannaux
|
||||
if npm_5channel:
|
||||
print("Getting NPM 5 Channels")
|
||||
# Define the path to the JSON file
|
||||
json_file_path_npm = "/var/www/nebuleair_pro_4g/NPM/data/data.json"
|
||||
# Read the JSON file
|
||||
try:
|
||||
with open(json_file_path_npm, "r") as file:
|
||||
data = json.load(file) # Load JSON into a dictionary
|
||||
|
||||
# Extract values
|
||||
channel_1 = data.get("channel_1", 0)
|
||||
channel_2 = data.get("channel_2", 0)
|
||||
channel_3 = data.get("channel_3", 0)
|
||||
channel_4 = data.get("channel_4", 0)
|
||||
channel_5 = data.get("channel_5", 0)
|
||||
|
||||
# Print extracted values
|
||||
print(f"Channel 1: {channel_1}")
|
||||
print(f"Channel 2: {channel_2}")
|
||||
print(f"Channel 3: {channel_3}")
|
||||
print(f"Channel 4: {channel_4}")
|
||||
print(f"Channel 5: {channel_5}")
|
||||
|
||||
#add to CSV
|
||||
payload_csv[13] = channel_1
|
||||
payload_csv[14] = channel_2
|
||||
payload_csv[15] = channel_3
|
||||
payload_csv[16] = channel_4
|
||||
payload_csv[17] = channel_5
|
||||
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"Error: JSON file not found at {json_file_path_npm}")
|
||||
except json.JSONDecodeError:
|
||||
print("Error: JSON file is not formatted correctly")
|
||||
except Exception as e:
|
||||
print(f"Unexpected error: {e}")
|
||||
|
||||
# Sonde Bruit connected
|
||||
if i2C_sound_config:
|
||||
#on récupère les infos de sound_metermoving et on les ajoute au message
|
||||
@@ -324,7 +369,7 @@ try:
|
||||
payload_csv[8] = min_noise
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"Error: File {file_path} not found.")
|
||||
print(f"Error: File {file_path_data_noise} not found.")
|
||||
except ValueError:
|
||||
print("Error: File content is not valid numbers.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user