[rrd-users] Measuring rain from weatherstation
Alex van den Bogaerdt
alex at vandenbogaerdt.nl
Sun Dec 7 10:49:30 CET 2014
>> Dear allI’m using rrd with a weather station (Sirius) from TFA, get data
>> every 5 minutes, and an Raspberry PI for producing graph and upload them
>> to
>> a web server – interested see here <http://sejr-hansen.dk/vejr/vejr.htm>
> Expect some more tips later, i'm a bit in a hurry now
First a suggestion for your wind direction graph. Try "--lower-limit
0 --upper limit 360 --rigid --y-grid 30:3".
Play a bit with the settings for y-grid if you don't like what you see.
Then something about large values. I've seen unlikely rates, such as 14
million mm, but also 140m/s wind speed. I can explain why such numbers occur
when using COUNTER data types, but not when using GAUGE as I expect to see
for your wind speed measurements. Please check how this happened. 140m/s is
504 km/h which would be a new record.
For the COUNTER type: if you increment from 1 at midnight to 0 at 00:05,
meaning a reset of the counter has happened, then without protection RRDtool
will assume the counter moved forward by one less than 2^32 in 300 seconds,
thus 14316557,65 per second. There is your 14 million. I will give you a way
to overcome this furtheron in this email.
I found some documentation for a Sirius 300 which seems to indicate the
amount of rain is shown as specific values:
0, <0,5 , <1 , <2 , <5 , <10 , <20 , <50
liters per sqare meter, accumulated for the current day.
This seems to be increasing during the day, and then be reset at midnight.
Is this also what you are getting? If so: there are basically two choices:
#1 poll the value multiple times between resets. In that case it is a
COUNTER, but you will want to do something around midnight to signal a
reset. DERIVE may be a better choice, in combination with a minimum of zero
and optionally with some extra processing. DERIVE in combination with a
minimum of zero will automatically notice a counter reset has happened. And
with a bit of extra work just after midnight, you can even prevent your
database from having unknowns for every interval after midnight.
Use the DERIVE counter type. Set the minimum allowed value to zero or else
the rate of rainfal could become negative. Optionally but recommended, you
could, at midnight, do the following:
1: get the value valid for midnight.
2: process this as usual (use fixed time when updating, e.g. the timestamp
1417910400 instead of 'now' !
3: insert a value of zero just after it (thus 1417910401). RRDtool will
notice the computed rate is invalid and set this one second interval to
unknown. It also resets the internal value it remembers to zero so a future
update compares against zero and will work as desired.
#2 poll the value only once, after which it is reset. In that case it is an
ABSOLUTE data type.
In both cases: A little bit of rain could make the value increase from <1 to
<2 whereas the same amount of rain could also go undetected e.g. from 6.5 to
8.5 is both <10. I would not expect your graph to really work for shorter
intervals of time but also not for longer intervals.
I don't think you can, but just in case you or someone else reading this
can:
If you can reset the rain counter when you want it, then the better option
is to do that. Find a good balance between frequent updates and allowing the
counter to change from e.g. <1 to <2. Read the amount of rain, reset the
counter, continue. If you implement this, then it is ABSOLUTE. It would be
a mistake to do this every 5 minutes. You won't record much rain, unless it
is raining very very hard.
Whichever method you used, you now have liters per square meter per second
in your database. That's also known as mm/s. Multiply by the amount of time
on the graph to get a total for that amount of time.
This won't change the way your graph looks. It is still showing mm/s. You
could multiply that by e.g. 3600 to see 'mm per hour', even if the intervals
on the graph are only 5 minutes. That is not a problem. The speedometer in a
car is showing km/h, same non-problem.
You will not see a running total, you will see an amount of rain per second.
That is what RRDtool does: per second. If you really want to have running
totals during the day (as your device gives you) but also during a week,
month, year, then you will have to do much more programming. Don't think
about it now, get your results correct first.
It is important that you know the amount of seconds in your graph, make sure
to use specific start and end times. E.g. do not use "" (nothing, meaning
the default) for the end time, but rather choose to use "--end 1417910400"
and similar. Combined with "--start end-86400" gives you a full day.
Make sure you understand how RRDtool stores data in RRAs. Each entry in an
RRA represents an amount of time, with specific start and end times. As
long as a whole number of such entries fits perfectly in your graph, RRDtool
does not have to tweak your settings, and because you have programmed the
graph you know how many seconds are shown and by how many seconds you need
to multiply to get an amount.
If the total amount of time shown on a graph is exactly 1 day, then this
will show a line representing rain in mm per hour, and total mm for that
day:
DEF:rain=$DIR/hjemmedatabase.rrd:raincounter:AVERAGE
CDEF:rainperhour=rain,3600,*
LINE1:rainperhour#0000FF:"rain in mm/h"
CDEF:raintotal=rain,86400,*
GPRINT:raintotal:AVERAGE:"%6.2lf mm"
Do remember that you are measuring "less than ... mm/s".
After getting above mentioned stuff right, you could try to increase the
accuracy of your rainfall meter. It involves remembering values read from
it. An example works best:
At time 09:55 you get "<1".
At time 10:00 you get "<2".
Upto and including time 13:55 you get "<2".
At time 14:00 you get "<5".
Upto and including time 17:55 you get "<5".
At time 18:00 you get "<10".
So far you have been logging this as "1", "2", "5" and "10", but with some
programming you could achieve more accurate results.
If you remember the read values and timestamps, then you can do something
like this:
* do not update the database for rainfall, unless the value changes
* do update the database every midnight, even if there was no change
* as soon as the read value changes, you record the previous value in the
database.
The result: at 10:00 you record "1". Then you wait. At time 14:00 you record
"2". RRDtool will automatically fill the time intervals between 10:00 and
14:00 with the new computed rate of 1mm in 4 hours = 1/14400 mm/s.
At time 18:00 you feed RRDtool the number 5. The computed rate will be 4mm
in 4 hours = 1/3600 mm/s.
If the value does not change anymore, then at midnight you have a choice.
Either log 5 again, or log 10, or log 7.5 being the average of those two.
You really do not know how much rain has fallen, you only know it is less
than 10 but not less than 5.
More information about the rrd-users
mailing list