Page 1 of 1

XPL-PERL and Oregon wireless temp sensors

Posted: Sat May 10, 2008 5:51 pm
by Jfn
I have a Oregon Scientific wireless temperature/humidity sensor running. Data is decoded by an RFXCOM receiver.

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
(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:

Code: Select all

$xpl->add_xpl_callback(id => "<i>temp</i>",
                        callback => \&log_temp,
                        filter => {
                                class => 'sensor',
                                class_type => 'basic',
                                device => 'thgr228n',
                                  });
(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!

XPL-PERL and Oregon wireless temp sensors

Posted: Sat May 10, 2008 6:16 pm
by Snelvuur
i think you should ask beanz for this..

// Erik (binkey.nl)

XPL-PERL and Oregon wireless temp sensors

Posted: Sun May 11, 2008 9:20 am
by Jfn
I found out that the callback routine gets called three times in a row, for temperature, humidity and battery status. Every measurement is considered to be a seperate xPL message.

I just add a record to the temporary table containing timestamp, id of the sensor, type of the data (temp/hum/batt) and the measured value.

Every next hour I calculate an average value (per sensor) over the previous hour for temperature and humidity (per sensor) and store this permanently in another table. After that, data in the temporary table for the previous hour gets deleted.




Als het niet gerepareerd kan worden dan is het niet kapot!

XPL-PERL and Oregon wireless temp sensors

Posted: Sun May 11, 2008 11:39 am
by Snelvuur
Sounds nice, what do you use now to turn on a light based on a actino? is that zenah or is that x10/heyu or something similar?

// Erik (binkey.nl)

XPL-PERL and Oregon wireless temp sensors

Posted: Sun May 11, 2008 12:39 pm
by Jfn
I am still only measuring data and storing it in a database (using simple perl scripts that get started by cron) so I can draw graphics. So no event-driven actions at the moment.

I do not have any X10 (or alike) equipment in the house, yet. This will come eventually, but for now I am more interested in learning what is going on in the house instead of being able to control stuff.

About X10, I am looking into the PLCBUS equipment sold by Elekhomica. Seems a lot cheaper than Xanura (especially considering the price of the extra equipment needed in a 3-phase installation).

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by snelvuur</i>
<br />Sounds nice, what do you use now to turn on a light based on a actino? is that zenah or is that x10/heyu or something similar?

// Erik (binkey.nl)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Als het niet gerepareerd kan worden dan is het niet kapot!

XPL-PERL and Oregon wireless temp sensors

Posted: Sun May 11, 2008 5:00 pm
by Jfn
A graphic:

Image

EDIT: Added the PHP code that generates the graphic

Als het niet gerepareerd kan worden dan is het niet kapot!

<b>Download Attachment:</b> Image temphum_garage.php.txt<br />2.44KB