#!/usr/bin/python import time import Adafruit_DHT while True: sensor = Adafruit_DHT.DHT22 pin = 4 humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) if humidity is not None and temperature is not None: data = [str(int(round(time.time() * 1000))), str(humidity), str(temperature)] with open('/var/www/data.csv', 'a') as f: f.write(','.join(data) + '\r\n')