update
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
'''
|
||||
_ _ ____ __ __
|
||||
| \ | | _ \| \/ |
|
||||
| \| | |_) | |\/| |
|
||||
| |\ | __/| | | |
|
||||
|_| \_|_| |_| |_|
|
||||
____ _____ _ _ ____ ___ ____ ____
|
||||
/ ___|| ____| \ | / ___| / _ \| _ \/ ___|
|
||||
\___ \| _| | \| \___ \| | | | |_) \___ \
|
||||
___) | |___| |\ |___) | |_| | _ < ___) |
|
||||
|____/|_____|_| \_|____/ \___/|_| \_\____/
|
||||
|
||||
|
||||
Script to get NPM values
|
||||
Script to get SENSORS values
|
||||
And store them inside sqlite database
|
||||
Uses RTC module for timing
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/NPM/get_data_v2.py
|
||||
@@ -73,6 +74,7 @@ ser.write(b'\x81\x12\x6D') #data60s
|
||||
|
||||
while True:
|
||||
try:
|
||||
#print("Start get_data_v2.py script")
|
||||
byte_data = ser.readline()
|
||||
#print(byte_data)
|
||||
stateByte = int.from_bytes(byte_data[2:3], byteorder='big')
|
||||
@@ -86,8 +88,6 @@ while True:
|
||||
#print(f"PM10: {PM10}")
|
||||
#create JSON
|
||||
data = {
|
||||
'capteurID': 'nebuleairpro1',
|
||||
'sondeID':'USB2',
|
||||
'PM1': PM1,
|
||||
'PM25': PM25,
|
||||
'PM10': PM10,
|
||||
@@ -101,7 +101,7 @@ while True:
|
||||
'laserError' : Statebits[7]
|
||||
}
|
||||
json_data = json.dumps(data)
|
||||
print(json_data)
|
||||
#print(json_data)
|
||||
|
||||
#GET RTC TIME
|
||||
# Read RTC time
|
||||
@@ -111,7 +111,7 @@ while True:
|
||||
|
||||
if rtc_time:
|
||||
rtc_time_str = rtc_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
print(rtc_time_str)
|
||||
#print(rtc_time_str)
|
||||
else:
|
||||
print("Error! RTC module not connected")
|
||||
rtc_time_str = "1970-01-01 00:00:00" # Default fallback time
|
||||
@@ -125,7 +125,7 @@ while True:
|
||||
# Commit and close the connection
|
||||
conn.commit()
|
||||
|
||||
print("Sensor data saved successfully!")
|
||||
#print("Sensor data saved successfully!")
|
||||
|
||||
break # Exit loop after successful execution
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user