diff --git a/html/admin.html b/html/admin.html
index c4f619f..f4899de 100755
--- a/html/admin.html
+++ b/html/admin.html
@@ -289,7 +289,7 @@ window.onload = function() {
checkbox_nmp5channels.checked = response.npm_5channel;
checkbox_bme.checked = response["BME280"];
checkbox_SFA30.checked = response["SFA30"];
- checkbox_CO2.checked = response["MH-Z19"];
+ checkbox_CO2.checked = response["MHZ19"];
//si sonde envea is true
if (response["envea"]) {
diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py
index 28cd293..ab03986 100755
--- a/loop/SARA_send_data_v2.py
+++ b/loop/SARA_send_data_v2.py
@@ -49,7 +49,8 @@ CSV PAYLOAD (AirCarto Servers)
17 -> PM 5.0μm to 10μm quantity (Nb/L)
18 -> NPM temp inside
19 -> NPM hum inside
-
+ 20 -> CO2
+
JSON PAYLOAD (Micro-Spot Servers)
Same as moduleair wifi
Endpoint:
@@ -274,7 +275,7 @@ npm_5channel = config.get('npm_5channel', False) #5 canaux du NPM
selected_networkID = int(config.get('SARA_R4_neworkID', 0))
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
bme_280_config = config.get('BME280', False)
-co2_mhz19= config.get('MH-Z19', False)
+co2_mhz19= config.get('MHZ19', False)
sensirion_sfa30= config.get('SFA30', False)
reset_uSpot_url = False
@@ -499,7 +500,7 @@ def reset_server_hostname(profile_id):
if profile_id == 0:
print('🔧 Resetting AirCarto HTTP Profile')
- command = f'AT+UHTTP={profile_id},1,"data.nebuleair.fr"\r'
+ command = f'AT+UHTTP={profile_id},1,"data.moduleair.fr"\r'
ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"])
print(response_SARA_5)
@@ -635,7 +636,31 @@ try:
else:
print("No data available in the database.")
-
+ #HM-Z19
+ if co2_mhz19:
+ # CO2 sensor - average of last 6 measures
+ print("➡️Getting CO2 values (last 6 measures)")
+ cursor.execute("SELECT rowid, * FROM data_CO2 ORDER BY rowid DESC LIMIT 6")
+
+ rows = cursor.fetchall()
+ if rows:
+ # Extract just the CO2 values (assuming CO2 is in column 2 after rowid and timestamp)
+ co2_values = [row[2] for row in rows] # Adjust index based on your table structure
+
+ # Calculate average
+ co2_average = round(sum(co2_values) / len(co2_values), 1)
+
+ # Add data to payload CSV
+ payload_csv[20] = co2_average # Choose appropriate index
+
+ # Add data to payload JSON
+ payload_json["sensordatavalues"].append({"value_type": "CO2", "value": str(co2_average)})
+
+ print(f"CO2 average from {len(co2_values)} measurements: {co2_average}")
+ else:
+ print("No CO2 data available in the database.")
+
+
#print("Verify SARA R4 connection")
# Getting the LTE Signal
diff --git a/sqlite/read.py b/sqlite/read.py
index 66916c6..70ea7f5 100755
--- a/sqlite/read.py
+++ b/sqlite/read.py
@@ -14,6 +14,7 @@ data_NPM_5channels
data_BME280
data_envea
timestamp_table
+data_CO2
'''