update
This commit is contained in:
@@ -99,6 +99,7 @@ import sys
|
||||
import sqlite3
|
||||
import RPi.GPIO as GPIO
|
||||
from threading import Thread
|
||||
from datetime import datetime
|
||||
|
||||
# Record the start time of the script
|
||||
start_time_script = time.time()
|
||||
@@ -205,10 +206,16 @@ need_to_log = config.get('loop_log', False) #inscription des logs
|
||||
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.nebuleair.fr)
|
||||
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
||||
selected_networkID = config.get('SARA_R4_neworkID', '')
|
||||
modem_config_mode = config.get('modem_config_mode', False) #modem 4G en mode configuration
|
||||
|
||||
#update device id in the payload json
|
||||
payload_json["nebuleairid"] = device_id
|
||||
|
||||
# Skip execution if modem_config_mode is true
|
||||
if modem_config_mode:
|
||||
print("Modem 4G (SARA R4) is in config mode -> EXIT")
|
||||
sys.exit()
|
||||
|
||||
ser_sara = serial.Serial(
|
||||
port='/dev/ttyAMA2',
|
||||
baudrate=baudrate, #115200 ou 9600
|
||||
@@ -279,6 +286,13 @@ try:
|
||||
# Display the result
|
||||
if last_row:
|
||||
print("SQLite DB last available row:", last_row)
|
||||
|
||||
datetime_measure_PM = last_row[0] #on récupère le datetime de la table data_NPM
|
||||
# Convert to a datetime object
|
||||
dt_object = datetime.strptime(datetime_measure_PM, '%Y-%m-%d %H:%M:%S')
|
||||
# Convert to InfluxDB RFC3339 format with UTC 'Z' suffix
|
||||
influx_timestamp = dt_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
PM1 = last_row[1]
|
||||
PM25 = last_row[2]
|
||||
PM10 = last_row[3]
|
||||
@@ -358,7 +372,7 @@ try:
|
||||
|
||||
#3. Send to endpoint (with device ID)
|
||||
print("Send data (POST REQUEST):")
|
||||
command= f'AT+UHTTPC={aircarto_profile_id},4,"/pro_4G/data.php?sensor_id={device_id}&datetime=000","server_response.txt","sensordata_csv.json",4\r'
|
||||
command= f'AT+UHTTPC={aircarto_profile_id},4,"/pro_4G/data.php?sensor_id={device_id}&datetime={influx_timestamp}","server_response.txt","sensordata_csv.json",4\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
|
||||
response_SARA_3 = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=120, wait_for_lines=["+UUHTTPCR", "+CME ERROR"], debug=True)
|
||||
|
||||
Reference in New Issue
Block a user