Fixing date in DHT22 print formatting.
This commit is contained in:
@@ -20,7 +20,7 @@ if __name__ == "__main__":
|
||||
# Setup for Hardware
|
||||
DHT22_PIN = 4
|
||||
dht_device = adafruit_dht.DHT22(4)
|
||||
file = '/home/pi/code/dht22/log.csv'
|
||||
file = '/home/pi/code/garden/dht22/log.csv'
|
||||
|
||||
with open(file,'a') as f:
|
||||
|
||||
@@ -29,10 +29,10 @@ if __name__ == "__main__":
|
||||
data = get_sensor_data(dht22=dht_device)
|
||||
if data:
|
||||
temperature, humidity = get_sensor_data(dht22=dht_device)
|
||||
current_time = datetime.now().strftime("%H:%M:%S")
|
||||
current_time = datetime.now().strftime("%D %H:%M:%S")
|
||||
print(f'{humidity:.2f}% {temperature:.2f}degF')
|
||||
f.write(f'{current_time},{humidity:.2f},{temperature:.2f}\n')
|
||||
time.sleep(60)
|
||||
time.sleep(14.9)
|
||||
else:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user