added debugging

Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>
master
Ebbe Baß 2022-07-24 10:13:00 +02:00
parent 5e748b0dae
commit c617eced1f
1 changed files with 18 additions and 9 deletions

27
main.py
View File

@ -1,3 +1,16 @@
def debug_print(message: str):
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('[DEBUG]['+current_time+'] '+message)
def error_print(message: str):
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('[ERROR]['+current_time+'] '+message)
debug_print("Importing modules")
from string import whitespace from string import whitespace
import time import time
from datetime import datetime from datetime import datetime
@ -14,15 +27,7 @@ except ImportError:
print(ImportError) print(ImportError)
exit() exit()
def debug_print(message: str): debug_print("Imported modules")
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('[DEBUG]['+current_time+'] '+message)
def error_print(message: str):
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('[ERROR]['+current_time+'] '+message)
#relay #relay
def relay_controller(pin: int, state: str): def relay_controller(pin: int, state: str):
@ -60,6 +65,8 @@ def get_water_level():
rounded_distance = int(distance) rounded_distance = int(distance)
return str(rounded_distance) return str(rounded_distance)
debug_print("Added water level detector")
#temperature #temperature
def get_temperature(): def get_temperature():
i2c = busio.I2C(board.SCL, board.SDA) i2c = busio.I2C(board.SCL, board.SDA)
@ -67,6 +74,8 @@ def get_temperature():
rounded_temp = int(bmp280.temperature) rounded_temp = int(bmp280.temperature)
return str(rounded_temp) return str(rounded_temp)
debug_print("Added temperature sensor")
print(get_water_level()) print(get_water_level())
print(get_temperature()) print(get_temperature())