No problem but I really messed up the code, that's what I get for rushing, unfortunately I can't edit that post. Still untested but should work. I must get to bed now but tomorrow I'll post a service file so the script runs when the Pi boots.thank you very much @robsworld78!! It’ll test it and let you know!
regarding the auto run of the script it is better to start at boot and let it run with a sleep command at the end or schedule the script with crontab?
Thank you again!!
Python:
import os
import time
import Adafruit_DHT
DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4
while True:
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
if temperature is not None:
f = open('/var/lib/reef-pi/dht22/temperature.txt', 'w')
f.write(temperature)
if humidity is not None:
f = open('/var/lib/reef-pi/dht22/humidity.txt', 'w')
f.write(humidity)
time.sleep(30)
