This commit is contained in:
Your Name
2025-01-23 11:24:42 +01:00
parent 2650954ecc
commit 806576b8b8
2 changed files with 22 additions and 7 deletions

0
envea/read_value_loop.py Normal file → Executable file
View File

View File

@@ -69,7 +69,7 @@ import busio
import re
import os
import traceback
import sys
import RPi.GPIO as GPIO
from adafruit_bme280 import basic as adafruit_bme280
@@ -83,8 +83,8 @@ with open('/proc/uptime', 'r') as f:
# Skip execution if uptime is less than 2 minutes (120 seconds)
if uptime_seconds < 120:
print("System just booted, skipping execution.")
exit()
print(f"System just booted ({uptime_seconds:.2f} seconds uptime), skipping execution.")
sys.exit()
url_nebuleair="data.nebuleair.fr"
payload_csv = [None] * 20
@@ -266,6 +266,9 @@ try:
payload_csv[3] = round(bme280.temperature, 2)
payload_csv[4] = round(bme280.humidity, 2)
payload_csv[5] = round(bme280.pressure, 2)
payload_json["sensordatavalues"].append({"value_type": "th_npm", "value": f"{round(bme280.temperature, 2)} / {round(bme280.humidity, 2)}"})
# Sonde Bruit connected
if i2C_sound_config:
@@ -347,12 +350,22 @@ try:
time.sleep(1)
# On vérifie si le signal n'est pas à 99 pour déconnexion
# si c'est le cas on essaie de se reconnecter
if signal_quality == 99:
print('<span style="color: red;font-weight: bold;">⚠ATTENTION: Signal Quality indicates no signal (99)⚠️</span>')
print("TRY TO RECONNECT:")
command = f'AT+COPS=1,2,"{selected_networkID}"\r'
ser_sara.write(command.encode('utf-8'))
responseReconnect = read_complete_response(ser_sara, timeout=20, end_of_response_timeout=20)
print('<p class="text-danger-emphasis">')
print(responseReconnect)
print("</p>")
print('🛑STOP LOOP🛑')
print("<hr>")
#on arrete le script pas besoin de continuer
exit()
sys.exit()
else:
print("Signal Quality:", signal_quality)
@@ -601,9 +614,11 @@ try:
# Calculate and print the elapsed time
elapsed_time = time.time() - start_time_script
if need_to_log:
print(f"Elapsed time: {elapsed_time:.2f} seconds")
print("<hr>")
print(f"Elapsed time: {elapsed_time:.2f} seconds")
print("<hr>")
except Exception as e:
print("An error occurred:", e)