blob: cdaa31a8fc33daab67a3c4f117872762d7cd5c94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
#!/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')
|