Methods described here are only available from the 0.4.1.13 version and higher of VSCP & Friends.
Sparcfun Electronics use “stream” to describe what other would call a “database” so we do so to in this document.
We set up a stream here that will log temperature measurements i degrees Centigrade. If you prefer them to be in another unit just program your device to send events in that unit or alternatively do a conversion before you send it up to the stream. We could have used a field for the VSCP measurement unit but as most other systems is dumb in that respect and just think “temperature” and send a value we do so here as well. But beware that a “temperature” of 100 degrees sjould be interpreted differently if it is in Kelvin, Fahrenheit or in Celsius.
First of all create a stream on the data.sparcfun site. First you need to give your stream a title. Use something descriptive like “temperature_los_outside”.
In the description you can describe the stream so you know why you created it and what it does.
Click hidden if you want the stream to be private to you.
In fields you enter a comma separated list of fields you want in your stream. In our case we use “temp,unit,sensoridx,guid”. Where temp is the measured temperature, and unit is the measurement unit (0=Kelvin, 1=Celsius, 2=Fahrenheit), sensoridx is the index for the sensor, and GUID is the globally unique id for the sensor device.
In tags you can write a comma separated list that categorize your stream data. We enter “vscp,los,house,temp” here.
Now we need to add this to VSCP. We do this by adding a DM entry that looks like this
<row enabled="true" groupid="xively-logger"> <!-- Mask - We just care for class and type --> <mask priority="0" class="0xffff" type="0xff" guid="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"></mask> <!-- CALSS1.MEASUREMENT, Type=6, Temperature event --> <filter priority="0" class="0x000a" type="6" guid="FF:FF:FF:FF:FF:FF:FF:FE:00:26:55:CA:1F:DA:00:02"></filter> <!-- Allowed historical --> <allowed_from>1977-01-01 00:00:00</allowed_from> <!-- Allowed also far into the future --> <allowed_to>2099-12-31 23:59:59</allowed_to> <!-- Allowed every day in the week --> <allowed_weekdays>mtwtfss</allowed_weekdays> <!-- At all times --> <allowed_time>*-*-* *:*:*</allowed_time> <!-- Control code - --> <control>0x80000000</control> <!-- Action code == Execute command --> <action>0x00000010</action> <!-- Action parameter --> <param>/usr/local/bin/datastream_update 9ycPu4AxlK3YyqoEULi39abh1xfnyHwX1A9tu7pqKe3inOTi 2805488985 temp_office %measurement_float</param> <!-- Comment for decision matrix row --> <comment>Log temperature to data.sparcfun</comment> </row>
What we say here is that we want to log all temperatures measurement events from a node with nodeid=2 on interface FF:FF:FF:FF:FF:FF:FF:FE:00:26:55:CA:1F:DA:00:00. When they are received we execute a program datastream_update we updated and tested above. For the parameters to the program we recognize the api-key followed by the feed id and the name of the channel but %measurement_float is new. This is just an escape sequence where the daemon automatically set in the floating point value for the measurement.There are many others defined and you can read about them in the specification document section 14.7.6
Now restart the daemon with
and CLASS1.MEASUREMENT, TYPE=6, Temperature events will be collected in Xively and you can investigate them further there in diagram form etc.
If you are a smart (a girl) you use the built in web interface of the daemon to update the decision matrix of course.
Configuration/DM - New element