Reputation: 575
My Pi Logs Temperature and Humidity every Minute into a csv File and in a RRDtool Database:
I created this RRDtool Database like this:
rrdtool create /home/pi/Desktop/GarageData.rrd --step 60
DS:Temperatur:GAUGE:300:U:U
DS:Humidity:GAUGE:300:U:U
RRA:AVERAGE:0.5:12:24
RRA:AVERAGE:0.5:288:31
So the database should accept one value every 60 seconds
I am logging with a python 3 script. Here is the important part.
import Adafruit_DHT
from rrdtool import update as rrd_update
humidity, temperatur = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, '22')
rrd_update('/home/pi/Desktop/GarageData.rrd', 'N:%s:%s' %(temperatur, humidity))
when using rrdtool fetch GarageData.rrd AVERAGE r300
I am only seeing nan
Temperatur Humidity
1469111040: nan nan
1469128320: nan nan
1469145600: nan nan
1469162880: nan nan
1469180160: nan nan
1469197440: nan nan
and when plotting the Database.... nothing is shows up in the plot.
Where is the problem in my script? I thought I did everything exactly like in this Tutorial
Upvotes: 1
Views: 1439
Reputation: 4027
You may not have collected enough data yet.
Your RRD definition uses a 60s step, but the smallest RRA is a 12-minute step (1cdp = 12pdp). This means you'll need to have at least 2 entries to have something meaningful, and so have data collected for at least 24 minutes, probably more, before you see something in your output.
As you are trying to fetch data at a 5min interval, I would suggest that you also have a 5pdp RRA, and possibly also a 1pdp RRA for testing. These RRA are also rather short but I assume you have a reason for that.
rrdtool create /home/pi/Desktop/GarageData.rrd --step 60
DS:Temperatur:GAUGE:300:U:U
DS:Humidity:GAUGE:300:U:U
RRA:AVERAGE:0.5:1:600
RRA:AVERAGE:0.5:5:200
RRA:AVERAGE:0.5:12:24
RRA:AVERAGE:0.5:288:31
If you add these additional RRAs then you'll be able to view your collected data much sooner.
If you still see nan
in the values, possibly your collected data are incorrect, and youre read_retry() function call is not returning valid data. Print these values to a file so you can see that they are really numerical.
Upvotes: 1