How to use Xively with VSCP

This page will show how you can use the Xively service with VSCP.

Methods described here are only available from the version and higher of VSCP & Frieds.

Using the C API to log measurements

Step 1

First of all create a development account on the Xively site. Then create a feed. As a result you will get a feed id and an API key.

Step 2

Now download the Xively C-API from github. You find it here and the documentation for it is here. You can either clone the lib with git

git clone

or you can download it compressed


the go into the folder

cd libxively or cd libxively-master
make all

Step 3

The file datastream_update in the bin folder of the lib do what we want if we want to update integer values. If we issue

./datastream_update API-KEY FEED-id name value

the value will be updated. This may look like

./datastream_update 9ycPu4AxlK3YyqoEULi39abh1xfnyHwX1A9tu7pqKe3inOTi 2805488985 temp_office 21    

If integer value is what you want to update this is all you need to do and you can go to step 5.

Step 4

To change this example program so it logs floating point values instead of integers you have to change a line and recompile. The file is located at


and the line you need to change is at line 53. You change this line from

xi_set_value_i32( &datapoint, atoi( argv[ 4 ] ) );


xi_set_value_f32( &datapoint, atof( argv[ 4 ] ) );  

and then you issue


to build gain. After this change datastream_update will handle decimal numbers and

./datastream_update 9ycPu4AxlK3YyqoEULi39abh1xfnyHwX1A9tu7pqKe3inOTi 2805488985 temp_office 21.15

will work as wall

Step 5

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"

        <!-- CALSS1.MEASUREMENT, Type=6, Temperature event -->
        <filter priority="0" class="0x000a" type="6"

        <!-- 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 -->

        <!-- At all times -->
        <allowed_time>*-*-* *:*:*</allowed_time>

        <!-- Control code -  -->

        <!-- Action code == Execute command  -->

        <!-- Action parameter -->
        <param>/usr/local/bin/datastream_update 9ycPu4AxlK3YyqoEULi39abh1xfnyHwX1A9tu7pqKe3inOTi 2805488985 temp_office %measurement_float</param>

         <!-- Comment for decision matrix row -->
        <comment>Log temperature to Xively</comment>

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

/etc/init.d/vscpd restart

and CLASS1.MEASUREMENT, TYPE=6, Temperature events will be collected in Xively and you can investigate them further there in diagram form ets.

If you are a smart (girl) you use the built in web interface of the daemon to update the decision matrix of course.



Configuration/DM - New element

Using the Python API to log measurements

Step 1

install the Xively Python library with

$ pip install xively-python

Now can go ahead and install the Xively python library within our virtualenv:

$ pip install xively-python

This command should run for a few seconds, and you should see that it installs the Xively library, plus any dependencies that it requires.

If you are getting an error message that says “Could not find a version that satisfies the requirement”, you should try running

pip install --pre xively-python.  

Step 2

As above create a channel on Xively. In this sample we use “temp_office”

Step 3

In the


folder of the VSCP & Friends source tree you have a python executable called which you can use to update measurement values.This simple program expect four parameters as the c example above

api-key feed-id datapoint-name datapoint-value

so a typical update should have an action parameter that looks something like

<!-- Action parameter -->
        <param>xively_update 9ycPu4AxlK3YyqoEULi39abh1xfnyHwX1A9tu7pqKe3inOTi 2805488985 temp_office %measurement_float</param>

Se step 5 of the C example for the complete decision matrix row needed. Just add this row (or many of them) to start to log data to Xively. Thats all there is to it.

For convinience the code for the action is here


# Use as a VSCP action to update meaurement values to Xively
# See
# Ake Hedman, Grodans Paradis AB, <>

import sys
import xively

if len(sys.argv) < 5:
    print 'Xively Data updater'
    print '==================='
    print 'Error: To few paramers.'
    print 'Should be: api-key feed-id datapoint-name datapoint-value'

    # Connect to the API using your API key.
    client = xively.XivelyAPIClient(sys.argv[1])

    # Create a new Feed object.
    feed = client.feeds.get(sys.argv[2])

    # Let's give it one datastream with id 'temperature'
    datastream = feed.datastreams.get(sys.argv[3])

    datastream.current_value = sys.argv[4]

    # We only want to change current_value.

see the Xively python api documentation on how to create datapoints etc

How to use Xively MQTT and VSCP

The VSCP MQTT driver can be used with Xively also. The usage is described here.

A full step by step sample will be available soon.

howto/how_to_xively.txt · Last modified: 2018/02/08 17:47 (external edit)
[unknown button type]
Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki