XPL-PERL and Oregon wireless temp sensors
Posted: Sat May 10, 2008 5:51 pm
I have a Oregon Scientific wireless temperature/humidity sensor running. Data is decoded by an RFXCOM receiver.
Works perfectly. An example of the output:
(In case you are wondering, the temp displayed is the temp in the garage).
The next step is to put the data in an SQL database. As the wireless sensor outputs data approximately every minute, I intend to store all measurements, received within the same hour, in a database and at the beginning of a new hour calculate an average from all available measurements from the previous hour. This value is then stored permanently in another table.
The callback routine used in xpl-perl would look something like this:
(As I will be adding more sensors, the line <i>device -> 'thgr228n'</i> should catch all sensors, but still contain the full name, for example <i>'thgr228n.15'</i>).
What I was wondering: Do I have to create 3 callback routines, that is one for <i>temp</i>, one for <i>humidity</i> and one for <i>battery</i>? Or is it possible to deal with all three values in 1 callback routine.
I would prefer one record per sensor in the temporary table, instead of three separate ones (whence the 3 callback routines).
Als het niet gerepareerd kan worden dan is het niet kapot!
Works perfectly. An example of the output:
Code: Select all
2008-05-10_15:31:42.16472 xpl-trig/sensor.basic: bnz-rfxcom.debian -> * - thgr228n.15[temp]=30.9
2008-05-10_15:31:42.16473 xpl-trig/sensor.basic: bnz-rfxcom.debian -> * - thgr228n.15[humidity]=30
2008-05-10_15:31:42.16473 xpl-trig/sensor.basic: bnz-rfxcom.debian -> * - thgr228n.15[battery]=90
The next step is to put the data in an SQL database. As the wireless sensor outputs data approximately every minute, I intend to store all measurements, received within the same hour, in a database and at the beginning of a new hour calculate an average from all available measurements from the previous hour. This value is then stored permanently in another table.
The callback routine used in xpl-perl would look something like this:
Code: Select all
$xpl->add_xpl_callback(id => "<i>temp</i>",
callback => \&log_temp,
filter => {
class => 'sensor',
class_type => 'basic',
device => 'thgr228n',
});
What I was wondering: Do I have to create 3 callback routines, that is one for <i>temp</i>, one for <i>humidity</i> and one for <i>battery</i>? Or is it possible to deal with all three values in 1 callback routine.
I would prefer one record per sensor in the temporary table, instead of three separate ones (whence the 3 callback routines).
Als het niet gerepareerd kan worden dan is het niet kapot!