This commit is contained in:
Your Name
2025-03-26 17:17:40 +01:00
parent d0e1ad18e9
commit 76a676925d
10 changed files with 283 additions and 18 deletions

View File

@@ -74,11 +74,11 @@ def read_co2():
response = ser.read(9)
# Print the response to debug
print(f"Response: {response}")
#print(f"Response: {response}")
# Check if the response is valid (the first byte should be 0xFF)
if len(response) < 9:
print("Error: No data or incomplete data received.")
print("Error: No data or incomplete data received from co2 sensor.")
return None
if response[0] == 0xFF:
@@ -86,7 +86,7 @@ def read_co2():
co2_concentration = response[2] * 256 + response[3]
return co2_concentration
else:
print("Error reading data from sensor.")
print("Error reading data from co2 sensor.")
return None
@@ -95,12 +95,12 @@ def main():
try:
co2 = read_co2()
if co2 is not None:
print(f"CO2 Concentration: {co2} ppm")
#print(f"CO2 Concentration: {co2} ppm")
#save to file
output_file = "/var/www/moduleair_pro_4g/matrix/input_MHZ16.txt"
with open(output_file, "w") as file:
file.write(f"{co2} \n")
print(f"Data written to {output_file}")
#print(f"Data written to {output_file}")
#GET RTC TIME from SQlite
cursor.execute("SELECT * FROM timestamp_table LIMIT 1")
row = cursor.fetchone() # Get the first (and only) row