update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user