PIR sensor data log

Hello!

I would like to know if it is possible to use emoncms to also log the status of a PIR sensor. The only problem is that I want to maintain the polling interval for the other sensors (temperature, current, light) at 60 seconds and for the PIR sensor only when it changes the state from 0 to 1.

I would also like to know if it's possible to extract from the database (using Timestore engine) the last value for each sensor. I need the last value of each sensor because I want to post them to facebook 5 times a day.

Thank you

TrystanLea's picture

Re: PIR sensor data log

Hello fpaliuc, are you using emoncms.org or your own instance? For the PIR it might be better to use PHPTimeSeries or MYSQL rather than Timestore, given that it isnt regular. If you have your own installation of emoncms you could switch the feed creation mode to mysql or phptimeseries temporarily to do this (in settings.php).

You could then use:

feed/list.json to get a list of feeds with their last values.

fpaliuc's picture

Re: PIR sensor data log

Hello TrystanLea!

Thanks for your answer. Yes, I'll use my own instance on a RaspberryPi. I understand that I could switch the feed creation mode to MySQL or phptimeseries but, is it possible to do this only for the PIR feed and let the others set to timeseries?

Practically Arduino pushes the sensor's values every 10 seconds. The value of the PIR sensor is sent only when it changes from 0 to 1.

Thanks again

TrystanLea's picture

Re: PIR sensor data log

Yes, just create your timeseries feeds with:

$default_engine = Engine::TIMESTORE;

then switch the settings to

$default_engine = Engine::MYSQL;

or

$default_engine = Engine::PHPTIMESERIES;

and it will create feeds in those engines.

Then switch back to timestore after your done creating the feeds.

fpaliuc's picture

Re: PIR sensor data log

I got it. Thank you very much!!!

The only thing I need to understand is how to get the latest values?

I'll have 3 feeds set as timestore and 1 as MySQL. I'll have to get the last value for each feed in order to use them in another .php script.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.