update
This commit is contained in:
0
envea/read_value_loop.py
Normal file → Executable file
0
envea/read_value_loop.py
Normal file → Executable 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
|
||||
@@ -267,6 +267,9 @@ try:
|
||||
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:
|
||||
#on récupère les infos de sound_metermoving et on les ajoute au message
|
||||
@@ -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,10 +614,12 @@ 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>")
|
||||
|
||||
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print("An error occurred:", e)
|
||||
traceback.print_exc() # This prints the full traceback
|
||||
Reference in New Issue
Block a user