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 re
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
import sys
|
||||||
|
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
from adafruit_bme280 import basic as adafruit_bme280
|
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)
|
# Skip execution if uptime is less than 2 minutes (120 seconds)
|
||||||
if uptime_seconds < 120:
|
if uptime_seconds < 120:
|
||||||
print("System just booted, skipping execution.")
|
print(f"System just booted ({uptime_seconds:.2f} seconds uptime), skipping execution.")
|
||||||
exit()
|
sys.exit()
|
||||||
|
|
||||||
url_nebuleair="data.nebuleair.fr"
|
url_nebuleair="data.nebuleair.fr"
|
||||||
payload_csv = [None] * 20
|
payload_csv = [None] * 20
|
||||||
@@ -266,6 +266,9 @@ try:
|
|||||||
payload_csv[3] = round(bme280.temperature, 2)
|
payload_csv[3] = round(bme280.temperature, 2)
|
||||||
payload_csv[4] = round(bme280.humidity, 2)
|
payload_csv[4] = round(bme280.humidity, 2)
|
||||||
payload_csv[5] = round(bme280.pressure, 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
|
# Sonde Bruit connected
|
||||||
if i2C_sound_config:
|
if i2C_sound_config:
|
||||||
@@ -347,12 +350,22 @@ try:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# On vérifie si le signal n'est pas à 99 pour déconnexion
|
# 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:
|
if signal_quality == 99:
|
||||||
print('<span style="color: red;font-weight: bold;">⚠️ATTENTION: Signal Quality indicates no signal (99)⚠️</span>')
|
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('🛑STOP LOOP🛑')
|
||||||
print("<hr>")
|
print("<hr>")
|
||||||
|
|
||||||
#on arrete le script pas besoin de continuer
|
#on arrete le script pas besoin de continuer
|
||||||
exit()
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
print("Signal Quality:", signal_quality)
|
print("Signal Quality:", signal_quality)
|
||||||
|
|
||||||
@@ -601,9 +614,11 @@ try:
|
|||||||
|
|
||||||
# Calculate and print the elapsed time
|
# Calculate and print the elapsed time
|
||||||
elapsed_time = time.time() - start_time_script
|
elapsed_time = time.time() - start_time_script
|
||||||
if need_to_log:
|
print(f"Elapsed time: {elapsed_time:.2f} seconds")
|
||||||
print(f"Elapsed time: {elapsed_time:.2f} seconds")
|
print("<hr>")
|
||||||
print("<hr>")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occurred:", e)
|
print("An error occurred:", e)
|
||||||
|
|||||||
Reference in New Issue
Block a user