Beginning of cooking cycle
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import grovepi
|
||||
import math
|
||||
import time
|
||||
from sensors.lock import grove_lock
|
||||
|
||||
# Connect the Grove Temperature & Humidity Sensor Pro to digital port D3
|
||||
@@ -20,3 +21,11 @@ def get_temperature_and_humidity():
|
||||
else:
|
||||
print("Error reading from DHT sensor")
|
||||
return None, None
|
||||
|
||||
def get_temperature_and_humidity_with_retry(max_retries=3):
|
||||
for _ in range(max_retries): # Try up to max_retries times
|
||||
temp, humidity = get_temperature_and_humidity()
|
||||
if temp is not None and humidity is not None:
|
||||
return temp, humidity
|
||||
time.sleep(1) # Wait a bit before retrying
|
||||
return None, None
|
||||
Reference in New Issue
Block a user