This commit is contained in:
quackerd 2022-01-22 16:51:03 +08:00
parent 9ffd93c5fc
commit 4efe19e08f

View File

@ -8,9 +8,9 @@ import influxdb_client
import sys
import signal
NUM_READS = 10
NUM_READS = 15
DELAY_PER_READ = 1
DELAY_PER_MEASURE = 300
DELAY_PER_MEASURE = 60
DB_TOKEN = 'sensor1234sensor'
DB_ORG = 'sensor'
@ -101,11 +101,10 @@ def main():
logging.info("Uploading data to database...")
dbpt = data_to_point(data)
logging.debug("DB point: " + str(dbpt))
if not dbconn.write_api().write(DB_BUCKET, DB_ORG, dbpt):
logging.error("Failed to update database.")
dbconn.write_api().write(DB_BUCKET, DB_ORG, dbpt)
next_ms = cur_ms + DELAY_PER_MEASURE * 1000
logging.debug("Next measurement point: " + str(next_ms))
logging.info("Next measurement point: " + str(next_ms))
else:
logging.debug("Next measurement point hasn't arrived. Sleeping for 1s...")
time.sleep(1)