How it works...

First, we initialize the Xively API client, to which we supply the API_KEY (this authorizes us to send data to the Xively device we created previously). Next, we use FEED_ID to link us to the specific feed we want to send the data to. Finally, we request the data stream to connect to (if it doesn't already exist in the feed, the get_datastream() function will create one for us).

For each data stream in the feed, we supply a name function and tags (these are keywords that help us identify the data; we can use our data names for this).

Once we have defined our data streams, we enter the main loop. Here, we gather our data values from dataDevice. We then set the current_value function and also the timestamp of the data for each ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.