XPL-PERL and Oregon wireless temp sensors

Forum regarding Linux Software and Home Automation Domotica.
Post Reply
Jfn
Member
Member
Posts: 332
Joined: Tue Feb 26, 2008 2:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post 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!
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post by Snelvuur »

i think you should ask beanz for this..

// Erik (binkey.nl)
Jfn
Member
Member
Posts: 332
Joined: Tue Feb 26, 2008 2:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post 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!
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post 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)
Jfn
Member
Member
Posts: 332
Joined: Tue Feb 26, 2008 2:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post 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!
Jfn
Member
Member
Posts: 332
Joined: Tue Feb 26, 2008 2:01 pm
Location: Netherlands
Contact:

XPL-PERL and Oregon wireless temp sensors

Post 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
Post Reply

Return to “Linux Forum”